Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to run two websites with XAMPP for Linux on my computer:

  • One for my public website development
  • One for my thesis (bibliography management, abstracts, ...)

They are totally unrelated and I don't want one to run on a sub domain of the other and I don't want to mess with the .htaccess file.

What's the best way to do so ?

share|improve this question

closed as off-topic by Iain, kasperd, Michael Hampton Aug 30 at 21:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Iain, Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Do you have domains for them? –  Frands Hansen Mar 12 '11 at 10:18
    
Sorry, I'm not sure to understand your question. I'm using a localhost. –  Coronier Mar 12 '11 at 10:35
    
I'm trying to configure VirtualHost (httpd-vhosts & /etc/hosts), but it doesn't work. I get a error 500... –  Coronier Mar 12 '11 at 10:37
    
Did you read the error log after getting the 500? –  Ignacio Vazquez-Abrams Mar 12 '11 at 10:59
    
In error_log, I have: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. –  Coronier Mar 12 '11 at 11:46

4 Answers 4

up vote 4 down vote accepted

Just set up your vhosts as is:

Name VirtualHost 127.0.0.1
<VirtualHost *:80>
   DocumentRoot /www/thesis
   ServerName thesiswork
</VirtualHost> 

<VirtualHost test2:80>
   DocumentRoot /www/test2
   ServerName test2
</VirtualHost>

<VirtualHost test3:80>
   DocumentRoot /www/test3
   ServerName test3
</VirtualHost>

Then in your /etc/hosts file just do the following:

example.com    127.0.0.1
test2.example.com    127.0.0.1
test2.example.com   127.0.0.1
test2               127.0.0.1
test3               127.0.0.1

That way you can just go to: example.com or test3.example.com (after you make the config changes to hosts makes sure you restart networking.

share|improve this answer

I recommend a port-based vhosts.conf like this (this is the complete vhosts.conf):

NameVirtualHost *:80

<virtualHost *:80>
DocumentRoot "/var/www/"
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

Listen 61 #use random free port number
<virtualHost *:61>
DocumentRoot "/var/vhosts/thesis/"
ServerName asdf
ServerAdmin admin@asdf
</VirtualHost>

You can then call your page with http://localhost/ and your thesis thing with http://localhost:61/

The advantage of port-based over name-based virtual hosting is that you don't need a domain, and you don't need to mess with your hosts file, which I find to be kind of "dirty".

Make sure you allow access to the directory in that you wish to host your thesis file in, for example in your httpd.conf, or just add it to your vhosts.conf:

<Directory "/var/vhosts/">
Order Deny,Allow
Allow From All
AllowOverride All
</Directory>
share|improve this answer

127.0.0.0/8 means that 127.0.0.2 and 127.0.0.3 and 127.0.0.4 and ... upto 127.254.254.254 or something like that are available IP addresses to use. So if name based virtual hosts are not good enough, you could have differerent localhost like IP addresses for each website.

share|improve this answer

You should use a name-based virtual host. Full details are listed here: http://httpd.apache.org/docs/current/vhosts/name-based.html

The basic idea is that you'll set up a default virtualhost on localhost, with something like this:

<VirtualHost _default_:*>
   DocumentRoot /www/default
</VirtualHost> 

Then, for your thesis site, you could set up another virtualhost

<VirtualHost *:80>
   DocumentRoot /www/thesis
   ServerName thesiswork
</VirtualHost> 

On your local computer, you would then have to edit your /etc/hosts file to include "thesiswork", pointing to 127.0.0.1

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.