我正在尝试为 mampstack(不是 MAMP)设置一个虚拟主机。这是我到目前为止所做的:
在我的 httpd.conf 文件中,我检查了
Listen 8080
这是正确的(我正在监听端口 8080,而不是 80)。
然后我取消了注释:
Include conf/extra/httpd-vhosts.conf
在我的 httpd.conf
文件在我的主机文件中,我添加了以下内容:
127.0.0.1 mext-pst.local
.在
httpd-vhosts.conf
我已经添加:NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs"
ServerName 127.0.0.1
ServerAlias localhost
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs/mext-pst-dashboard/web"
ServerName mext-pst.local
ServerAlias mext-pst.local
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN mext-pst.local
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^ http://%{HTTP_HOST}:8080%{REQUEST_URI} [P]
</VirtualHost>
现在当我去
http://mext-pst.local/
我只是收到我的浏览器错误,他无法连接到该页面......当我去
http://mext-pst.local:8080/
我收到以下错误:Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /index.php.
Reason: DNS lookup failure for: mext-pst.local:8080
当我去
http://mext-pst.local:8080/index.php
有用 ...
最佳答案
您必须将端口更改为 *:80,并且如果您打算使用不同的名称,那么服务器名请确保在您的 httpd.conf 中使用 NameVirtualHost *:80。
关于apache - VirtualHost 设置总是不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21936220/