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.

Step 1:

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

Step 2:

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>

Step 3:

Confirm the VirtualHost sytax before restarting httpd service:

# httpd -S

Step 4:

Restart apache :

# /etc/init.d/httpd restart

Step 5:

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 222.222.22.2 do to access it from your local client:

# echo 222.222.22.2 www.example.net example.net >> /etc/hosts

For anything else you need Domain name record somewhere.

Step 6:

Navigate to your new VirtualHost website.

Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top