In port based virtual hosting, different websites run on different ports. In this is example, we will be running website on port 81 of development server. Not much useful for production server, still I find this useful for development server.

folder structure
————————-
In $home directory, create the folders from where the files will be server.

webapps
--djangoapp
----index.html
----log
------error.log
------access.log

cd /etc/apache2/sites-available
sudo vi djangoapp

Listen 81
NameVirtualHost *:81

<VirtualHost *:81>
ServerAdmin webmaster@localhost
DocumentRoot /home/vinod/webapps/djangoapp

<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride None
</Directory>

ErrorLog /home/vinod/webapps/djangoapp/log/error.log
LogLevel warn
CustomLog /home/vinod/webapps/djangoapp/log/access.log combined
ServerSignature On
</VirtualHost>

sudo a2ensite djangoapp
sudo /etc/init.d/apache2 reload

http://localhost:81/ should now server the index.html file in djangoapp folder.

One Response to “Port based Virtual Hosting in Apache2 (Ubuntu 9.04)”

  1. John Sheridan says:

    Yes!!
    Finally someone who shows a step by step setup for port based virtual sites under ubuntu.
    Thank you so much!

    - John

Leave a Reply