Search code examples
apachexampp

Create a Virtual Host in Xamp Windows 10


Last night I have updated my windows 7 to windows 10.

The result is struggle trying to run my local apache server in windows 10 that is running on windows 7.I have tried uninstalling and installing another versions of xampp then I came up that I have to change the apache's default port just to make it run.

I changed httpd.conf

from Listen 80 to Listen 1234

AND ServerName localhost:80 to ServerName localhost:1234

and in xampp control panel Config->Service and Port Settings. I also change the Main Port enter image description here

Now I can access phpmyadmin using localhost:1234/phpmyadmin. And now my problem is creating Virtual host

so I added in my host(C:\Windows\System32\drivers\etc\hosts) file

127.0.0.1       sample.local
127.0.0.1       anothersample.local

And my vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file

<VirtualHost *:1234>
    DocumentRoot "D:/xampp/htdocs/sample"
    ServerName sample.local
</VirtualHost>

<VirtualHost *:1234>
    DocumentRoot "D:/xampp/htdocs/anothersample"
    ServerName anothersample.local
</VirtualHost>

I did make sure the vhost file above was include enter image description here

I already restarted my apache but seems like my vhost is not working .Can anyone point out what i missed?


Solution

  • Thank you @ShamSUP AND @maytham-ɯɐɥıλɐɯ I was able to solve my problem by uninstalling the xampp.

    Then following the instructions here

    I will just list the steps I have done here.

    1. Windows+R and type appwiz.cpl and use Turn Windows features on or off and install the IIS Manager Console by expanding Internet Information Services->Web Management Tools->then checking IIS Management Console
    2. Windows+R and type InetMgr.exe and enter, then expand Site Right Click it then click Edit Bindings
    3. Change the http port from 80 to 8080

    After that I then install the XAMPP and configure the Virtual host

    host(C:\Windows\System32\drivers\etc\hosts) file

    127.0.0.1       sample.local
    127.0.0.1       anothersample.local
    

    vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file

    <VirtualHost *:80>
        DocumentRoot "D:\xampp\htdocs\sample"
        ServerName sample.local
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "D:/xampp/htdocs/anothersample"
        ServerName anothersample.local
    </VirtualHost>
    

    And by default in windows virtual host is uncommentedenter image description here

    After restarting apache and mysql.The Virtual host is running now.I hope this may help someone in the future.