multisite using subdomains in cpanel with symlink

I've followed the bits and pieces that I've read:

1) create a folder in: /public_html/drupal/sites/

2) create the subdomain 'sub' in cpanel

2) delete the subdomain folder which is created: /home/user/public_html/sub

3) in drupal (6.x), create a page (with php input on) and type the following to create a symlink:

symlink( '/home/user/public_html/sub', '/home/user/public_html/drupal/sites/' );

However, when run, I get the error:

warning: symlink() [function.symlink]: File exists in /home/pulpoco/public_html/website/includes/ : eval()'d code on line 2

Any idea why this is not creating the symlink?


Magnity’s picture

I think you are using the wrong locations in your symlink code. Try reading this thread:, especially that comment.

Especially, you do not have to link to the sites/ folder, just from the subdomain directory to the main drupal installation.


-Anti-’s picture

Here's how I got a subdomain multisite to work with cpanel account and a symlink (php method)

1) My main drupal installation was installed into public_html/subfolder and was working.

2) The 'sites' folder is set by drupal to 555 CHMOD.
It was necessary to CHMOD it (and all the files/folders below it) to 755 for the next step.

3) I created a folder: /public_html/subfolder/sites/

4) I put a BLANK settings.php into /public_html/subfolder/sites/

5) I created the subdomain 'sub' in cpanel, and then deleted the folder /user/public_html/sub.

6) I ran the following php file to create a symlink:

symlink('/home/user/public_html/subfolder', '/home/user/public_html/sub');

Note: just copy/paste the above into a txt file, replacing 'subfolder' with your main install directory, and 'sub' with whatever your subdomain is. Save the file as symlink.php and upload it to public_html. Run it by pointing your browser to

6) This creates the symlink 'folder': /public_html/sub
When clicking on this symlink folder in my ftp client, it lists the contents of /public_html/subfolder/
although the ftp path reads /public_html/sub/ That's an easy check to see if the symlink is working.

7) I pointed my browser to
The INSTALL script started, allowing me to choose an admin account and a database (or existing database and new prefix).


cog.rusty’s picture


symlink( '/home/user/public_html/drupal', '/home/user/public_html/sub' );

The first one is the destination, the second one is the filename of the new created symlink.

But for this to work (using php), public_html must be writable by apache at the time that you run this script. If you can't make it writable, then the symlink file won't be created and you will need shell access to give the command yourself.

By the way, the drupal/sites directory is drupal's internal business. It has nothing to do with the symlinks. Drupal needs it to bring up the site which matches the requested URL.