3

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?

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
jameshwart lopez
  • 2,993
  • 6
  • 35
  • 65
  • 1
    Are you trying to access the urls at `anothersample.local:1234` and `sample.local:1234`? – shamsup Feb 27 '16 at 10:46
  • @ShamSUP Yes. I am access it that way. I also tried without port anothersample.local and ist not giving me any output. – jameshwart lopez Feb 27 '16 at 10:48
  • Look at this solution it go through all steps, so to be sure http://stackoverflow.com/questions/27754367/how-to-setting-virtual-hosts-for-xampp-in-windows/27754990#27754990, I suggest also you re install your xampp to start with – Maytham Fahmi Feb 27 '16 at 11:19
  • If you have mysql data on your xampp folder, make back up of that as well before re installing – Maytham Fahmi Feb 27 '16 at 11:21
  • @maytham-ɯɐɥıλɐɯ I have done your answer. and in my case it wasnt helpful.. – jameshwart lopez Feb 27 '16 at 11:28

3 Answers3

8

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.

Community
  • 1
  • 1
jameshwart lopez
  • 2,993
  • 6
  • 35
  • 65
  • you are welcome, you are welcome to check it as answer. – Maytham Fahmi Feb 27 '16 at 16:40
  • Glad you got your problem sorted out, but this doesn't create virtual hosts on port 1234 as you were asking. This answers an entirely different question: cannot make Apache listen to port 80 because port 80 is already in use. – Álvaro González Feb 29 '16 at 12:06
  • @ÁlvaroGonzález as you can see from my answer, the only change that I made to create my virtual host is the port(80).My problem was not my virtual host configuration, It was the port that is being used by another program. As you can read in the second sentence of my post, you will realize that my first problem was running my apache in windows 10, then I came up that I should use another port but then problem in setting up Virtual host came in. – jameshwart lopez Feb 29 '16 at 14:16
  • @jameshwart Thank you. I also tried a number of different 'solutions' offered on StackExchange and eslewhere, but nothing seemed to work for the vhosts. Simply changing the port of IIS fixed all problems. – ChE Junkie May 06 '17 at 12:22
  • Glad it helps :D – jameshwart lopez May 10 '17 at 13:18
4

E:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs/dev2017/schools"
    ServerName dev.schools
    <Directory "E:/xampp/htdocs/dev2017/schools">

    </Directory>
</VirtualHost>

C:\Windows\System32\drivers\etc\hosts

127.0.0.1       dev.schools

NOTE: Restart Xampp Server.

Type URL: http://dev.schools

SagarPPanchal
  • 9,839
  • 6
  • 34
  • 62
Ram Pukar
  • 1,583
  • 15
  • 17
2

Maybe my issue is different. Above answer not worked for me Windows 10, XAMPP portable 5.6.30

My XAMPP works on port 80 but when I set virtual host then its localhost also go to virtual host folder. So http://localhost also shows the content of http://mydrupal

I simply added this to /apache/conf/extra/httpd-vhosts.conf file as well.

<VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs"
    ServerName localhost
    <Directory D:/xampp/htdocs>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Above code was not required on Windows 7.

For virtual host - mydrupal

<VirtualHost *:80>
DocumentRoot "D:/vhosts/drupal"
ServerName mydrupal
<Directory D:/vhosts>
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

Hope this helps.

Burgi
  • 421
  • 8
  • 24
atyagi
  • 300
  • 2
  • 7