You want site1.example.org, site2.example.org, and site3.example.org on the same server, or virtual private server, using one copy of Drupal and a separate database for each site. You are using Cpanel. The first site will take whatever time you need to upload and install Drupal. The second and subsequent sites will take 5 minutes each. This example uses Drupal 6. Drupal 7 appears to be the same.
Drupal 6 and 7
The cPanel part of this page is the same for Drupal 6 and Drupal 7. I use exactly the same procedure for Drupal 7 multisite. Please add a comment if you do find a difference for Drupal 7 or a new release of cPanel.
- First site
- Second site
- Third site
- Update notifications
- Which site goes first?
- cPanel interface
- Drupal in a subdirectory
- Drupal lookup documentation
- SSL certificates for multiple sites
I assume you have the first site set up. You used WHM to create a database account for site1.example.org then went into Cpanel for site1.example.org to set up email and install Drupal. You now have site1.example.org working with Drupal 6.
When you created site1.example.org, you created a user for the account and I will assume the user is named site1. Use the MySQL Databases option or the wizard. I use the MySQL Databases option. You create a database named drupal and cpanel shows a database named site1_drupal. You create a user named drupal for the database and Cpanel displays user site1_drupal. You then connect user site1_drupal to database site1_drupal with all privileges.
You use the Cpanel Email Accounts page to create some email accounts for site1.example.org including one named boss. You will use boss (at) site1.example.org as the email address when you create the administration account during the Drupal installation.
When installing Drupal, you create directories /sites/default/ and /sites/default/files/ plus file /sites/default/settings.php. You set the permissions to 777 then run the installation step then set /sites/default/settings.php back to 644. You will repeat this step once for each new site.
Go into Cpanel on site1.example.org and park domain site2.example.org on site1.example.org. While you are there, park site3.example.org on site1.example.org. If you run into a limit on the number of parked domains, you can go back into WHM to increase the limit. You want a database per domain so while in WHM, increase the limit on the number of databases.
Create a database and database user for site2.example.org, perhaps user site2 connected to database site2. Repeat for site3.example.org with user site3 connected to database site3.
Go into Email Accounts and create boss (at) site2.example.org plus boss (at) site3.example.org.
You probably used FTP to upload Drupal 6 to site1.example.org. I will assume FTP. There is a file manager in Cpanel that does similar things to Filezilla and other FTP programs. Go into /sites/ and create directory site2.example.org. While in /sites/, create directory site3.example.org.
Create directories /sites/site2.example.org/files/ and /sites/site3.example.org/files/ with permission 777.
Copy /sites/default/default.settings.php to /sites/site2.example.org/ and rename the file to settings.php then give it permission 777. Copy /sites/default/default.settings.php to /sites/site3.example.org/ and rename the file to settings.php then give it permission 777.
Do you notice how you are repeating part of the original installation? Yeah, it gets boring if you have 2000 sites.
Visit http://site2.example.org/ and up pops the Drupal 6 installation process, exactly the same as happened with site1.example.org. Answer the same questions. Use the right database name, database user name, and password.
Visit http://site3.example.org/ and up pops the Drupal 6 installation process, exactly the same as for site1.example.org and site2.example.org.
Done! You could do ten at a time if you can keep track of all the passwords. Replace your Drupal Beginner t-shirt with the Drupal Do It In My Sleep t-shirt.
Put standard themes in /sites/all/themes/ to let every site use the themes. Site specific custom themes go in a /themes/ directory within the site, e.g., /sites/site1.example.org/themes/ for site1.
You have a separate database for every site so you can activate different modules for each site. Put the modules in /sites/all/modules/ then let each site switch them on or off.
Drupal automatically checks for code updates unless you turn off update notifications. You have only one copy of the code so switch off update notifications for all sites after the first.
Ok, darumaki pointed out the case where different sites use different modules.
This might be fine if every site was using the same modules, however, a typical multi-site setup usually involves each site using different modules, therefore, it should not be advised to turn off updates on the other sites, because updates only checks the modules that are enabled and not all the modules in the module directory. You could turn on every single module in your base domain, to get update notifications, or you could turn on updates in just those domains with something different.
The same consideration applies to themes because theme updates are detected and notified the same as module updates. The main saving from turning off updates is when you set up 3550 identical sites for the 3550 members of a professional association. They want separate databases for client privacy but they all get the same modules and features as specified by their association.
You have one copy of the code so put all the sites offline before updating the code. You have a database for every site so run update.php on every site before switching the sites back online.
Which site goes first?
The first site is locked in place while any other sites are parked on top. Use a throwaway site for the first site.
When I registered petermoulding.com, I registered the .biz and some other variations for experiments. I used the .biz domain name as the base site for the multisite setup because the .biz domain name will not be visited by anyone but me. Each time I load a new theme into /sites/all/themes/, I can activate it in site1.example.org for testing. When one of the added on sites becomes too busy for the server, I can move the added on site without disturbing the other sites.
The first site is also the default site your customers will see when there is a setup failure in Drupal or Apache. Put contact information on the first site so people can report failed Web sites.
Cpanel provides several themes and each theme shows different combinations of buttons. I use crimson_smoke for these screen shots.
Go to the domains section to park your new domain, site3.example.org, to your existing domain, site1.example.org. Do not use Subdomain or Addon domain for this part of the setup.
You add subdomains in the form x.example.com. For domain site3.example.org, you might add forums.site3.example.org and shop.site3.example.org. First you would park site3.example.org on site1.example.org and create site3.example.org in Drupal following the instructions on this page then you would look at adding forums and shop to site3.example.org. Adding subdomains should be covered in another page because there would be considerations around sharing user ids across the domains.
The following image shows the Cpanel subdomain page. You can add, edit, and delete subdomains. If you leave the document root field empty, the result will be similar to parking a domain and should let you use multisite. Multisiting forums.site3.example.org next to site3.example.org would require public_html/sites/forums.site3.example.org/settings.php, another database, and a way to share the login.
Addon domains are similar to parked domains but add more complications. Do not use Addon domains for the procedure in this page, use Parked domains.
The following image shows the Cpanel domain addon page. Notice the password field. Addon domains have a subaccount type arrangement you might use if you want to delegate administration to someone else. You could put several domains in one WHM account using separate subdirectories and give each site administrator separate FTP access. The separate FTP access does not work with multisite because they all share the same directories. Instead use Parked domains and control uploading of files using a Drupal module.
If you insist on using Addon domains instead of Parked domains then set Document root to public_html/. Drupal multisite is based on all page requests from all sites going to the same public_html/index.php.
You can park domain egjhnbhniu.com on example.com and Drupal can separate the two if they have separate multisite settings. You use Parked domains without redirection. A request for egjhnbhniu.com/food/turnip goes to public_html/index.php then Drupal looks for public_html/sites/egjhnbhniu.com/settings.php and uses the database from the settings file. If public_html/sites/egjhnbhniu.com/settings.php is missing, Drupal uses public_html/sites/defaults/settings.php and you see a page from example.com.
The following image shows the simple Cpanel domain parking page. It is simple because their are no passwords or document root settings. This is all you need for multisite.
A redirect sends one domain to somewhere on another domain. egjhnbhniu.com could be redirected to example.com/test-sites/egjhnbhniu/. A common use is for personal Web sites. You create example.com/~george then, for your birthday, grandma buys george.com for you. You can redirect george.com to example.com/~george. When visitors visit george.com, they see example.com/~george so do not redirect, add george.com as a subdomain with a document root of ~george.
Drupal in a subdirectory
When you install Drupal in /home/example/public_html/, site3.example.org is in /home/example/public_html/sites/site3.example.org/ and you access Drupal as http://site3.example.org/. If you install Drupal in a subdirectory, for example /home/example/public_html/drupal-6.13/, you can access Drupal as http://site3.example.org/drupal-6.13/.
An alternative is to change the way you park the domain. Put /drupal-6.13 the Domain Root setting. Set Domain Root to /public_html/drupal-6.13 and access Drupal as http://site3.example.org/.
Drupal lookup documentation
There are lots of questions about the Drupal lookup sequence to get from a domain name to a settings.php file. The Drupal documentation is in INSTALL.txt under the heading MULTISITE CONFIGURATION. The following list is the lookup sequence from Drupal 6.12 INSTALL.txt for www.sub.example.com/site3.
Note that Drupal will not look in sites/sub/settings.php or sites/site3/settings.php.