You are here

Creating a drupal multisite install on a2hosting.com

It took a little while but here is the formula for creating a multisite install of drupal on a2hosting with shared hosting: 1 install base with each site having its own database.

I am assuming you maintain all the addon and subdomains and have full control over them. Thus all extra non-core modules can simply be put under the main drupal install so it doesn't matter if they are enabled or not in each drupal site.

1. Install drupal in the main public_html directory and ENSURE it is working first:
/public_html/files
/public_html/includes
/public_html/misc
/public_html/modules
/public_html/profiles
/public_html/scripts
/public_html/sites
/public_html/themes
/public_html/.htaccess
/public_html/CHANGELOG.txt
/public_html/INSTALL.mysql.txt
/public_html/INSTALL.pgsql.txt
/public_html/INSTALL.txt
/public_html/LICENSE.txt
/public_html/MAINTAINERS.txt
/public_html/UPGRADE.txt
/public_html/WS_FTP.LOG
/public_html/cron.php
/public_html/index.php
/public_html/install.php
/public_html/robots.txt
/public_html/update.php
/public_html/xmlrpc.php

2. Create your subdirectories - one for each site. Examples:
/public_html/addondomain
/public_html/subdomain

3. In cpanel, create addons or subdomains:
An addon is a domain name that is different that your main domain name for your a2hosting account.

Main domain: maindomain.com
Addon: addondomain.org

addondomain.org has files stored under Maindomain.com but is still a separate domain. Create this under cpanel:

Name - [actual name of domain such as anotherdomain.org]
Folder - [just the name of the file folder under public_html without slashes]
Password - password that will be used for the ftp username

A subdomain is a name appended to the front of your main domain:

maindomain.com -> joe.maindomain.com

4. Create a folder for each addon and subdomain under:
/public_html/sites

For example:
/public_html/sites/joe.maindomain.com
/public_html/sites/anotherdomain.org

Put a settings.php file in each directory under /public_html/sites/[domainname]. DO NOT PUT THE SETTINGS.PHP UNDER A WRONG DIRECTORY (ie /public_html/sites/[domainname]/sites or /public_html/sites/[domainname]/sites/default).

Here, you can define different databases, users, and passwords for each site, if you chose to have a different database for each one.

5. Create symbolic links for all the directories and files pointing from each of your subdirectories to the main install of drupal (if you have a business account under a2hosting you have access to SSH or shell access):

ln -s /home/[username]/public_html/includes /home/[username]/public_html/joe/includes
ln -s /home/[username]/public_html/misc /home/[username]/public_html//joe/misc
ln -s /home/[username]/public_html/modules /home/[username]/public_html/joe/modules
ln -s /home/[username]/public_html/profiles /home/[username]/public_html/joe/profiles
ln -s /home/[username]/public_html/scripts /home/[username]/public_html/joe/scripts
ln -s /home/[username]/public_html/sites /home/[username]/public_html/joe/sites
ln -s /home/[username]/public_html/themes /home/[username]/public_html/joe/themes
ln -s /home/[username]/public_html/cron.php /home/[username]/public_html/joe/cron.php
ln -s /home/[username]/public_html/index.php /home/[username]/public_html/joe/index.php
ln -s /home/[username]/public_html/install.php /home/[username]/public_html/joe/install.php
ln -s /home/[username]/public_html/update.php /home/[username]/public_html/joe/update.php
ln -s /home/[username]/public_html/xmlrpc.php /home/[username]/public_html/joe/xmlrpc.php

Site5 might look like this:
ln -s ~/public_html/drup/includes ~/public_html/directinstruction/includes
ln -s ~/public_html/drup/misc ~/public_html/drup/misc
ln -s ~/public_html/drup/modules ~/public_html/directinstruction/modules
ln -s ~/public_html/drup/profiles ~/public_html/directinstruction/profiles
ln -s ~/public_html/drup/scripts ~/public_html/directinstruction/scripts
ln -s ~/public_html/drup/sites ~/public_html/directinstruction/sites
ln -s ~/public_html/drup/themes ~/public_html/directinstruction/themes
ln -s ~/public_html/drup/cron.php ~/public_html/directinstruction/cron.php
ln -s ~/public_html/drup/index.php ~/public_html/directinstruction/index.php
ln -s ~/public_html/drup/install.php ~/public_html/directinstruction/install.php
ln -s ~/public_html/drup/update.php ~/public_html/directinstruction/update.php
ln -s ~/public_html/drup/xmlrpc.php ~/public_html/directinstruction/xmlrpc.php

Site5 has a cheapo shared service whereby you don't use symbolic links, you simply set everything up under the sites/ directory. The files directory is tricky. I ended up creating separate files directories under the root directory.
6. Ensure your settings under /public_html/sites/joe.maindomain.com has the right database information. Then install drupal for that subdomain:

http://joe.maindomain.com/install.php

or

http://anotherdomain.com/install.php

7. If you make a mistake in making a symbolic link, simply remove by - eg:
rm index.php
rm install.php
rm cron.php
rm xmlrpc.php
rm includes
rm misc
rm modules
rm profiles
rm sites
rm scripts
rm themes
rm update.php

Articles: