Skip to Content

truly simple cPanel multsite setup

Posted in

No single multisite setup method above got me all the way there; if you have cPanel and Drupal installed on your original domain, follow these straightforward instructions to set up a multisite:

For 'www.yourlovelysite.com':

1. in cPanel, go to 'Subdomains'

2. enter a name for you subdomain; this is followed by '.' and your original domain name automatically, e.g. 'sub1' becomes 'sub1.yourlovelysite.com'.

3. enter a 'Document Root'; this needs to point to the folder in your directory containing the 'index.php' file that a Drupal installation creates, e.g. 'public_html', and Create. Please note cPanel may automatically insert "public_html/sub1" - delete "sub1".

4. in cPanel, go to 'MySQL Databases'.

5. name a new database and 'Create Database'.

6. scroll down to 'MySQL Users' and 'Add New User' - and insert a username and password (twice) - give the user all privileges. Make a note of username/password.

7. in 'Add User to Database', associate your new username with the name of the database just created.

8. in cPanel, go to 'File Manager' - though this can be done using Dreamweaver or other ftp software - create a new folder in the 'sites' folder, which is in the root of the Drupal installation, named after your subdomain, e.g. 'sub1.yourlovelysite.com'.

9. copy the file 'settings.php' from the 'sites/default' folder, which you should have already from your original Drupal install, and paste it into your new subdomain folder 'sub1.yourlovelysite.com'.

10. grant this new 'settings.php' all permissions.

11. open 'settings.php' and locate the line "$db_url = 'mysql://username:password@localhost/databasename';".

12. replace each 'variable' with the respective thing, e.g. $db_url = 'mysql://newdatabaseusername:newdatabasepassword@localhost/newdatabasename'; and save.

13. now you have a database for your new subdomain which you access using 'settings.php' in your new subdomain folder.

14. go to 'sub1.yourlovelysite.com/install.php' and follow the familiar steps for a Drupal installation.

That should do it.

You can repeat this method over and over: sub2, sub3... and so on.

Important:
When you upload files/images to your subdomain, by default, Drupal will place that file in 'sites/default/files'. To organise and to avoid your subdomains overwriting each others' files, change the 'file system path' in 'Administer > Site configuration > File system' to something like: 'sites/sub1.yourlovelysite.com/files'. This should be remembered/reversed if the subdomain is ever moved to its own site, otherwise your pictures will disappear as Drupal is looking in the wrong place for them.

credit: Andrew Smith