Friday 25 July 2008

apache2

ok so i had to learn about apache2 virtual hosting today...so here is a quick run down of getting your fo-shizzle working

this assumes you have installed and set up apache2 first

first go into apache folder
/etc/apache2/

in here you will find something like the following


/etc/apache2# ls
apache2.conf httpd.conf mods-enabled sites-available
conf.d magic ports.conf sites-enabled
envvars mods-available README ssl



now the apache2.conf will auto include every config placed in the "sites-available" folder
go into that folder and you will likely see a file called default
this is the file that the server will use for a default website (if someone goes to your server via the ip address in a browser)

so do a cp of that file and name it yournewdomain.com

right now edit the new file yournewdomain.com and change the following bits
first remove the
NameVirtualHost *
bit you only need that on the default file.
then change the bits below to reflect your domainname and your server root folder for that particular website


ServerName www.yourdomain.com
ServerAlias www.yourdomain.com *.yourdomain.com
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/web


where your document root is a different folder from the standard /var/www

now save that and creat a symbolic link between the sites-available and the sites-enabled folder using
ln -s /etc/apache2/sites-available/yourdomain.com sites-enabled/yourdomain.com

then restart the apache2 server with
/etc/init.d/apache2 restart

and your done :)