Files to check - /etc/apache2/ports.conf - /etc/apache2/apache2.conf
Consider the ServerName to be "myserver". Check /etc/hosts for an entry
127.0.0.1 localhost 192.168.1.100 myserver.com myserver ...
We will see an example where by we can change/add apache ports in order to have two sites hosted on different ports.
Example: http://myserver:8001 http://myserver:8002
First, we need to edit ports.conf file to add two port numbers 8001, 8002
$ vi /etc/apache2/ports.conf
File Content
Listen 80 Listen 8001 Listen 8002
Listen 443
Now, ports.conf file is configured to listen on 80, 8001, 8002
Restart apache for the changes to take effect $ /etc/init.d/apache2 restart
To check if Apache is listening on the correct port, netstat command comes in handy
$ netstat -tulpn $ netstat -tulpn | grep :8002
Setup two site location in /var/www $ mkdir /var/www/site1 $ cd /var/www/site1 $ echo "In site1" > index.html
$ mkdir /var/www/site2 $ cd /var/www/site2 $ echo "In site2" > index.html
Now, lets create myserver.conf file in /etc/apache2/sites-available with the content shown below
ServerName greenland DocumentRoot /var/www/site1
ServerName greenland DocumentRoot /var/www/site2
Create a symbolic link to enable the site in sites-enabled folder $ cd /etc/apache2/sites-enabled $ ln -s ../sites-available/myserver.conf myserver.conf
In Debian, a2ensite and a2dissite comes in handy to enable, disable sites
Again, restart apache for the changes to take effect $ /etc/init.d/apache2 restart
In the browser, type http://myserver:8001 http://myserver:8002 to see the two sites in action.