Apache VirtualHost Exercise: Vitus
-----------------------------------
NB: Please note, remember to replace X with your pc number. eg pc36.sse.ws.afnog.org
NB: Please note, remember to replace Y with your neighbours pc number. eg pc37.sse.ws.afnog.org
0.
IF your DNS is setup and working then do mapping on DNS.
web1 IN A 196.200.219.X ; your IP
web2 IN A 196.200.219.X ; your IP
...
-- START WORK --
1. Create web directory for each host
sudo mkdir -p /var/www/html/pcX.sse.ws.afnog.org
sudo mkdir -p /var/www/html/pcY.sse.ws.afnog.org
cd /var/www/html/pcX.sse.ws.afnog.org
2. sudo nano /var/www/html/pcX.sse.ws.afnog.org/index.html
--- WEB1---
3. sudo nano /var/www/html/pcY.sse.ws.afnog.org/index.html
--- WEB2 ---
SSE
Welcome To KAMPALA - UGANDA Afnog 20
//createing virtual virtual host files
4. sudo nano /etc/apache2/sites-available/pc33.sse.ws.afnog.org.conf
ServerAdmin root@pcX.sse.ws.afnog.org
ServerName www.xxxx.afnog.nog-oc.org
DocumentRoot /var/www/html/pc36.sse.ws.afnog.org
ErrorLog ${APACHE_LOG_DIR}/www.pcX.sse.ws.afnog.org_error.log
CustomLog ${APACHE_LOG_DIR}/www.pcX.sse.ws.afnog.org_ccess.log combined
5. sudo vi /etc/apache2/sites-available/pcY.sse.ws.afnog.org.conf
ServerAdmin root@pcX.sse.ws.afnog.org
ServerName web2.xxxx.afnog.nog-oc.org
DocumentRoot /var/www/html/pcY.sse.ws.afnog.org
ErrorLog ${APACHE_LOG_DIR}/www.pcY.sse.ws.afnog.org_error.log
CustomLog ${APACHE_LOG_DIR}/www.pcY.sse.ws.afnog.org_ccess.log combined
DEFINE A RECORDS
*****************
IF your DNS is setup and working then do mapping on DNS.
web1 IN A 196.200.219.X ; your IP
web2 IN A 196.200.219.X ; your IP
ELSE
JUMP TO #HOSTFILE
Disable the default
$sudo a2dissite 000-default.conf
Now make your new sites go live by enabling them.
$sudo a2ensite pcX.sse.ws.afnog.org.conf
$sudo a2ensite pcY.sse.ws.afnog.org.conf
$sudo systemctl reload apache2
TESTING
Go to your web browser and check sites.
END - Congrats.
#HOSTFILE
DON'T DO THIS IF YOUR DNS IS FINE.
6. sudo nano /etc/hosts
127.0.0.1 pcX.sse.ws.afnog.org pc36
127.0.0.1 pcY.sse.ws.afnog.org pc37
Else if you are using your hosts file.
$lynx pcX.sse.ws.afnog.org
$lynx pcY.sse.ws.afnog.org