1

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 ?

6
  • Do you have domains for them? Mar 12, 2011 at 10:18
  • Sorry, I'm not sure to understand your question. I'm using a localhost.
    – Coronier
    Mar 12, 2011 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, 2011 at 10:37
  • Did you read the error log after getting the 500? Mar 12, 2011 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, 2011 at 11:46

4 Answers 4

4

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.

1

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>
1

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.

0

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

Not the answer you're looking for? Browse other questions tagged .