Install Virtualhosts on Fedora 11/12

Lets give a definition of a vrtualhost

The term Virtual Host refers to the practice of maintaining more than one server on one machine, as differentiated by their apparent hostname. For example, it is often desirable for companies sharing a web server to have their own domains, with web servers accessible as and, without requiring the user to know any extra path information.

Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both, IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts. (source

now first we have to install httpd server

#yum install httpd

Now when the apache server installled you can find the config files

Example : we have 2 domaine : and

Now . we have to make the domains pub_html inside the home user /home/test1

now first create the public_html inside this directory with subdirctories of this domaine

cd  /home/test1
mkdir public_html

Now create the subdirectories of the virtual hosts :

mkdir -p public_html/{public,private,log,cgi-bin,backup}
mkdir -p public_html/{public,private,log,cgi-bin,backup}

now lets make a small script to direct the index.html to the virtualhost

VI  public_html/

and add


dont froget to close the lines with



dont forget to make the same chnage in the index.html of example2

Now you have to edit httpd.conf and make line uncomented
# Use name-based virtual hosting.
NameVirtualHost *:80

Now restart your httpd service
#services httpd restart
you will get somthing like

Stopping httpd:                                            [  OK  ]

Starting httpd: [Mon 15 Dec  07:12:12 2010 [warn] NameVirtualHost *:80 has no VirtualHosts

                                                           [  OK  ]

Configure virtualhosts

vi /etc/httpd/conf/httpd.conf
add this

# Place any notes or comments you have here
# It will make any customization easier to understand in the weeks to come

# domain:
# public: /home/test1/public_html/

# Admin email, Server Name (domain name) and any aliases

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /home/test1/public_html/

# Custom log file locations
LogLevel warn
ErrorLog /home/test1/public_html/
CustomLog /home/test1/public_html/ combined

save and exit

dont forget to do the same config for

No reboot or reload the httpd
#services httpd restart
#services httpd reload

Now navigate to the first virtual host

http://www/ and should be working

if you want to check your logs

ls  /home/demo/public_html/

this it the output

access.log error.log

Please enjoy and ask if you have any question