Hi all,
Using Drupal 5.1
I have read almost all multi site topics in this forum. I tried for hours to set up my multisite and finally did it. As i think many others can have the same problem i'll post here the way I did it. Hope someone can get the work done with this:
1) After installing drupal you create an admin account in the default site. I installed it in C:\www\drupal. This default site is configured to be accessed from http:\\localhost.
2) Then the important part begins. Create folders for your sites in C:\www\drupal\sites. I'll suppose you want two create two sites using the same database. Lest call them site1 and site 2, and you want to access them form http:\\site1 and http\\site2.
Create the folders as site1 and site2 and copy the settings.php file in it. You will have to change them to contain:
#For site1 settings
$db_url = 'mysql://root:uchile@localhost/drupal';
$db_prefix = 'site1_';
#For site2 settings
$db_url = 'mysql://root:uchile@localhost/drupal';
$db_prefix = 'site2_';
in this case we are sharing in this sites the same default database that i called drupal (you use your main database name here or use different databases if you don't want to share your data between sites).
Then, to let apache listen to calls for this specific sites you must have a httpd.conf file with this settings:
#I'm using this port so everything will be related to this port.
Listen 80
...#this means other lines
ServerName http://127.0.0.1:80
....
DocumentRoot "C:/www/drupal" #Don't forget to change this in a few lines down<Directory "C:/www/drupal">
....
#the following code I have it in the httpd-vhosts.conf file but I think you can paste it
#in this file in the bottom.
#If you are using a different file you should have just this code plus two gropus
#starting on <VirtualHost *:80> to handle requests that
#do not match a ServerName or ServerAlias in any <VirtualHost> block.
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot "C:/www/drupal"
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName site1
DocumentRoot "C:/www/drupal"
<Directory />
Options All
AllowOverride All
# Simply allow all directives to be overridden in .htaccess
Order allow,deny
Allow from localhost
# Only allow access from localhost
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName site2
DocumentRoot "C:/www/drupal"
<Directory />
Options All
AllowOverride All
# Simply allow all directives to be overridden in .htaccess
Order allow,deny
Allow from localhost
# Only allow access from localhost
</Directory>
</VirtualHost>
3)Once you have done this and your apache server starts correctly with this settings, you must do a very important part that has been my worst nightmare...
In C:\WINDOWS\system32\drivers\etc, find the file 'hosts'. If you can't see it (maybe you can see some similar files), you must enable hidden and system files view in that folder. Do this by entering the tools menu and in the view tab find and select 'Show hidden file and folders' and unmark 'Hide protected operating system files (Recommended)'. Then you will be able to see the file. Open and you should have:
127.0.0.1 localhost
127.0.0.1 site1
127.0.0.1 site2
This file is read-only so save with another name and rename or unprotect it before writting.
4) Now enjoy your new drupal installations by entering http:\\site1\install.php and http:\\site2\install.php. This finishes the work.
Well, good luck all and hope you can do it faster than i did.
If I made any mistake or omission, please let me know because maybe I forgot to write some step. Or maybe this worked just for me...
Edited by WorldFallz - added <code> tags and some white space.
Comments
Correction
Settings should be:
Create the folders as site1 and site2 and copy the settings.php file in it. You will have to change them to contain:
#For site1 settings
$db_url = 'mysql://root:uchile@localhost/drupal';
$db_prefix = '';
#For site2 settings
$db_url = 'mysql://root:uchile@localhost/drupal';
$db_prefix = '';
I don't know about prefix and it works this way.
Remember that this installation is to have different sites pointing to the same database, sharing the data. This may be usefull to test different versions of your sites without messing up your main site.
Great tutorial for windows
Great tutorial for windows users!
If you don't want to use the same database tables for all the sites (ie sharing data between them all), then you'll want to add a db_prefix. For instance, if site2 is to have a totally separate setup to the others, then you could have
There's also other stuff you can do with prefixes, if you look in the comments
using the above, you could share the user settings, but have different module setups - great for testing whether module1 works with module2 etc
Oh, and shouldn't you mention that the settings.php files for site1 and site2 need to go in the sites directory?
cheers
Re:Great tutorial for windows
Regarding suffixes, you are right, but I tried that and the tables for each site were created in the same database. I' don't know what went wrong in my case. For more information about multi-site with multi-database installation I would recommend looking in another topic so you can confirm this.
And you are right about settings.php. I forgot that part. Thanks for the comment...Hope this continue helping others.
db prefixes
i guess my problem is that i'm not sure what the prefix is pointing to: tables in the same database or an entirely different database? maybe if i say what i'm attempting:
i have 2 sites for now that i need to make. i'd like to use the same drupal codebase but completely different everything else, and a different forum and database for each (1 tech site and 1 fun site= very different members). Each site will probably eventually branch off into subdomains as i think of more stuff, so i'd like to get those set up too, which is why i'm thinking well in advance about proper naming conventions and organization here.
any help is appreciated.
soon as if figure this out i'll write my own setup tutorial for multisite using MAMP. :) im so close, just need little direction.
how are you accessing your
how are you accessing your sites? site1.com/ site2.com or localhost/site1 and localhost/site2 ?
Sometimes something interesting appears on http://litwol.com
doing everything locally for
doing everything locally for now.
heres the story: before drupal i initially set up my site in the MAMP htdocs folder. the address to that is
http://localhost:8888/rpsite.com/ (MAMPs default apache port is 8888)
then i discovered Drupal, tried setting up some virtual hosts, so the address to the default drupal site now is
http://localhost:8888/Drupal/
The V Hosts i added (rpsite rpsite2) point to the same thing, which is why i'm trying to nail down/understand the database protocols, including subdomains (for instance, if i try to do something like forum.rpsite.com or rpsite.com/forum or pricesearch.rpsite.com)
http://rpsite:8888/
http://rpsite2:8888/
still trying to figure out some kind of real direction for this site. all ideas, no supreme plans. seeing what i can do with drupal...basically the more i learn the more fun this gets.
1) to create your two
1) to create your two completely separate websites you need the following folder structure
/
.../sites
......./rpsite (since you didnt put .com in your example)
.........../modules
.........../themes
......./rpsite2 (since you didnt put .com in your example)
.........../modules
.........../themes
2) you need to configure those two new sites
a) to do that you need to go into the folder /sites/default and copy file names settings.php into both of the folders /sites/rpsite and /sites/rpsite2
b) change file access permissions on those 2 files (both settings.php in both folders) to read and write.
c) open each settings.php file and look for a line that begins like this " $db_url = ", in that line you need to replace what ever it has with $db_url = 'mysql://username:password@localhost/databasename'; and $db_prefix = '';
what (c) will do is allow you to access the regular install page where you can entere all the DB details and table refix details.
d) go into your http://rpsite/install.php and http://rpsite2/install.php run the regular instalation
from that point everything is the same as with single site setup. if you have any further problems just write them here and i will reply as soon as i can :)
Sometimes something interesting appears on http://litwol.com
i give up
Thanks for the suggestion litwol. Nothing however.
So yeah, been at this for about a week now trying various things, reading everything i can on this forum and on the MAMP site about multi-site configurations for a local server...
Hey, the default install works just fine. But I have lots of site ideas, and so I wanted to quickly set up multiple databases/sites: it seems so easy:
you just have to
1. make a new database in phpMyAdmin called 'rpsite'. (or copy the current drupal database to a new one called 'rpsite')
2. duplicate the sites/default folder, change its name to 'rpsite.com'
3. in the newly copied site, change the following in "settings.php":
$db_url = 'mysql://username:password@localhost/databasename';to whatever your database is, like:
$db_url = 'mysql://root:mypassword@localhost:8889/rpsite';(8888 is apache, 8889 is mysql, i tried both.)
And once that's done, you should be able to type in
http://rpsite.com:8888/install.php
and then get the database dialogue, first user, etc... because drupal is set to search for settings.php in a /sites folder OTHER than /default, i.e. right to left.... and it will read my database and connect it to install.php in drupal's main folder.
But it doesn't work for me.... i'm probably just going to copy the entire drupal folder as many times as i need sites and just rename them and create databases accordingly. this'll probably work out better for multiple domain names anyways as soon as i get something i like going on my local machine. Any thoughts on that?
Still....I kinda would like to get the multisite configuration working (it's not really multi-site is it, in terms of full distinct domain names, more of subdomains, am i right?) I'm still having trouble understanding the concept.
Why would i need subdomains... i dont know. maybe to do separate databases or separate tables if rpsite has both a blog and a forum. But even that I don't know if that's what people normally do. kind of feel like i'm setting up a dinner table for 1000 people whom i don't know, and without knowing how to cook.
Hi matey Hopefully I can
Hi matey
Hopefully I can help a bit (I've done this on windows and linux) - Oh, and I'm writing this from an easy perspective (in case anyone else needs help!)
First off, I'd not use names that resemble proper domain names (you'll see why later!)
It looks to me like you're doing everything right, there's just an important step you've missed out.
You need to locate a file called hosts. It should be here on osx or linux
/etc/hostsAdd this to your hosts file: (names used as example, YMMV)
This does the magic of pointing a http://rpsite1 to localhost (this is why we don't want to use real domain names as you're basically overriding the internet. If you were to use a real domain, then you would never see the internet version, only your localhost version....not good for sanity!)
Now, I'm not sure how apache is setup on osx - I'm using Ubuntu on the desktop and FC6 on a server and they both differ with regards to virtual servers!
Right then (after a bit of searching!), you need to edit the file
/etc/httpd/httpd.confFind the section titled "### Section 3: Virtual Hosts".
There may be a line that looks like
#NameVirtualHost *- this needs changing toNameVirtualHost 127.0.0.1Then underneath this you'll want to add lines like this:
The DocumentRoot is where Apache will look for your files, the ServerName is whatever you're using in the hosts file. If you want to add more test sites, then you'll need to remember to update the hosts file and the httpd.conf file
Whenever you make changes to httpd.conf you need to restart Apache, taken from another site "In MacOS X, the easiest way to do this is in the Sharing panel in System Preferences. Turn Web Sharing off, then turn it on again."
(On some linux it would be something like
sudo /etc/init.d/httpd restart, or in Ubuntu/Debiansudo /etc/init.d/apache2 restartNow, if you point your browser to rpsite1 or rpsite2 you should get whatever documents are in the respective directories.
Now, the many-sites-from-one-codebase thing!::
If you set both DocumentRoots of the sites to point to the same directory, you should be able to get drupal to serve different settings. sometimes you may need to put a symbolic link in the DocumentRoot that points back to the DocumentRoot, in which case:
So we could do
In drupal's sites directory, you should have a 'default' directory and you might have an 'all' directory.
Make a new directory called whatever your site is, so you could have rpsite1 or rpsite2 or whatever. Now if you want a sub-site setting up, you'd make a dir called subsite.mainsite or if you wanted to have different settings for a sub-directory eg rpsite1 has one set of settings, but rpsite1/staff has some different settings, then you'd make a directory called rpsite1.staff
(I haven't tried this with drupal5 but I've got it working on drupal47 so it should still be the same, as an example http://www.personalcapabilities.co.uk and http://www.personalcapabilities.co.uk/smartscience are on drupal47, on the same codebase, but the second site uses a different set of modules, and a different theme), anyway back to the show!
Now you need to copy a settings.php into your newly created directories and set the settings.
(Before we start editting any settings, I'd double check that mysql is listening on the port you specify as it should default to 3306, and apache defaults to port 80).
See if you've got a file called
/etc/mysql/my.cnfTowards the top of this file is a section title '[client]'. Make sure the port is what you think it is (or it will be 3306). Also make sure under the '[mysqld]' the port is the same - should be 3306For Apache, have a look in the httpd.conf for a setting called 'Listen'. This will tell you which port apache is setup to listen on - the default is 80.
Back to drupal (just read something else you need to check!)
If apache is running on a port other than 80, you need to rename the dirs we just created in the sites to this format
I'm using the port number you said before, so
Use your settings from before, but if mysql is running on its' normal port, you don't need to tell drupal.
Using the above method, you could have a multi-site from one codebase setup, it's all a matter of making sure every site shares the same documentRoot, and that the relevant dirs and settings.php files are in the sites directory.
The additional power here, is that you could share some database tables across installations, have a default set of modules and themes, but then allow other sites to have a different setup (alternate modules +/ themes), or just different databases. (I'm going to try setting this up sometime later to see how it all works - should save some valuable space on the server!)
The general consensus is that the dirs under the site directory should hold the site-specific stuff, so you'd have directories for modules, themes, and files)
Hopefully some of this may help; give me a shout if you need more! (I've done the multi-site setup thing quite a few times on different servers)
Cheers
I think i may just
have done it properly. I'm going to be late to work this morning because i was obsessively messing with it, but yeah, thanks again. Just a few additional tweaks here and there aside from what you wrote, but i'll tell you in detail later tonight. have to test it a little bit more.
I think i may just
have done it properly. I'm going to be late to work this morning because i was obsessively messing with it, but yeah, thanks again. Just a few additional tweaks here and there aside from what you wrote, but i'll tell you in detail later tonight. have to test it a little bit more.
think i might
have done it properly. I'm going to be late to work this morning because i was obsessively messing with it, but yeah, thanks again. Just a few additional tweaks here and there aside from what you wrote, but i'll tell you in detail later tonight. have to test it a little bit more.
a quick(?) question...
i am trying to work through setting up a multisite install with MAMP. I was hoping you could clarify something for me.
I am not sure what you are referring to by the 'hosts' file. The httpd.conf file for MAMP is located at conf/apache/httpd.conf and i can follow the necessary mod's for that*. I can't locate a 'hosts' file at all.
An extension of this, why are you using 127.0.0.1 for NameVirtualHost (please excuse my apparent ignorance on this. Is to follow the above example??). MAMPs default is http://localhost:8888/. To point to a drupal install this would be http://localhost:8888/drupal-x.x ???
So if you had (to use the above example) http://rpsite1 would this point to http://localhost:8888/rpsite1 or http://localhost:8888/drupal-x.x/rpsite1 [i am trying to get my head around this for when i start with multisites remotely --> which seem easier)
I hope i have been clear (is getting late after too many hours looking at code)
thx
c.
* i have made no mod's as yet - i want to ensure i can follow every step first
avolve designs | ethical by design
Hi, Can you do all this when
Hi,
Can you do all this when you site is hosted by a hosting company?
Will they let you fool around whith those files?
Michaël
You can do some of it, but
You can do some of it, but as the subject says "Localhost multisite..." - so this is basically for setting up a dev environment locally.
If your host allows subdomains (some do, some don't) on your domain then you can get the multisite stuff working.
What is it you're wanting to do??
I have decelopped several
I have decelopped several drupal web projects and one of them , now is requering multisite (only for 2) that is for a sort of bilingual (latin women and french speaking men). It is a dating site. But as the content itself changes apart from the language, as this is due to the sex of the user, the multilingual module would not help.
So I thought I would take a shot at it with the multisite.
My host company provides subdomains.´
My problems are:
I cannot acces the httpd.conf file, but I can create a local htaccess file.
I can start the web service, but I am not sure this would reset the whole web server as this is shared hosting.
Michaël
Wow this is the absolutely
Wow this is the absolutely best multi site tutorial i've ever seen, i have been waiting for this! great many thanks to you.
i have now learned not only how to easily setup multisites on localhost but also in general what it means to have multiple sites run off the same codebase!
thank you
Edit: can we move this tutorial into handbook page? this information is by far more important than just let it get lost within the thousands of forum topics.
thank you.
Sometimes something interesting appears on http://litwol.com
Re: Wow this is the absolutely
You can use this information freely.
Remember to include the corrections and comments made in the replys.
what about Automatic generation of username.example.com
This forum topic is great!
It's a pity that there is no handbook section which would explain various sides of subdomain set-up in simple step-by-step manner.
But what about Automatic and (endless) creation of subdomains based on user's username and OG's groupname??? ... like this
username.example.com (where users will have their Blog and Profile and their own pages)
groupname.example.com (where OGs will ave their own forums, calendars, memberlists etc)
(just like in username.wordpress.com or username.livejournal.com)
I've noticed that Olav from tribe.de and drupalsite.org has set this up perfectly, but I cannot find any info as to how. Contacted him -- no reply.
Can anyone help??? I've been cracking my skull against this problem for more than a month -- I'm in tears and total despair :(
My website cannot go live without this essential feature.
So far I'm working from my localhost and I need to get this thing right on my localhost first.
Please please help...
Multiple sites- same Db -2 domain names
I have my Drupal work on a shared webhost.
My Settings.php at the moment with one Domain Name is:
$db_url = 'mysql://user name:PW@mysql.HOST .com/database name';
$db_prefix = '';
To set up for two Domains, instead of : $db_prefix = 'site1_';
do I have to insert?:
$db_url = 'mysql://user name:PW@mysql.HOST .com/database name';
$db_prefix = 'www.Domain Name1.com';
$db_url = 'mysql://user name:PW@mysql.HOST .com/database name';
$db_prefix = 'www.Domain Name2.com';
Sorry my understanding of php is very very limited. If is wrong can you suggest right way. Multi thanks
Are you wanting to do 2
Are you wanting to do 2 sites from 1 database?
If you can't get another database then, yes, in the relevant settings.php you would have a different prefix:
So, in the sites directory you'd have a directory called domainname1.com and another directory called domainname2.com.
There should be a settings.php file in both directories.
Now, the $db_prefix needs to be just a prefix, not what you have done, for example
in the settings.php in the domainname1.com directory
$db_prefix = 'd1_';
and in domainname2.com
$db_prefix = 'd2_';
Because the prefix is used for the table names in the database, you want it to be short yet descriptive. It might be fine to use long names if you know you'll never have to use phpMyAdmin to troubleshoot or admin the database (or the shell for that matter), but otherwise I would opt for shorter names....
which looks more manageable?
d1_node or domainname1_node
Hope this helps, let us know if you need further help
Do not forget to restart the browser...
Also one should not forget to restart the browser after any change on C:\WINDOWS\system32\drivers\etc\hosts file.
Fantastic! Thank you very
Fantastic!
Thank you very much for this localhost multisite description :P
Just what I have been looking for
My Drupal sites:
Holy Shit
You are so generous for writing this and letting us in on your process. It will save me so many headaches (and hopefully resolve the one I have now from banging my head on this yesterday. It makes such a difference when people post things that they have been able to figure out.
awillem
--
anawillem
http://jellobrain.com
Please compare with handbook.
Over here are the multisite handbook pages people don't seem to be able to find.
If there's anything in this thread that could be added to that page, please have a look, I'm sure there are some differences, but the handbook one is also pretty clear and correct. It goes for separate database, not prefixes. I like prefixes for quick demo throw-aways, but not for any site I'm ever going to take live.
WAMPP/MAMPP uses a slightly different place to put its configs by the sound of things.
Messing around with port numbers may deserve a sub-handbook page of its own...
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks
This helped me a lot.
multi sites on localhost
Forgive my inexperience but I cannot get to grips with all this multi site business.
I can downlaod drupal and wamp and put in all the boxes the necessary names, like localhost; must it be called localhost, can it be drupalhost?
Ive copied the settings file over, God knows what I did, anyway Drupal is there running BUT I cant for my life fathom out all this multi site, multi database, stuff; I have php files in my mind, windows hosts files, and so on. Lets go thru your comments step by step and tell you where I fall astray or do not understand what you are saying, first lets divide the actual drupal login and admin work from the work on files and folders; hetre you go:
1) After installing drupal you create an admin account in the default site.
We all know this I cant see what you are inferring here, and the description default site; it is either a drupal site or nothing?
I installed it in C:\www\drupal. This default site is configured to be accessed from http:\\localhost.
I managed to get my www directory below wamp; i have wamp,alias,apps,bin,lang,logs,scripts,tmp,www.
in my www is includes,misc,modules,profiles,scripts,sites,themes, and sites has all,default, and all has files, modules, and modules has g2, gallery, sorry to be such a dummy and spell all this detail out, but am wondering how you got your drupal site in C:\www\drupal?
Yes, I also get drupal going from http://localhost.
2) Then the important part begins. Create folders for your sites in C:\www\drupal\sites.
For me there is no www.drupal directory, I cant fathom out why I didnt get one, as I say, imy www directory is below wamp, so what would I do in this situation?
I'll suppose you want two create two sites using the same database. Lest call them site1 and site 2, and you want to access them form http:\\site1 and http\\site2.
I am sort of stuck here, and I think going on with comments would be superfluous, sorry but my brain is stopped, can you help here, gra.