Fedora 21 Apache httpd Virtual Hostings Techs2resolve

Fedora 21 Apache httpd Virtual Hostings Techs2resolve




Fedora21:Apache httpd:Virtual Hostings : Techs2resolve

Virtual Hosting allows Apache Weberver to serve different content based on IP Address, hostname or used port number.

In this tutorial we will see name based virtual hosting.

This tutorial assumes you have installed Apache httpd server.

1. To create virtual host do the following:-

vi /etc/httpd/conf.d/vhost.conf

2. Add the below code in the file:-

# create new
# for original domain
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName sarfaraz.test.com # <= Your system hostname
</VirtualHost>

3. Add the virtual host entry next to it 

<VirtualHost *:80>
DocumentRoot /home/sarfaraz/public_html/virtual #Change to your path
ServerName www.virtual.host
ServerAdmin root@virtual.host
ErrorLog /var/log/virtual.host-error_log
CustomLog /var/log/virtual.host-access_log combined
</VirtualHost>



4. After this create a directory with name virtual:-


# mkdir /home/sarfaraz/public_html/virtual

# chmod -R 755 /home/sarfaraz/public_html/virtual

5. Now we need to create logs file which we mentioned above:-

# vim /var/log/virtual.host-error_log

# vim /var/log/virtual.host-access_log



Change the permission of the log files:-

# chmod 644 /var/log/virtual.host-error_log

# chmod 644 /var/log/virtual.host-access_log


6. Add the virtual host entry in /etc/hosts file:-

# vim /etc/hosts

#Add the host entry at the bottom

192.168.15.47 www.virtual.host


7. Now create the file inside your DocumentRoot :-

# Please add the below code if you have installed php or you can add any text 


<?php
phpinfo();
?>


8. Now lets access it from the browser:-


9. Now lets check the log files:-


Thats it 
Enjoy creating Virtualhost !
Please do Like,Share and Comments:-

download file now

Unknown

About Unknown

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :