How to create a virtual host
Mar 02, 2016 Janaki Mahapatra, Laravel
There are two ways you can create your virtual hosts easily.
- Through command prompt using ssh
- If you have already installed the vagrant box, then open your bash command window or putty type
vagrant up
this will start the virtual machinevagrant ssh
To ssh to the vm and finallysudo nano /etc/httpd/con/httpd.conf
to edit the Apache config file Check the image here. - scroll down to end of the file and type
DocumentRoot /home/vagrant/public_html/sampleproject ServerName sampleproject.local <Directory /home/vagrant/public_html/test> AllowOverride All </Directory> ErrorLog /home/vagrant/public_html/logs/sampleproject_error_log CustomLog /home/vagrant/public_html/logs/sampleproject_access_log common
- Now press CTRL+O to save the file
- now restart the apache by typing sudo service httpd restart
- Time to configure our sampleproject.local domain in our OS. To do that open your hosts file and add 127.0.0.1 sampleproject.local
- Save the hosts file and open a browser and browse sampleproject.local:8000
- If you have already installed the vagrant box, then open your bash command window or putty type
- Through webmin/virtualmin (it is a gui interface)
- Log in to webmin by browsing https://localhost:10080/
- Use username as root and password as vagrant
- After login you will see the home page of webmin
- Under left navigation open Server->Apache Webserver
- Now create a virtual host. Check the image below
- Select "Any Adress" for Handel Connetions to address
- Use Port:80
- Select DocumentRoot
- Write ServerName (in our case it is sampleproject.local
- Click the "Create Now" button to create your virtual hosts
- Now configure our sampleproject.local domain in our OS. To do that open your hosts file and add 127.0.0.1 sampleproject.local
- Save the hosts file and open a browser and browse sampleproject.local:8000