Hi everyone,

I love drupal and so I am going to use it for few more sites including migrating a postnuke and a wordpress one.

What I have now:

- A shared Unix hosting account with addons abilitiy.
- My main hosting account which I will call mymainaccount.tld has non-drupal subdomains in it.
- I added another domain name as an addon domain and installed drupal 6.13 in it. So my main/default drupal installation is not in my main hosting account. It is rather in an addon account and its drupal root folder is :

home/username/www/myaddonmaindrupal.tld/

- Now I want to install drupal for few more sites and I want to use multisites then.
- I have been reading posts and docs about multisites for 2 days and I am just confused now. I understand most directions assume the main drupal installation is in the main hosting account and hence when they talk about Parking domains for example, it makes sense but not in my case (where parking a new domain will only take it to the mymainaccount.tld which is not where my main drupal resides.

- I tried creating new Domain Addons for new domains in Cpanel and set the root folder for each as a sub dir in:

home/username/www/myAddonMainDrupal.tld/sites/

My first addon domain root folder is:

home/username/www/myAddonMainDrupal.tld/sites/addonsite1.tld

I created the settings.php file in the above folder and when I access the above site (addonsite1.tld) it gives me Error 403 Page (Forbidden).

I thought it is about setting symlinks so I tried creating symlinks using a php script but it failed. I am not sure whether it was becuse of some server restrictions or it was the way I wrote it.

After reading somewhere that using parked domains is better than addon domains for multisites, I stopped trying with the symlinks thing and started thinking about using parked domains instead. My problem with parking domains though is that as I said parked domain will only point to the mymainaccount.tld not to my myAddonMainDrupal.tld where my primary drupal resides.

Now, I need your help about the best way I can have drupal multisites if possible with my main drupal not in my main cpanel account. I like all my domains to look separate in all ways. Each has its own top domain name and own identity. I juts want to use multisites for conveninece maintanining. I also think of best practice reharding SEO and Google later on.

If it is better to install main drupal in my main hosting account (I prefer not if possible) then I would need to install it in a subfolder rather than the www folder (home/username/www/drupal) because otherwise my www forlder would be a mess and drupal codes would be mixed with other non-related subdomains.

I appreciate any help and any clear instructions and examples in case of anything to do with server and symlinks if needed as I am not familiar with more than using cpanel and ftp.

Thank you in advance

Comments

cestmoi’s picture

Okay, it seems no one is interested in helping me :(

I thought I could spare myself some more time in trial and error as I usually do with unfamiliar things but now it seems I have no other options!

Thank you anyways :)

davidhernandez’s picture

Hi,

I'll try to help you. You provided a lot of information, which is great, but maybe some people that might otherwise help were overwhelmed. I can't say I was immune.

"- I tried creating new Domain Addons for new domains in Cpanel and set the root folder for each as a sub dir in:"

This might be the problem. The sites folder in the drupal installation is only for drupal to use. It is where things like the settings.php file, which configures access to the db, is located. It is not where you point the document root for your site. The root for all sub-sites is the same, the root of the drupal install. Drupal will automatically locate the correct settings.php file to use in the sites folder.

If one were to have example.com with a drupal install in home/username/www/drupal and sub-sites site1.example.com and site2.example.com you would have the following:

home/username/www/drupal/sites/default
home/username/www/drupal/sites/site1.example.com
home/username/www/drupal/sites/site2.example.com

However, in the server configuration, the document root for all three would point to home/username/www/drupal

cestmoi’s picture

Hi David,

Thank you so much for your kind help after I had given up on any! Apologies for my overwhelming first post.

All I needed after reading your kind reply was to make the root directory for my addon second site the main drupal folder ( home/username/www/myfirstdrupalsite.tld ) and keep the previousely created subfolder for the second site in home/username/www/myfirstdrupalsite.tld/sites/secondsite.tld

I went to second site url http://secondsite.tld and drupal installation page showed up and so did my smile :)

I didnt do the installation anew though as I didnt want to do all settings again so I copied the DB of my first drupal install to a new DB for second site and copied the settings.php file from my my default install, changed DB info, base url, and cookie domain all to new site.

I accessed the second site again and I have a second drupal working. I logged in and changed the new site info to accordingly and voila ! all look great.

I didnt need to do any symlinks or anything else except what I already mentioned.

I was maybe confused by the mentioning of symlinks and favouring parked domains over addon domains in other posts on this site and so I went in diffrent direction of thinking but got only frustration and failure !!!

I will create a third drupal site and keep testing. I would appreciate any thoughts on the way I did it now and if there are any things I need to beware in my circumstances.

Thank you so much again for the help and my apologies for complicating my initial post.

davidhernandez’s picture

You don't need symbolic links unless you are doing sub-sites. example.com/site1, example.com/site2, etc.. I'm not sure what you read about favoring parked domains over add-on domains, but aren't they completely different things? In any case, if you are using a single drupal install, the key is to make sure all your sites have their roots point to the same drupal install root. The key here is that they all have to point to index.php, which is located in the root of the drupal install. The all use the same index.php file to run the site, as well as all the other drupal files. If your website can't locate index.php, it can't load the site.

The only thing you might want to think about is how you handle files for each website. If you are ok with keeping the files folder in the individual site folders, and don't care about the urls, you should be fine. Thus, http://secondsite.tld/sites/secondsite.tld/files is where they will be stored. I often don't like this, so I have to create a work around.

cestmoi’s picture

Hi David and thanks again for your responses :)

I added 2 more sites and all look fine so far.

The key here is that they all have to point to index.php, which is located in the root of the drupal install

Maybe too much reading of different approaches had made me miss the very simple fix that I happened to see clearly when reading your kind first reply to this post.

I have a different DB for each site with shared code base as well as themes and 3rd party modules because I wanted most of those modules for all of my sites. However, In case I wanted later to install a site sepcific theme or module, I created modules and themes folders in each addon site sites/secondsite.tld/modules and sites/secondsite.tld/themes

and I also created files folder for each sites/secondsite.tld/files and now I understand I would have that urls thing you mentioned, David. It wouldn't be a big deal as long as I only have same domain urls but it would be better to fix it. In such case, I am just thinking setting File System path in each individual site to sites/default/files/site1 & sites/default/files/site2 ..... so on. I would appreciate your sharing the work around you mentioned if different.

Re the parked domains vs addons, I had seen this post: http://drupal.org/node/320948

cestmoi’s picture

Re File System urls, I actually tried the default settings as well as the one I thought of and they both gave same urls. I set File System path to sites/default/files/secondsite for secondsite site and to sites/thirdsite.tld/files for the other thirdsite and they both worked the same in terms of urls as follow:

http://www.secondsite.tld/system/files/
http://www.thirdsite.tld/system/files/

I tested both and couldnt see any duplicate urls.

I dont see any problem either case but of course setting the File System as for the thirdsite example above is better.

Cheers

davidhernandez’s picture

If you have the urls /system/files/ that means you set your download method to "private." This means all file downloads will be handled by Drupal, and will result in a request being sent to drupal to retrieve a file. This adds overhead. If this is fine with you, then no problem. Your paths will then always be /system/files/. no matter where you actually store the files on the file system.

If you set the method to "public" you will see your file paths turn to http://www.secondsite.tld/sites/default/files/secondsite/ or however you set it up at the time.

cestmoi’s picture

Thanks David, yes I actually had set File System to private and I could see the urls like you said when I changed it to public. Still interested in your work around if you dont mind sharing :)

Cheers

davidhernandez’s picture

If I only want public download method, I do things in a number of different ways. Here are some examples. This is all using Apache on Linux. My motives for needing to change the urls vary, and often have to do with factors outside of drupal.

Assuming the following sites:

example.com
site1.example.com
example.com/site2
example.com/site3

If a files directory is put in each site folder the urls look like this:

http://www.example.com/sites/default/files
http://site1.example.com/sites/site1.example.com/files
http://www.example.com/site2/sites/example.com.site2/files
http://www.example.com/site3/sites/example.com.site3/files

To make site2 and site3 work, since they are sub-sites (sub-folders,) symbolic links need to be added for each in the root of the drupal install folder. /var/www/html/drupal/site2 and /var/www/html/drupal/site3. Site1 would ave its own virtual host config on the server.

If a folder is put in the root of the drupal folder, you get urls like this:

http://www.example.com/files
http://site1.example.com/files/site1
http://www.example.com/site2/files/site2
http://www.example.com/site3/files/site3

Some people do this, but I don't think its all that much better. Plus, you have to keep all the files together, even though they are for separate sites. It could be manageable, but example.com will have access to the other sites' files, unless you create its own folder, like
http://www.example.com/files/default.

One thing I've done for this is create actual folders in the drupal root, site1, site2, site3, put a real files folder inside each, and then make symbolic links to the necessary parts of the drupal root. includes, modules, index.php, misc, etc.

That gives me this:

http://www.example.com/files
http://site1.example.com/files
http://www.example.com/site2/files
http://www.example.com/site3/files

This is more work to manage, so I probably wouldn't do it if I had a lot of sites to manage. Since I have direct access to my web servers, I do the following. I leave file folders in the normal location (sites/example.com/default/files, etc) but I put aliases in my Apache config, so I don't need to sym links

Example, for site1:

Alias /site1 "/var/www/html/drupal"
Alias /site1/files "var/www/html/drupal/sites/site1.ias.edu/files

This does everything without sym links, so I can do upgrades, disaster recovery, etc., without having to worry about folders or links inside the drupal install. The only problem I have encountered with this is that you still have to configure the files directory in each site to be the actual server folder (sites/site1.ias.edu/files) which means any module that creates links to files will automatically create the longer urls (http://site1.example.com/sites/site1.example.com/files) This is particularly noticeable with a WYSIWYG editor, and using a file manager like IMCE. I can solve this by using FckEditor and its built-in file manager. The FckEditor settings allow you to tell it what url to use as the file path, so I configure it to insert /files/[filepath] which results in http://site1.example.com/files/[filepath]. This is nice, but I like IMCE's file manager better. That's why I'm working on getting CKFinder, FckEditor's better file manager to work in drupal. Either that, or I might make a custom module to always manipulate the file paths.

One problem with aliases is that you have to do them in a server level config file, so they won't work in .htaccess. Not a problem for me, but its a problem for people using shared hosting services.

I've implement other solutions, but I think they are all based on one of these, or I can't remember them. I've done it a dozen different ways, so I can't always remember.

...as you've noticed setting the download method to private eliminates most of these problems. Its just not an option when I really need direct access to the files, pretty urls, can't afford the overhead, need backward compatibility with some existing paths, or have some interaction with another application that can't be solved any other way.

Hope that helps, and if someone knows a better way, please let me know.

cestmoi’s picture

Thanks for your great kind help David. I will probably keep File System set to private but i am sure many others would find your tips useful. Thank you so much again :)