How to create virtual host in ubuntu 14 ?

  • create directory under var/www/ folder by this command, to hit command press ctrl+alt+t i “sudo mkdir -p /var/www/project.com/public_html”
  • sudo mkdir -p /var/www/project.com/public_html
  • Now it’s time to give permission the folder that we created so hit this command “sudo chown -R root:root /var/www/project.com/public_html”
  • sudo chown -R root:root /var/www/project.com/public_html
  • Copy the host file using this command “sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/local.project.com.conf”
  • sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/local.project.com.conf
  • Now, edit this file
    etc/apache2/sites-available/local.project.com.conf"
  • ServerAdmin admin@local.project.com
    ServerName local.project.com
    DocumentRoot /var/www/html/folder-1/project/public_html
  • in DocumentRoot you can set any project url which will map to the virtual host domain
  • Make one localhost project entry in host file /etc/hosts like this way.
  • 127.0.0.1   localhost
    127.0.1.1   guest-desktop
    111.111.111.111 example.com
    111.111.111.111 local.project.com
  • To enable and activate the server hit
    sudo a2ensite local.project.com.conf
  • Last setep to reload apache server by this
    sudo service apache2 restart
  • Visit your new site

local.project.com

Advertisements

About Hiren Kubavat

PHP Developer
This entry was posted in Apache. Bookmark the permalink.

2 Responses to How to create virtual host in ubuntu 14 ?

  1. Pingback: How to create virtual host in ubuntu 14 ? — Hiren Kubavat | SutoCom Solutions

  2. krishna kumar says:

    this article really helped me

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s