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 one of the Multisite modules (option #2).

If using ProcessWire 3.x, you might also be interested in multi-instance support, which is a different topic from this but may have some crossover, depending on your need.

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 Alternate
You 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, or the newer 3rd party Multisite module by Soma. These modules may not be in active development at present, but are still applicable and useful starting points if you are interested in implementing this kind of multi-site support.

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.

How to install

Installation instructions and support can be found on the Multisite forum thread.

Comments

  • Adam

    Adam 5 years ago 43

    I have one question about method #1. As I read, I shouldn't have two different sites sharing the same database. OK. But how about templates? Is there any possibility to share templates in all pages?

    • ryan

      ryan 5 years ago 33

      You could share template files if you wanted, by replacing one of the /site/templates/ dirs with a symlink.

  • Adam

    Adam 5 years ago 33

    Works like a charm on localhost (and servers where can make symlinks). But how about hosting where I can't make symlinks? Is there any other possibility to share templates using method #1?

    • ryan

      ryan 3 years ago 33

      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

    steve 4 years ago 33

    Is there some reason I can't simply create a new site-whatever folder, then run the installer from the new domain? Why the extra step of installing in a tmp directory?

    • Jim

      Jim 3 years ago 33

      @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...

    • ryan

      ryan 3 years ago 33

      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.

  • Paul

    Paul 3 years ago 43

    Hi. I'd like to set up temp/staging sites for my clients so I can develop them before moving them to their own hosting accounts. I'm wondering if this set up is possible:

    Root
    -processwire (single, main installation of PW)
    --wire

    -clients
    --client_a
    ---site (PW site directory - unique templates, database, etc)

    --client_b
    ---site

    --client_c
    ---site

    etc.

    ie, somehow 'point' all site directories to the same pw installation.

    Sorry if this is a little noobish.

    • ryan

      ryan 3 years ago 63

      If these are ultimately all going to be different client sites, I would suggest this:

      /processwire-src/

      /client-a/
      /client-a/wire/ => symlink to /processwire-src/wire
      /client-a/site/

      /client-b/
      /client-b/wire/ => symlink to /processwire-src/wire
      /client-b/site/

      And so on.

      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.

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.