Multiple-site support

Multiple-site support implies running multiple web sites at independent domains or subdomains from the same ProcessWire installation and web hosting account.

ProcessWire can support multiple site setups using various methods, and you'll find several techniques discussed in the forum. On this page we outline the two most common and recommended methods of supporting multiple sites.

The core supports multiple sites running on the same web account and ProcessWire installation, with each site maintaining its own database and /site/ directory (option #1). You can also run multiple sites from the same database by installing the Multisite module (option #2).

Option #1: multiple sites with multiple databases

This section outlines how to install multiple sites on the same ProcessWire installation, where each site has it's own database and /site/ directory (templates, modules, etc.)

Advantages

Sites remain independent from each other and thus highly organized and easy to maintain or move.

This method of multi-site support is built into ProcessWire's core and thus doesn't require installation of any other modules.

If your sites are different from one another in terms of design and function, then you'll find this approach may be preferable in keeping your site's templates, fields and modules more organized.

Disadvantages

Sites can't easily share data with each other, since they are running independently from one another.

Each site not only has it's own database, but it's own template files and 3rd party modules–this is an advantage or a distadvantage, depending on your needs.

If you need to maintain the same user accounts across all the sites, you'd have to maintain them individually on each.

How to install

Point another domain or subdomain to your current ProcessWire installation. When you access that domain or subdomain, it should load your existing ProcessWire site.

1. Create a subdirectory off of your web root called /tmp/ (or another name if you prefer). We will temporarily install a separate copy of ProcesWire there. So download and install a new copy of ProcessWire in that /tmp/ directory (run the installer by loading the /tmp/ URL in your web browser) . When it asks for database settings, make sure you are installing to a separate database than the one used by your main site. There is also an alternate version of step 1 further down, if you want to instead use a site that already exists.

2. Once installation has completed, move or rename the /tmp/site/ directory to a /site-name/ directory in your main ProcessWire installation. You may name the directory whatever you want, so long as it starts with "site-", i.e. "site-name", "site-something" or "site-cats"… whatever you want. Just don't call it /site/, as that is already there for your main site.

3. You may now delete the /tmp/ directory where you installed the other copy of ProcessWire–it is no longer needed.

4. Now you should just be left with your main site, but with the new /site-something/ directory. Copy or move the file /wire/index.config.php to /index.config.php (moving it into your web root).

5. Now edit that file with a text editor: /index.config.php. You will see instructions embedded in the file, follow them. To summarize those instructions, you will be telling ProcessWire to look for requests for your other domain or subdomain, and use the site installed at /site-something/ instead. Save.

6. Now access your alternate domain or subdomain in the browser. It should now be functional. To edit template files for this site, edit the files in /site-something/templates/. To edit pages for that site, login at the site's /processwire/ URL (at the newly added domain/subdomain).

Step 1 AlternateYou don't necessarily have to install a new copy of ProcessWire for step 1. If you have an existing site that you want to install instead, all you need is its /site/ directory and database. Using PhpMyAdmin or another tool, export the database from that site, create the new database, and import the data you exported. Then take the /site/ directory from your new site that you want to install and copy it to a /site-something/ directory where you want to install it (which is your ProcessWire installation where you want to support multiple sites). Once you've done that, edit the /site-something/config.php file and note the database information at the bottom. Edit it to be consistent with the database you created and imported.

Option #2: multiple sites from the same database

This option requires installation of the 3rd party Multisite module by Antti Peisa.

Advantages

All the individual sites or domains are running from the same database and thus can talk to each other. One site can pull data from another.

The sites can share the same templates, template files, fields and modules (an advantage or a disadvantage, depending on your needs).

All the user accounts are the same along the various sites. If you have the same team administering the individual sites, then this would be a major benefit.

Unlike option #1, you can and should re-use templates and fields where appropriate. If your multiple sites are similar in design and function, you may find this approach preferable to option #1.

Disadvantages

Your ProcessWire API usage must be coded in recognition of the multi-site environment, and thus one couldn't as easily move them out of this context as they could with option #1.

Requires installation of a 3rd party module, so you may have to be more careful in ensuring everything works through upgrades and such.

What is an advantage to this approach (sharing data) may be a disadvantage in keeping things organized long term. However, that can be easily solved with a little bit of discipline on your part in keeping things organized.

If your sites are not sharing the same templates to a large extent, you will have a lot more to keep track of [administratively] than if you kept them independent like in option #1. When you view your templates, fields and modules in the admin, you'll be viewing them for all the sites at once.

It doesn't technically have to be symlinks. They can be aliases or whatever method of symbolically linking one directory to another your server supports. But since ProcessWire is primarily designed for the LAMP server environment, we focus in on symlinks when it comes to instructions like this.

@Steve ...because in PW 2.4 the site path is hard-coded in install.php.

Even though index.php and index.config.php properly create a $siteDir member based on the URL you browsed to (and put into your index.config.php), install.php has a hard-coded path that always begins with './site/', instead of any custom/alternative site directories you might create.

One workaround is the tmp folder procedure presented above. Any other workaround would involve directory renaming.

The best solution (imho) would be to update install.php to use the $siteDir var as produced by index.php and index.config.php, which (hopefully) would also allow you to custom-name your default site, and still use the stock install.php...

It's a safety measure to ensure you don't interfere with your existing running copy. You may be able to omit that step one way or another, or by modifying your index.php as Jim suggested. But we'd prefer you start with a fresh installation that doesn't have any potential to cross-over with your existing site, and that's why it's good to install from a temporary directory.

Each of your /client directories would have their own /index.php and /.htaccess file in them. But they would all share the same /wire directory (and thus ProcessWire code/version) via symbolic links or aliases. You will also want a separate database for each of the client sites.

This is pretty easy to setup because whenever you want a new client site, you just grab a new copy of ProcessWire and put it in your /client-x/ directory. Then remove the /wire/ directory that is in it, and replace it with a symlink/alias to /processwire-src/wire/. This is the setup I have always used here and it works well on my dev server.

Latest Forum Posts

Latest Blog Post

ProcessWire 3.0.76, a new front-end account module and much moreThis week we’ve got a new core version, a new version of the Uikit 3 admin theme, a new version of ProCache with SCSS and LESS support, plus a brand new module that provides user login, new user registration and a user profile editor, all for the front-end of your site. / Blog / RSSSeptember 22 6:02 pm