
Have a cPanel shared hosting account and want to use Drupal to host multiple sites, this article will help. By creating such a configuration, you can have one shared code base and separate databases per website making it easier to upgrade and maintain.
These instructions are can be used with any cPanel based share hosting account. We assume you are hosting on a LAMP application stack (Linux, Apache, Mysql, PHP).
Before you begin, make sure you have the following system requirements:
To make the explanations in this article easier to understand, assume site1.com is your main domain name and site2.com, site3.com, etc. are your other domains. Of course, substitute these with your real domain names.
We will start by creating our first domain.
(*) Note that it may take up to 24 hours before your domain name resolves as it needs to propagate across the Internet.
Go to cPanel and click on the php.ini QuickConfig icon. Make sure the following configurations are set:
Do NOT change $db_url to your database parameters of username/password/server/databasename as this will result in tables not being created. Just leave these files alone and let Drupal fill it in on install.
Take the original .htaccess from Drupal and modify the file to add the following:
RewriteCond %{HTTP_HOST} ^siteN\.com$ [NC]
RewriteRule ^(.*)$ http://www.siteN.com/$1 [L,R=301]
For SEO purposes we make sure all URL requests go to the canononical URL. That is, if someone typed http://siteN.com or http://www.siteN.com it will be changed to http://www.siteN.com/.
Go to http://www.site1.com and you should be presented with the installation program. Fill in all the information as required and write down everything you entered to refer back later.
Make sure you test everything out to make sure it works.
Now that you have your main site installed, you can add additional Drupal sites! You basically do the same steps again.
(*) As you add more domains through cPanel site2.com, site3.com folders will be created. Delete them as they won't be used. You will see why below.
Here is the trick to creating Drupal multisites. Now that the siteN.com folder is deleted you must point siteN.com to the root public_html folder. On shared hosting accounts you don't have root access so you have to do it though programming.
Run your text editor and create a symlinkcreate.php file. Type the following in:
<?php symlink( '/home/yourusername/public_html/', 'siteN.com' ); ?>
Replace username and siteN.com with appropriate information. FTP symlinkcreate.php to public_html and run it from your browser (http://www.siteN.com/symlinkcreate.php).
After execution, a folder by the name of siteN.com will exist. If you use your FTP client to access the siteN.com folder, it will point back at your public_html root.
Technical stuff:
The Apache httpd.conf is told that a siteN.com virtual host is available at /public_html/siteN.com directory. Every siteN.com HTTP request is file mapped to /public_html via the symlink. Because index.php is the default home file it will get executed. Index.php is Drupal's bootloader so all website requests to the symlinks will be handled by index.php. This is how a Drupal multisite can work.
Do the same instructions as mentioned above to add your new site to .htaccess for friendly URLs and site SEO.
Go to www.siteN.com and you should be presented with the installation for your siteN.com domain. Fill in all the information as required.
Congratulations! You are now done!
Proceed to add modules, setup users and all the other things you need to run your site. Refer to the Drupal documentation for assistance.