Tuesday, July 9, 2013

Create Virtual Host


Webmin is the best server admin panel, but some times it fails to do some jobs. Creating virtual host is one of them. So, I’m explaining code for creating virtual host. This is very easy to do. Just copy paste given code and that’s it.

Step 1) Open Apache2 configuration file

sudo gedit /etc/apache2/apache2.conf

Copy-paste this code:

######################wordpress-local.com -- start ###############
<VirtualHost *:80 >
ServerAdmin webmaster@localhost
ServerName wordpress-local.com
DocumentRoot /var/www/wordpress

<Directory >
  Options All
  AllowOverride All 
</Directory >

<Directory /var/www/wordpress>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory >


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
< Directory "/usr/lib/cgi-bin" >
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
</Directory >

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
< Directory "/usr/share/doc" >
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Order deny,allow
  Deny from all

Allow from 127.0.0.0/255.0.0.0 ::1/128

   < /Directory > 

< /VirtualHost >

######################wordpress-local.com -- over ###############

Step 2) Open  Hosts File

sudo gedit /etc/hosts

Write this code

127.0.0.1 localhost
127.0.0.1 wordpress-local.com     <<----- 

Step 3) Restart Apache server

sudo service apache2 reload

Now, you can open http://wordpress-local.com on your browser.