How to create quick apache virtual host in Ubuntu?By Hardik Savani | December 7, 2016 | | 21527 Viewer | Category : Installation Ubuntu Server Apache
We always require to create virtualhost on each project because we don't want to run each project manually, so it is better way to create virtual host address for each project when you development like as bellow:
It will best way to run our project on local system. But if you want to create virtual host on ubuntu, you have to follow several step like site enabled, site enabled config, site directory permission, hosts entry and etc. You have to follow several step on each virtual host create time. I think it take a time to create on every time and also it anything you forgot they it return error like "apache virtual host permission denied", "apache virtual host 403 forbidden", "apache 403 client denied by server configuration" and etc.
However, In this tutorial i am going to give you very quick way to create virtual host on your ubuntu os. You have to just install "Virtualhost Manage Script" at one time in your system. That script provide us "vistualhost" command and we can quick create and delete virtualhost. So just install this script by following 5 commands in your terminal:
$ cd /usr/local/bin
$ wget -O virtualhost https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost.sh
$ chmod +x virtualhost
$ wget -O virtualhost-nginx https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost-nginx.sh
$ chmod +x virtualhost-nginx
Maybe you require to use sudo for admin permission issue.
Ok, now we are ready to create quick virtual host in our ubuntu system. So you have to follow bellow syntax to create virtual host:
Virtual Host Create Syntax:
sudo virtualhost create domain_name directory_path
Virtual Host Create Example:
sudo virtualhost create blog.dev /var/www/blog/public
You can also see how it works on bellow screenshot:
This way you can simply create virtual host on your system, you can also use with PHP5 and PHP7, you can get more information about this script from here : Virtualhost Manage Script.
I hope it can help you...