Advices needed in setting up multisite subdomain folders with cPanel

My hosting server (Lunarpages) uses cPanel and I'm trying to setup 2 subdomains (sub1 & sub2), the problem is when cPanel creates a subdomain, it creates automatically a subfolder under the root (public_html), and if I would like to set the sub1 folder under public_html/sites, then they told me I have to change .htaccess file. I'm not that familiar with Linux/Unix, can someone tell me what's the pros/cons in doing that and which .htaccess I have to change. If it's not too much trouble, a sample will be awesome (I'm new to Drupal).

Thanks for your suggestion/comment
Michael

Groups:
Login to post comments

You can specify the home directory on cPanel

drm's picture
drm - Sat, 2009-02-14 16:52

Every version of cPanel I've used lets you specify the home directory, which it calls the Document Root. The default is to create a new directory, but when you create the subdomain, there is a field to specify a different directory. And I think you need to point it to public_html, not public_html/sites.


Thanks for your reply, but

michaelbr - Mon, 2009-02-16 02:49

Thanks for your reply, but Lunarpages does not have that option, therefore you can only have a subdomain folder under public_html and if you want to do a redirect, you'll need to change the .htaccess file.

Thanks in advance for your suggestion/comment
Michael


Well...

kham08 - Mon, 2009-02-16 03:17

Right -- all hosts will have that folder in your web root (public_html/) -- and a folder is created in that location using these steps. Did you try it or are you making the assumption that it won't work?

Drupal processes all url requests and decides which subdomain site folder (and settings.php) to operate from based on the request. You CAN have a site1.yourdomain.com folder under sites/ because that's the only way Drupal multisite works. You do have drupal installed at the root and are trying to run another site with the same drupal instance (multisite), right?

These steps create a symlink to handle the redirect so that you will not have to monkey with your .htacess file. The public_html/site1 folder stays put and functions in the redirect.

I'd put your .htaccess file back in the order you found it and try the steps I've outlined. It will save you all the hassle I went through putting the same question to rest for my own site. If you find you can't operate using symlinks (not likely) I'd find another host provider. It's way too simple this way.

Good luck!


Just re-read...

kham08 - Mon, 2009-02-16 03:23

...your original post.

It's clear what you are attempting is a multisite setup.

You are getting the subdomain folder issue confused. You will have a public_html/site1 subdomain folder as a site architecture neccessity, and DRUPAL will use the one you create -- sites/site1.yourdomain.com. "Subdomains" as your host views them and "subdomain sites" as Drupal understand them are two separate things, both of which will be addressed in the end with the two differetn folders we're talking about.

Just slow down, follow the steps carefully and it will work. I've done it a brazillion times.


I've been excatly where you are

kham08 - Sun, 2009-02-15 16:29

Follow these by the letter and you should be OK. (The steps 1 and 2 under Step 9 should be Steps 10 and 11 -- just a formatting quirk I guess)

  1. In CPanel, set up the subdomain and point it to http://yourdomain.com (The DNS updates from the subdomain add/redirect can take several hours to complete.......). For the example of site1.yourdomain.com, a folder named 'site1' will be automatically created by CPanel. Delete the folder that was created.
  2. Create a folder in the sites/ folder that matches the subdomain you want to create (so for site1.yourdomain.com, the folder name would be site1.yourdomain.com).
  3. Create directory /sites/sitename.isalescards.com/files/ with permission 777.
  4. Duplicate the settings.php file from the default folder and place it in your newly created folder from step 2.
  5. Edit the settings.php file you just placed in the site1.yourdomain.com folder so that it does not point to a database. You can replace the line that has your other site's database information with this:

    $db_url = 'mysql://username:password@localhost/databasename';

  6. Then give settings.php permissions of 777 (Drupal will reset permissions to 644 when it is finished with the file). This will allow step 10 below to load your database tables.

  7. Use the following example to create a 'multisite.php' file and upload via FTP or CPanel's File Manager. Make sure you change the path to whatever the path to your web root is.

    <?php
          symlink
    ( '/home/username/public_html/', 'site1' );
         
    ?>

  8. Go to the location of the php file in your browser (such as www.yourdomain.com/multisite.php). This will create a symlink (and a new 'site1' folder), allowing your subdomain to work properly.

  9. Create a database and database user for sitename.isalescards.com.
    1. Go to your subdomain and start the Drupal 6 installation process. Drupal will ask for your database information and then install the tables necessary to run the new site.
    2. You're all set to use the new site.

Thanks kham08 for your

michaelbr - Mon, 2009-02-16 03:49

Thanks kham08 for your reply, I did a little bit different from you, this is what I did and it didn't work (got redirect loop error):
1) installed D6 under public_html (root in my hosting server).
2) created a subdomain sub1 in cPanel, it created automatically a folder public_html/sub1, I did not change anything else.
3) created a folder under sites (public_html/sites/sub1)
4) moved cgi-bin folder (created by cPanel during subdomain creation) from public_html/sub1 to public_html/sites/sub1
5) modified .htaccess to add the following statements:
RedirectMatch /sub1/* http://www.mydomain.com/sites/sub1
then put this file in public_html

when I tried to go to http://sub1.mydomain.com or http://www.mydomain.com, I got redirect loop error message. I contact Lunarpages support and they told me that I could not remove the public_html/sub1 folder, what I need to do is put the .htaccess under public_html/sub1 folder instead of public_html

The only difference with your instructions is during the subdomain creation, my hosting server is pointing directly to subdomain's folder (public_html/sub1) and you are pointing to public_html (how do you point to public_html? using redirect in cPanel > subdomain?), and I have no choice other than do a redirect either in cPanel or through .htaccess file, which is what you're trying to avoid.

Based on my understanding, you're trying to tell me not to use .htaccess to redirect, instead use symlink to do this work, is it right? Let me try and post back the result. Thanks

Thanks in advance for your suggestion/comment
Michael


a lot to change

kham08 - Mon, 2009-02-16 04:50
  1. correct
    2 remove that site 1 folder and let the symlink step recreate it
    3 wrong folder name -- read my instructions carefully -- sites/site1.yourdomain.com is the correct name
    4 never move your cgi-bin...put it back where you found it
    5 leave the .htaccess alone after restoring it to how you found it
    6 now you can follow the instructions I sent you, completely and to the letter. pay attention to them becaus edoing somthing close isn't going to work. if you try to follow half of mine and half of something else you will only run yourself in circles.

Thanks so much for pointing

michaelbr - Mon, 2009-02-16 12:18

Thanks so much for pointing my mistake, now it's working, followed your instructions and everything is fine now. Thanks so much.

Thanks in advance for your suggestion/comment
Michael


Did exactly this, and get page not found

beanworks's picture
beanworks - Wed, 2009-03-04 18:15

I have several domains on my shared hosting account. The public_html directory has drupal installed in it because that's the root for the main domain. There are directories for site2.com, site3.com, and site4.com in the public_html directory as well, each with their own drupal installations. I am trying to make site2.com a multisite install with a subdomain (subdomain.site2.com).

So far, drupal is running fine on site2.com. So I followed the steps above. But on step 1, cpanel wanted to know where the root for subdomain.site2.com is, so I put site2.com as the root. I did not tell cpanel to redirect anywhere. (I deleted the subdomain directory created in the sites2.com directory) Then I proceeded with the rest of the steps.

When I type in the URL (subdomain.site2.com) it goes to site2.com/sites/subdomain and gives a file not found error.

I know I must be missing something, but I can't figure out what it is. Any help would be greatly appreciated.

Thanks!
Carol


don't know how, but it's working

beanworks's picture
beanworks - Wed, 2009-03-04 18:34

The multisite.php file had created a redirect, visible in cpanel's listing of subdomains, so I clicked on the "manage redirect" link and took out the redirect it had for subdomain.site2.com (site2.com/sites/subdomain). Then I went to site2.com/multisite.php, and then to subdomain.site2.com/install.php and voila! ready to install.

Carol


Can't see contribbed modules (solved)

TomSherlock - Wed, 2009-05-13 15:53

kham08, thank you for taking the time to figure out and record these steps.

I followed them to a T. While i have the site, i am unable to see contributed modules. I can see core modules only.

For step 7, i was unclear to me where i should place multisite.php, so i placed it in public_html.
I was also unclear whether i should write 'site1' or 'site1.yourdomain.com' for the symlink method, so i went with the former.

I find it confusing that i now have public_html/site and public_html/sites/site1.yourdomain.com

I have the contrib modules in public_html/sites/site1.yourdomain.com/modules

*****While copying the directory path, i noticed that i had created the subdirectory 'module' with no 's'. Once i renamed the subdirectory i was able to see the contribbed modules.

Thanks again, kham08.


clarify

carlthuringer - Wed, 2009-06-24 20:03

"1. In CPanel, set up the subdomain and point it to http://yourdomain.com "

What do you mean, 'and point it to'?

Using cPanel 11.24.4-RELEASE 33609

When I go to create a subdomain, I may enter a short text string, select from a combo box the domain I wish to attach it to, then click 'add'. It gives a short string of messages, then I can click 'go back' to see it added to the list.

dude.yourdomain.com (public_html/dude)

Now if you mean 'set up redirection' then that's a separate step which involves selecting dude.yourdomain.com from a lower combo box and clicking 'setup redirection'.

What do I enter here? 'http://yourdomain.com' is listed as an example. or do i use 'public_html/' or 'home/me/public_html'?


A much easier way!

mohamnag - Tue, 2009-02-24 12:58

Just enable cPanel X3 theme and you can set the destination of your new subdomain during creation.


uummmm....

kham08 - Tue, 2009-02-24 14:57

....setting the destination of the subdomain isn't the issue. Having a "site1" folder inside the sites/ directory won't work. It has to be named something that Drupal recognizes as a multisite, which is a completely different animal from the subdomain folder cPanel sets up.

You have to use a symlink to direct all requests for the subdomain to the common Drupal index.php, so that Drupal can process the request and send it through the settings.php of the appropriate site. The instructions above are the easiest way to do this and only take a few minutes to complete once you've done it a couple of times.

cPanel doesn't know or care that you have Drupal, even with x3 or whatever enabled.

Thanks, but I'd hate to see someone chasing their tail in cPanel for hours trying to find a way to save 3 minutes.


I have 4 sites running using

mohamnag - Tue, 2009-02-24 15:54

I have 4 sites running using this process:

  1. coping drupal to public_html
  2. creating 4 following folders in sites/ folder from drupal:
    fa.atie.ir
    en.atie.ir
    pmc.atie.ir
    wmpauker.atie.ir
  3. I have run install.php 4 times and each time used same database with different table prefixes. Each time I moved the settings.php from default folder in sites/ to each relating folder inside sites/
  4. I changed some table prefixes so that my users tables are common between all 4 sites
  5. Added 4 subdomains in cPanel all pointing to /public_html

and now every thing's working. you can see the domains listed above.


I have a working Drupal 6.10

HiFiGuy36 - Thu, 2009-02-26 04:11

I have a working Drupal 6.10 on a typical hosted server (just updated tonight, the current problem existed before this update from 6.9) in my /home/user/public_html/drupal/ directory. I also have set up multisite for 7 other sites on this codebase with separate databases and all are working. Of the 7, one is the main domain name, three are subdomains of that domain, three are add-on domains. One of the add-on domains used to be a subdomain of one of the other add-on domains, so I know I've been able to successfully add a multisite on a subdomain.
I went through the same process (I think) to add a new multisite on a subdomain that results in a redirect loop.
I created a subdomain through cpanel sub.domain.com
I created a directory /home/user/public_html/drupal/sites/sub.domain.com and renamed default.settings.php and copied it to this directory
I deleted the /home/user/public_html/sub directory that cpanel created via ftp client
I created a new database and database user for this site.
I created a symlink in public_html via ssh with "ln -s /home/user/public_html/drupal/ sub"
Now, when I go to http://sub.domain.com or http://sub.domain.com/install.php I get a "Redirect Loop" error.

I have read others suggest messing with .htaccess, which I have not done.
I can't figure out what step I missed.


You have made this step

mohamnag - Thu, 2009-03-05 12:30

You have made this step false:
"I created a directory /home/user/public_html/drupal/sites/sub.domain.com and renamed default.settings.php and copied it to this directory"
you should not rename and copy default.settings.php, you should install the site using Drupal installer and copy the resulting settings.php to that subdirectory.


Yes, that could have been the problem

beanworks's picture
beanworks - Thu, 2009-03-05 13:19

I wanted to make sure the db settings were not those of the original install, because I have a separate db set up for the subdomain site. It seems to be working fine now. But on the next one, I will try copying the settings.php from the default folder (instead of copying and renaming the default.settings.php file) and just change the db information in the settings.php file for the new site.

Thanks for the advice.

Carol