Introduction
1. To create a virutal host you need create a directory inside your server so that we can put our content in it :-
2. Then you can put your content in it for e.g we will put index.html file for our test :-
Insert some character for identification
3. Now add the virtual host conf file in /etc/httpd/conf.d/ directory :
You need to create logs file at defined location so that log can be generated by apache :-
6. Now restart the web service :-
7. Lets browse the website with virutal name :-
That's it you can enjoy using Virtualhost.
Please Do Comments, Likes and Share.
Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to used the same host name.
I am using fedora-21 as a distribution for virtualhost testing. And I have already installed a LAMP server. You can also use any text editor like nano,vim,vi etc.. Note that VIM doesn't come installed with Fedora21 you have to install it.
1. To create a virutal host you need create a directory inside your server so that we can put our content in it :-
mkdir /var/www/html/test
2. Then you can put your content in it for e.g we will put index.html file for our test :-
vim /var/www/html/test/index.html
Insert some character for identification
<html>
<body>
<h1> THIS IS A VIRTUAL HOST </h1>
</body>
</html>
3. Now add the virtual host conf file in /etc/httpd/conf.d/ directory :
vim /etc/httpd/conf.d/test.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/test
ServerName www.virtualtest.com
ServerAdmin sarfaraz@techs2resolve.in
ErrorLog /var/log/virtual.host-error_log
CustomLog /var/log/virtual.host-access_log combined
</VirtualHost>
You need to create logs file at defined location so that log can be generated by apache :-
touch /var/log/virtual.host-error_log
touch /var/log/virtual.host-access_log
# Now give permission
chmod 777 /var/log/virtual.host-error_log
chmod 777 /var/log/virtual.host-access_log
4. Now check the ownership and permission as per your structure as i am putting it in default document root directory but as per production document root path may be different. So please configure as per your location :-
chown -R apache:apache /var/www/html/test
5. Now as we are testing it in local environment on the same server so we have to add an host entry inside /etc/hosts file. If you are on production environment you need to add CNAME record in your Domain DNS :-
vim /etc/hosts 192.168.15.47 www.virtualtest.com #save and exit
6. Now restart the web service :-
service httpd restart
7. Lets browse the website with virutal name :-
That's it you can enjoy using Virtualhost.
Please Do Comments, Likes and Share.
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments