Jump to content

Setting up multi-site development environment


MarkE
 Share

Recommended Posts

Having decided to migrate  to PW (one at a time) most of the half-dozen sites I manage, I thought that a multi-site (option#1 in https://processwire.com/api/modules/multi-site-support/) installation would be best as I would only have to do one upgrade each time (as well as saving a little space). So I set that up on the hosting service I use (two sites initially) and downloaded everything to my local (Windows 10) machine.

Locally, I use XAMPP and PhpStorm. I put the ProcessWire directory (with both sites and Wire) into htdocs. The site in the /site/ directory works fine using the localhost/processwire url, but whatever I try in the index.config.php file, I cannot get the second site to show - it always falls back to /site/ (because of the 

'*' => 'site',

entry).

Let's say the second site is in /site-new/ . How do I configure index.config.php to get that to launch locally? At the moment, my work-round is to change the name of the "catch-all" site to be whichever site I am working on, which is a bit clumsy.

Or would I have been better not to go multi-site at all?

Thanks for any insights.

Link to comment
Share on other sites

Seems to me that built-in approach requires domains, which of course can be temporary/fake/local domains and not real ones.

If you google something like "xampp custom domains" you'll find a few articles / threads on this, but general process involves editing your hosts file (whatever that is called in Windows) and adding these domains to Apache (via VirtualHost block somewhere, unless there's a GUI for this in XAMPP).

Best practice seems to be using .test domains for local development, i.e. site1.test etc. ProcessWire doesn't care that much about which domain you use, so having multiple rules ('site1.test' => 'site', 'site1.com' => 'test') shouldn't be an issue, but alternatively you could add some kind of test (ENV?) to choose which domain to pick. ?

Link to comment
Share on other sites

5 hours ago, MarkE said:

Or would I have been better not to go multi-site at all?

I'd vote for that. I've tried a multisite setup years ago but then ended up in a mess where I had several websites using one multisite setup and one breaking all others or being extremely tedious to bring out of that setup.

Customizations are not so easy, you might have modules that do not work on a multisite setup etc etc.

But maybe it was only me and it's working well for others. I'm happy to hear different experiences!

Link to comment
Share on other sites

Finally got it working after re-installing ProcessWire locally using Bitnami. With that installation (in xampp/apps/processwire) the url needs to be {domain name}/processwire not just {domain name}.

The issue as to whether multi-site is a good idea or not remains. I guess if I have problems I can always split them onto different installations.

Link to comment
Share on other sites

On 11/13/2018 at 9:18 AM, MarkE said:

Or would I have been better not to go multi-site at all?

 

On 11/13/2018 at 2:26 PM, bernhard said:

But maybe it was only me and it's working well for others. I'm happy to hear different experiences!

I use multi-sites (ProcessWire inbuilt one, aka Option #1), locally and remotely without issues. Locally, I have two main multi-sites; one for ProcessWire 2.7 and the other for ProcessWire 3.x. It means I don't have to mess about with Apache virtual environments for the 'sub-sites'. For local dev, I just need to make sure that my domains are resolved in hosts file.

For module development, I have each module as its own sub-site and the domain tells me what ProcessWire (main) version I'm testing on. So, something like:

 

// processwire 2.7
array(
	'mediamanager.pw27' => 'site-mediamanager',
	'blog.pw27' => 'site-blog',
	'runtimemarkup.pw27' => 'site-runtimemarkup',
	'*' => 'site' // main/mother site, e.g. sandpit.pw27
);
// processwire 3
array(
	'mediamanager.pw3' => 'site-mediamanager',
	'blog.pw3' => 'site-blog',
	'runtimemarkup.pw3' => 'site-runtimemarkup',
	'*' => 'site' // main/mother site, e.g. sandpit.pw3
);
On 11/13/2018 at 2:26 PM, bernhard said:

you might have modules that do not work on a multisite setup

This shouldn't be an issue if using Option #1 as each site has it's own 'site' folder, e.g. 'site-a', 'site-b', etc. with their own assets and modules. The issue would of course be, if one of the modules is not compatible with the one 'wire' running the site. It means you might have to do away with that module or not upgrade 'wire' ?.

On 11/13/2018 at 7:22 PM, MarkE said:

With that installation (in xampp/apps/processwire) the url needs to be {domain name}/processwire not just {domain name}.

I'd just create my own domains using hosts for lookup and have them served locally.

  • Like 1
Link to comment
Share on other sites

11 minutes ago, kongondo said:

shouldn't be an issue

Shouldn't, but my experience was different ?

You cannot have different htaccess files for example. So using ProCache is all-or-nothing. Things like that bugged me. That's why I switched. Laragon makes it so easy to setup new projects... just create a new folder in C:/laragon/www and click reload. You'll have a new vhost, https support and you can even share that site via ngrok temporarily and publicly. That's great when you want to show something to a client or to try webhooks of a third party service.

  • Like 1
Link to comment
Share on other sites

17 minutes ago, bernhard said:

You cannot have different htaccess files for example. So using ProCache is all-or-nothing.

Good point.

17 minutes ago, bernhard said:

That's why I switched. Laragon makes it so easy to setup new projects... just create a new folder in C:/laragon/www and click reload.

Don't remind me please ...? I'm still very raw ?.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...