If you decided to run more than one website on your Apache web server you would need to configure a VirtualHost based on the name or IP address. Here is some notes on how to achieve it. Here we assume that you have httpd package already installed on your system.
Create a directory to contain your new website:
# mkdir /var/www/example.net # echo Hello Web > /var/www/example.net/index.html # chmod -R 755 /var/www/example.net # chown -R apache.apache /var/www/example.net
Add virtual host configuration to the bottom of /etc/httpd/conf/httpd.conf :
<VirtualHost *:80> DocumentRoot /var/www/example.net ServerName www.example.net # Other Apache config directives, logs etc. </VirtualHost>
Confirm the VirtualHost sytax before restarting httpd service:
# httpd -S
Restart apache :
# /etc/init.d/httpd restart
If your example domain is already pointing to your server you should be ready to go. Make sure that your domain resolves an IP address of your server. For testing it is also handy to modify /etc/hosts file. For example if this is done just locally add :
# echo 127.0.0.1 www.example.net example.net >> /etc/hosts
Or if your web server’s IP is 18.104.22.168 do to access it from your local client:
# echo 22.214.171.124 www.example.net example.net >> /etc/hosts
For anything else you need Domain name record somewhere.
Navigate to your new VirtualHost website.