XAMPP (WIN7) 端口更改和虚拟主机
我决定更改 Apache 的端口,以消除与其他应用程序的一些冲突,甚至可能在将来尝试一下 IIS。我遇到了下面描述的问题。
基本上下文:
WIN 7 x64
XAMPP 1.7.4 (Apache 2.2.17, MySQL 5.5.8, PHP 5.3.5)
因此,我通过在 httpd.conf 中更改默认的 Apache 端口从 80 更改为 8080:
Listen 8080 (was Listen 80)
ServerName localhost:8080 (was ServerName localhost)
在我的 vhosts 文件中,我有:
NameVirtualHost 127.0.0.1:8080
以及这样定义的几个虚拟主机:
<VirtualHost 127.0.0.1:8080>
DocumentRoot "somepath"
ServerName servername
<directory "somepath">
usual stuff here
</directory>
</VirtualHost>
当我尝试访问虚拟主机时使用上面定义的服务器名,如果不明确指定端口,它就不起作用:
servername:8080
似乎 vhosts 文件中定义的端口没有任何区别,无论我尝试什么(80、8080,什么都没有),它总是需要与服务器名称一起指定的端口。
phpinfo() 说:
SERVER_PORT: 8080
Apache 错误日志不显示任何错误。
我想我想知道这是否是正常行为,或者我忽略了一些事情。
I've decided to change the ports for Apache to clear up some conflicts with other applications, and maybe even give IIS a shot in the future. I've run into the problem described below.
The basic context:
WIN 7 x64
XAMPP 1.7.4 (Apache 2.2.17, MySQL 5.5.8, PHP 5.3.5)
So I've changed the default Apache port from 80 to 8080, by changing this in the httpd.conf:
Listen 8080 (was Listen 80)
ServerName localhost:8080 (was ServerName localhost)
In my vhosts file I have:
NameVirtualHost 127.0.0.1:8080
And several virtual hosts defined like this:
<VirtualHost 127.0.0.1:8080>
DocumentRoot "somepath"
ServerName servername
<directory "somepath">
usual stuff here
</directory>
</VirtualHost>
When I try to access the virtual host using the servername defined above it does not work without explicitly specifying the port:
servername:8080
It would also seem that the port defined in the vhosts file does not make any difference, whatever I tried (80, 8080, nothing), it allways requires the port to be given with the server name.
phpinfo() says:
SERVER_PORT: 8080
Apache error logs do not show any errors.
I guess I'm wondering if this is normal behaviour, or there is something I overlooked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
80 端口是浏览器的默认端口,因此您不需要访问 servername:80。在您的情况下,像这样访问服务器是正常的:servername:8080
The 80 port is default for browsers so that's why you don't need to access servername:80. In your case it's normal to acces server like this : servername:8080
如果您想访问本地主机而不在 URL 中指定端口号
http://localhost
而不是http://localhost:8080
。8080
。If your want to access localhost without specify the port number in the URL
http://localhost
instead ofhttp://localhost:8080
.8080
.