我尝试在Windows 10 PC上设置虚拟主机时遇到问题。 在我的主机文件中:
127.0.0.1 project.dev
在我的httpd-vhosts.conf
中<VirtualHost *:80>
ServerAdmin webmaster@project.dev
DocumentRoot "path to project"
ServerName project.dev
ErrorLog "logs/project.dev-error.log"
CustomLog "logs/project.dev-error-access.log" common
<Directory path to project>
Require all granted
Allowoverride All
</Directory>
</VirtualHost>
httpd.exe运行没有错误。
我试着跑:
localhost
它工作,但当我尝试运行:
project.dev
在浏览器中,它不起作用。
This site can’t be reached
project.dev refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
我试图解决这个问题好几个小时,但我不能。 Windows防火墙日志,系统日志,应用程序日志,Apache日志不会向我显示任何帮助我的信息。
有人可以帮我调试这个问题吗?
谢谢!
------------ -------- UPDATE
今天,我将php和apache更新到了更新的版本
https://windows.php.net/downloads/releases/php-7.2.6-Win32-VC15-x64.zip
https://www.apachehaus.com/downloads/httpd-2.4.33-o110h-x64-vc14-r2.zip
并尝试使用简单的vhost运行project.dev:
<VirtualHost *:80>
DocumentRoot "C:/Users/0x1111/workspace"
ServerName project.dev
#ServerName www.example.com:80
</VirtualHost>
Chrome显示https错误:
Your connection is not private
Attackers might be trying to steal your information from project.dev (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
正常运行localhost
。
----更新-----
当我使用nslookup localhost
时:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
Non-authoritative answer:
Name: localhost
Addresses: ::1
127.0.0.1
但是当我查看project.dev
时:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
*** resolver1-fs.opendns.com can't find project.dev: Non-existent domain