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 :

[[email protected] ~]# vim /etc/httpd/conf/httpd.conf

Update Admin’s address :

ServerAdmin [email protected]

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 [email protected]
    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
</VirtualHost>

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

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

5. Start httpd service :

[[email protected] ~]# systemctl restart httpd.service

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

[[email protected] ~]# 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 :

[[email protected] ~]# systemctl restart iptables.service

Leave a Reply