更改默认的apache端口

时间:2011-08-22 02:04:26

标签: apache url

我对apache有疑问,据我所知,默认apache在端口80上工作,我需要将这个默认端口更改为另一个,比如8080。

实际上,我已成功更改此端口,通过编辑apache配置 Listen 80Listen 8080

但问题是,我需要添加:8080内部网址,所以我请求网站像这样: http://localhost:8080

是否可以删除网址上的8080?

因为我需要关闭端口80,而不需要关闭服务器以进行公共访问。

2 个答案:

答案 0 :(得分:4)

如果没有明确地将端口声明为URL的一部分,则无法将标准浏览器连接到非标准HTTP端口,否。

答案 1 :(得分:0)

尝试...

http://httpd.apache.org/docs/2.0/vhosts/examples.html

您有多个域转到同一个IP,并且还想要提供多个端口。通过在“NameVirtualHost”标记中定义端口,您可以允许它工作。如果您尝试使用不带NameVirtualHost名称:port或尝试使用Listen指令,则您的配置将不起作用。

Server configuration

Listen 80
Listen 8080

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>
相关问题