Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create virtual host with xampp VM?

I recently started use xampp vm ! I want to connect my project exist in /Users/mine/project . So I tried with vhost from /opt/lampp/etc/extra/httpd-vhosts.conf ,that is open by xampp application volumes tab Explore.

<VirtualHost *:80>
    DocumentRoot "/Users/mine/project"
    ServerName mine.online
</VirtualHost>

Then I update hosts file from terminal like below,

192.168.64.2    mine.online //192.168.6.2 is xampp vm ip

Also I do uncomment in /opt/lampp/etc/httpd.conf

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

Finally I restarted my apache ! But it show me 404 not found . Please help me how to run correctly ?

Plus => is there any way to clone git project to xampp vm 's htdocs folder ?

like image 979
David Jaw Hpan Avatar asked Oct 06 '17 03:10

David Jaw Hpan


People also ask

How can we set virtual host in local machine?

Register the new virtual hostname To register a host name, we need to edit the hosts file, which is located at C:\Windows\System32\drivers\etc\hosts . At the bottom of the file, add the name of your virtual host. The hosts file requires administrator privilege to edit. See the note below on how to do so.


1 Answers

-->Open your local terminal and run "vi /etc/hosts" without quote

-->Add "192.168.64.2 mine.online" line without quote and then save the file

-->Go to Xampp and start the xampp.

-->Go to volumes tab and mount the "/opt/lampp" volume.

-->Press the explore button and then go to "lampp/etc/extra"

-->Open the "httpd-vhosts.conf" file and edit like as the given one

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/opt/lampp/htdocs/YOUR_PROJECT_FOLDER"
    ServerName mine.online
    ServerAlias www.mine.online
    ErrorLog "logs/mine.online-error_log"
    CustomLog "logs/mine.online-access_log" common
</VirtualHost>

-->Then go to "/opt/lampp/etc/httpd.conf"

-->Uncomment "Include etc/extra/httpd-vhosts.conf"

-->Restart the services from Xampp

Then it should work.

like image 153
Md. Robi Ullah Avatar answered Oct 06 '22 21:10

Md. Robi Ullah