Re: [Hampshire] apache2 configuration

Top Page

Reply to this message
Author: Peter Alefounder
Date:  
To: hampshire@mailman.lug.org.uk
Subject: Re: [Hampshire] apache2 configuration

 
With the help of diverse web sites and odd bits of documentation, I
have now solved the problem I had of getting virtual hosts working
with apache2 under Debian 7.1. Just in case it is of use to anyone
else, here is how to do it:
 
(1) add
 
ServerName localhost
 
to the end of /etc/apache2/apache2.conf
 
(2) add an IP address for each virtual host to the end of
/etc/hosts, for example:
 
127.0.2.1 example1.com
127.0.3.1 http://www.example2.com/
 
(3) create a configuration file for each virtual host and put it
in /etc/apache2/sites-enabled/, for example:
 
/etc/apache2/sites-enabled/example1.conf
NameVirtualHost 127.0.2.1:80
<VirtualHost 127.0.2.1:80>
  ServerName example1.com
  ServerAlias http://www.example1.com/
  DocumentRoot /home/user/example1/WebSite
  Alias /webdir /home/user/some/other/dir
</VirtualHost>
 
/etc/apache2/sites-enabled/example2.conf
NameVirtualHost 127.0.3.1:80
<VirtualHost 127.0.3.1:80>
  ServerName http://www.example2.com/
  DocumentRoot /home/user/example2
  Options +ExecCGI
  AddHandler cgi-script .cgi .pl
  ScriptAlias /cgi-bin/  /home/user/example2/CGI/cgi-bin/
  ErrorLog /etc/apache2/error.log
</VirtualHost>
 
(4) restart apache2:
apache2ctl -k restart
 
Peter Alefounder.

--
Please post to: Hampshire@???
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------