High on my list of priorities as we move towards our first real Drupal site was understanding how to setup multiple Drupal sites using the same core files. A lot of users have written on this subject and in the last couple of days I've read most of them. The alarming thing is that no two seem to be the same. The sad news is that I want to add to that growing list of multisite setups instructions.
The reason most of the posts proved unhelpful is that they assume you are creating different sites under different domains. For example, www.examplesite1.com and www.examplesite2.com will point to the same ip. But that wasn't what we were after. All our sites are under one domain. So we will create www.ourdomain.com/examplesite1/ and www.ourdomain.com/examplesite2/. The following instructions assume that you have already created a new alias in your Apache configuration file that points to your Drupal install.
In your Drupal 5 folder you will find a sites folder containing two folders ; "all" and "default". The "all" folder is for shared modules and themes that aren't part of the core but will be used with all your sites. The "default" folder contains a settings.php. If no other sites are found, based on your url, then the default folder is used. To create new sites using the same core you create new folders with their own settings.php file within the sites folder. The first important thing you need to know is that the folder name of your new sites need to reflect the address of the site with "." replacing "/" in the folder name. For example, if your site's url is http://localhost/test1/ then Drupal will look for a folder named localhost.test1. There are a few possible variations on this and they are described in settings.php. But what proved crucial for us was that you need to uncomment and change the $base_url variable to hold your full url without the trailing slash. Ours looked like this :
$base_url = 'http://localhost/test1';
This variable is optional in settings.php and for the senario of multiple domains for a single ip then it's probably doesn't need changing. But if you've done everything else and keep seeing the default site then you probably need to change this setting. We definitely did. Now to create a new site at this url you need to create a new empty database and assign priviledges. Add this information to settings.php as shown in the examples provided (in settings.php). Then navigate to install.php at the new sites url (e.g http://localhost/test1/install.php) and follow the usual install procedure. The result should be a shiny new Drupal website.
Subscribe to:
Post Comments (Atom)
28 comments:
I'm tearing my hair out trying to get this to work. I can access the default Drupal site via localhost/drupal, but when I add a directory called localhost.drupal.test to the sites folder and put a settings.php file in it, I 'Page not found' when accessing localhost/drupal/tch... any ideas?
Hi Peter,
assuming you've created an alias called test (in your Apache config file) that points to your drupal site (not the test site within Drupal) then the url of the test site will be http://localhost/test/ and the site folder should be called localhost.test. Hopefully this helps.
Though it isn't in the scope of the article, it's related: can you outline how you actually create an alias in Apache?
Hi Alistair,
sure I'll give it a go. The following assumes you have access to the httpd.conf (If you don't then you need to add/modify the .htaccess file; I won't pretend to explain the details of this process as I've never needed to do this). Within httpd.conf find where your directories are defined. Creating and alias is quite simple it looks something like this:
Alias /image /ftp/pub/image
When this Alias is added and the Apache server re-started you can now access the folder at http://www.examplesite.com/ftp/pub/image/ from http://www.examplesite.com/image/. Hope this helps. More details can be found in the Apache manual (http://httpd.apache.org/) under mod_alias.
finally I got the multisite working. thanks for your advice - I really don't know what I am doing. One thing, I had to put the full position for the alias in apache - "c:\etc\localhost\etc" to my drupal installation.
Glad to hear you got there in the end.
Shees... I think I'm having the same problem as Peter.
I have drupal installed here: C:\Program Files\xampp\htdocs\drupal\
(not in Root as I have other installs also running).
I have a New site called idealab running here:
C:\Program Files\xampp\htdocs\drupal\sites\idealab
What do I need to change where? Stumped!
unodewaal you are focussed on the local file path. But what you need to think about is the url of your Drupal site. That url needs to be defined in the sites setting file, and an alias needs to be created in the server configuration file and the folder name in the drupal sites folder needs to reflect that path as well (idealab is the correct name if the url is www.idealab.com). But the actual file location only effects the alias definition. Hope that helps a little.
hi geekglue,
when i using multisite functionality of drupal i am getting Page not found error. i have updated everything as u r saying.
To anonymous,
it's hard to say where you are going wrong. I'd need some more detail to try and diagnose the issue.
now there is a module to help this out:
http://drupal.org/project/multisite_manager
Trying to get this to work on a windows xp with xampp (apache 2.2) installed.
After added the Alias to httpd.conf the installation went through with me second site.
I am though having problem after the installation, when accessing localhost/test1 everything is working fine... BUT when accessing localhost/test1/admin for example, I am directed to the default directory of my drupal installation.
Anyone who has an suggestion on how to avoid this behaviour ?
I need some help getting this to work.
The instructions talks about creating a new database and running the install.php file. To restate what is says: "Now to create a new site at this url you need to create a new empty database and assign priviledges. Add this information to settings.php as shown in the examples provided (in settings.php). Then navigate to install.php at the new sites url (e.g http://localhost/test1/install.php) and follow the usual install procedure."
I haven't got this to work...but it seems to be that you are actually doing a multiple installs of DRUPAL, NO?!
So if you have 500 sites, you want to do this 500 times? That's crazy.
Please some tell me I am wrong.
Thanks
Angelou.
Our situation doesn't involve setting up hundreds of sites at a time. They are setup on a job by job basis (about 1.5 a month) so the process you quote isn't a real burden. I imagine if you needed to setup 500 sites at one time you'd do well to write a script to handle this process. I'm unaware of any existing scripts to handle an industrial scale install.
Hi Geek Glue,
Following your instructions to get multisite up, i am still not getting the hang of it... I am new to Drupal so please bear with me when I won't be able to fully explain everything here.
I am using win server 2008 with IIS 7, I followed your instructions carefully and still didn't get the site up.
Let's say my main site's domain is: http://stage.example.com.. and i want to create a sub domain "stage2". I created a new folder inside ../sites and named it stage.example.com.stage2, already created an empty DB to call from settings.php. When i run install.php from http://stage.example.com/stage2/install.php, i get a 404 error...
Please tell me if i missed something here? I would really appreciate if you could me out on this..
Thank you.
Hi Anonymous IIS user,
on our Apache server we alter the config file and add an alias that points to the Drupal folder using the sub sites name (in your example stage2). Not being familiar with IIS I'm not sure how you achieve the same outcome (sure there will be lots of examples for this online). Without this alias the server doesn't know where to look for the site (hence 404). Hope that helps.
Thanks Geek Glue.
I think i may need to check this inside applicationhost.config but i don't have permission to modify it.
I will try to sort this out and get back to you again.
Thanks for the help, appreciate it. :)
Hi, I've a little problem with it.
I've been able to create two sites in drupal and access form the same machine with localhost/site1 and localhost/site2, following the steps you explain... However, if I try to access from other PC in the same lan with its IP/site1 or IP/site2, I always get the default Drupal's site.
Have you got any ideas?
Thank you so much.
Hi Sergio,
I assume from what you've written that in your sites folder there is a folder called localhost.site1 but it should be called IPaddress.site1 (ie 152.122.25.7.site1) to access it external to that machine. Hope that helps.
Ok, thank you for the answer.
Then, I suppose that if i like to test it in my LAN, i have to create a lanIP.siteX directoy and, move it to InternetIP.siteX to see the sites over Internet.
Do you know if there are other ways?
Thank you again
I vaguely remember reading something about re-write rules when a site has multiple domains. This could be relevant to what you are after. Otherwise I'm not aware of any other options.
Ok, thank you.
Now, I have a clue to search ...
This is really tough to get going. Another great tutorial is here: http://topcweb.com/content/drupal-multisite-installation. Once you get it going, a multisite installation is very powerful for web developers.
This is really tough to get going. Another great tutorial is here: http://topcweb.com/content/drupal-multisite-installation. Once you get it going, a multisite installation is very powerful for web developers.
Interesting topic, though I've always felt Drupal is a CMS that's lacking when compared to other CMSs, in terms of flexibility and usability. Interesting post though.
"I've always felt Drupal is a CMS that's lacking when compared to other CMSs, in terms of flexibility and usability."
Drupal has it's limitations but flexibility isn't one of them. We've been using Drupal for a few years now in an environment that constantly throws up new and challenging requirements. In that time we haven't had a request that couldn't be handled by Drupal. There remain a few usability hurdles but it is improving. Having said that we have users with very limited experience in web publishing who have no trouble using it. The usability hurdles mostly lie on the development side.
Would be curious to hear which CMS's you think are better : assuming to come from an independent perspective (ie you aren't from the sales department of an expensive and closed alternative).
Hi
I have a similar yet different problem. Can you help me? My webhost has this configuration: Windows server 2003, IIS7, php 5.2.5 and MySQL.
My drupal 7.14 install in under the folder dessites, in my root. I have the subdomain http://dessites.des-us.com going to this folder, and that is all working.
Now, I want to install my website as a subsite under sites/des-us.com.erp, so that the url http://www.des-us.com should access this subsite. The .htaccess file has to be deleted to access the website. So I cannot do the ReWrite there. But I do have the httpd.ini file, where all my subdomains etc are configured.
Can you please explain to me how to install my domain as a subsite of my drupal install?
thank you.
Dzigner : not that experienced with your exact configuration. Suggest you take a look on the "Installing Drupal" forum : http://drupal.org/forum/1. If you don't find your answer post a question. I'd be surprised if you didn't find exactly what you are after there.
Post a Comment