I'm using WinXP with XAMPP 1.6.3 (Apache 2.2.4 mod_rewrite enabled, PHP 5.2.3). I'm able to create symlinks by using Junction. I've installed Drupal 5.2 in C:\Program Files\xampp\htdocs\drupal52 and can access it via http://localhost/druapl52.
I am now trying to create two websites (localhost/site1 and localhost/site2) that run on the same codebase as my localhost/drupal52. So far, I have:
- created C:\Program Files\xampp\htdocs\site1 and C:\Program Files\xampp\htdocs\site2 directories
- created a settings.php file for each of the two sites in drupal in C:\Program Files\xampp\htdocs\drupal52\sites\localhost.test1 and C:\Program Files\xampp\htdocs\drupal52\sites\localhost.test2
- created a database for both sites
- editted C:\Program Files\xampp\apache\conf\extra\httpd-vhosts.conf:
NameVirtualHost *:80 <VirtualHost site1.localhost> DocumentRoot "C:/Program Files/xampp/htdocs/drupal52/" ServerName test1.localhost </VirtualHost> <VirtualHost site2.localhost> DocumentRoot "C:/Program Files/xampp/htdocs/drupal52/" ServerName test2.localhost </VirtualHost> - editted C:\WINDOWS\system32\drivers\etc\hosts:
127.0.0.1 localhost 127.0.0.1 site1.localhost 127.0.0.1 site2.localhost
If I now browse to http://localhost/drupal52, I get the website as expected. If I, however, browse to http://localhost/site1, I get a default apache site index:
Index of /site1
Name Last modified Size Description[DIR]
----------------------------------------------
Parent Directory -
----------------------------------------------
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.3 mod_perl/2.0.3 Perl/v5.8.8 Server at localhost Port 80
Obviously, the same happens when browsing to localhost/site2.
My questions are:
- What Am I doing wrong?
- What do I yet have to do to make this work?
I have reviewed several topics on this (i.e. LOCALHOST MULTI SITE INFERNO: Finally did it!, Using the same Drupal code base for multiple sites, Running multiple sites on a local PC (localhost) from a single codebase, using Windows and Multisite with drupal for dummies) but am not able to find the answers I need - some really confuse me as I do exactly what they say, but it doesn't work on my computer. Perhaps you can help me out? Any help would be greatly appreciated :-)
Comments
You mention junction, but
You mention junction, but not that you’ve used it for anything. You have mentioned two directories – C:\Program Files\xampp\htdocs\site1 and C:\Program Files\xampp\htdocs\site2 – I think both of these need to be links to C:\Program Files\xampp\htdocs\. See Multiple Drupal Sites under Windows
Creating symlinks doesn't make any difference
You're right that I mentioned being able to create symlinks, but that I haven't used it for anything, since I wasn't sure what symlink to create. Following your suggestion (junction C:\Program Files\xampp\htdocs\site1 C:\Program Files\xampp\htdocs\) doesn't make any difference - I still get the directory listing when browsing to localhost/site1... :-( Anybody...?
.exe
Doesn’t seem like you have created the symlinks:-
junction.exe C:\Program Files\xampp\htdocs\site1 C:\Program Files\xampp\htdocs\?Did you get an error message?
Have you tried deleting the directories first?
Have you tried migrating to LinuxAMP? ;-)
No message at all
When I type the junction command, I don't get any form of message telling me the symlink has been created or not. Look at the command line below:
If I first delete the directory C:\Program Files\xampp\htdocs\site1 and run the junction command, I get the exact same output as above: no error, but no confirmation either...weird?
The webserver I'm renting is LAMP-based, my own little PC / Mediacenter / Devbox is not :-)
Space – the final frontier.
The response of junction.exe indicates that it doesn’t understand the command, so it prints out some help for you.
The two arguments it expects are a directory and a target. Unfortunately you have given it four arguments – you have a space in the directory name “Program Files”. You need to ‘escape’ the spaces, maybe ‘%20’ would work (I’m a bit rusty on windows)
Thanks, that helped!
I downloaded Link Magic, a freeware program for creating junctions through a graphical interface. I now created a junction between c:\program files\xampp\htdocs\site1 and c:\program files\xampp\htdocs\drupal52. This is working...partially.
Any thoughts on why the junction is only working on the indexpage of te site and not for pages "deeper" in the site? I have configured my settings file correctly (defining http://localhost/site1/ as $base_url). Might it have to to with the .htaccess file in c:\program files\xampp\htdocs\drupal52? If so, how should I alter it?
Not sure about mod_rewrite
I’m not sure about mod_rewrite but my guess is that RewriteBase /drupal52 is causing this: Have you tried without?
It now works!
Rewriting .htaccess into the following makes the magic happen:
How to achieve this?
I now have the following working:
http://localhost/drupal52 (dir on server: c:/program files/xampp/htdocs/drupal52) is where drupal is installed. c:/program files/xampp/htdocs/site1 has been symlinked to c:/program files/xampp/htdocs/drupal52, so that http://localhost/site1 uses the same codebase but a different database because of the settings file in drupal52/sites/localhost.site1.
What I would like to achieve now is for each website to have it's own files and images repository, like this:
Notice that I have removed the files directory in htdocs/drupal52/files. This, because there will be no shared files among sites. Again, each site will have it's own repository.
Can this be achieved with Drupal configuration and / or rewriting the root's .htaccess?
Site-specific directories
Themes for all sites should go in sites/all/themes (README.txt in sites/all). I assume this is the purpose of that directory.
The files & images directories could be done with rewrite, but, depending on how you will use them, you could set-up admin » settings » file-system for each site to point directly eg. sites/localhost.site1/files for site1, & images could be a sub-directory of files.
HTH