How to Configure and Create Apache httpd VirtualHost on Fedora 16

Share this Article :

In this post, i will show on how to configure apache httpd and create VirtualHost on linux Fedora 16 server. Assumed that you already install apache httpd server.

1. Modify httpd.conf as below :

[root@fedora16 ~]# vim /etc/httpd/conf/httpd.conf

Update Admin’s address :

ServerAdmin root@fedora16.ehowstuff.local

Uncomment the serverName as below :

ServerName fedora16.ehowstuff.local:80

Add file name that can be access, example : index.php :

DirectoryIndex index.html index.html.var index.php

2. Uncomment NameVirtualHost :

# Use name-based virtual hosting.
NameVirtualHost *:80

3. Create Virtual host :

<VirtualHost *:80>
    ServerAdmin admin@fedora16.ehowstuff.local
    DocumentRoot /var/www/html/fedora16.ehowstuff.local
    ServerName fedora16.ehowstuff.local
    ErrorLog logs/fedora16.ehowstuff.local-error_log
    CustomLog logs/fedora16.ehowstuff.local-access_log common

4. Create sample index.html file on DocumentRoot of your virtualHost :

[root@fedora16 ~]# vi /var/www/html/fedora16.ehowstuff.local/index.html
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for Fedora.ehowstuff.local

5. Start httpd service :

[root@fedora16 ~]# systemctl restart httpd.service

6. Enable port 80 to go through linux iptables firewall :

[root@fedora16 ~]# vi /etc/sysconfig/iptables

Add this line :

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

7. Restart iptables to take effect :

[root@fedora16 ~]# systemctl restart iptables.service

Leave a Reply