问题
I add the following codes in httpd-vhost.conf file.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/mmcast"
ServerName mmcast.dev
<Directory "C:/xampp/htdocs/mmcast">
AllowOverride All
Require all granted
</Directory>
Although I can run the Apache and MySQL in XAMPP but I cannot call my vhost.
I got "Unable to connect" error in when I call mmcast.dev in browser.
Do I need to change <VirtualHost *:80>
into 81 ? Because I change Listen 81 in httpd file. But, I tried to change 80 to 81 but it still does not work.
In httpd.conf file, I change like this but it does not work.
<Directory />
AllowOverride all
Require all granted
</Directory>
In hosts file,
127.0.0.1 mmcast.dev
Only http://localhost:81/mmcast/
works. Can anyone help me please?
回答1:
Very first confirn you have an entry in hosts file -
127.0.0.1 mmcast.dev
Second, check httpd.conf
file - there are multiple < directory
tag and if necessary make all Require all granted
Third, in httpd-vhost.conf
file write bellow lines
# you can put any port whatever you feel comfortable! I normally use 127.0.0.1:144 and counting for every project
Listen 127.0.0.1:81
<VirtualHost 127.0.0.1:81>
ServerName mmcast.dev
DocumentRoot "C:\xampp\htdocs\mmcast"
SetEnv APPLICATION_ENV "development"
<Directory "C:\xampp\htdocs\mmcast">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Fourthly, RESTART XAMPP Server. and try in browser https://127.0.0.1:81
来源:https://stackoverflow.com/questions/45173872/virtual-host-cannot-create-with-xampp-server