更改默认apache端口

更改默认apache端口,apache,url,Apache,Url,我对apache有疑问,我知道,默认情况下apache在端口80上工作,我需要将这个默认端口更改为另一个端口,比如8080 实际上,我已经成功地更改了这个端口,通过在 Listen 80至Listen 8080 但问题是,我需要在url中添加:8080,所以我请求站点如下: 是否可以删除url上的8080 因为我需要关闭端口80,而无需关闭服务器进行公共访问。如果不将端口明确声明为URL的一部分,则无法将标准浏览器连接到非标准HTTP端口,否。如果不将端口明确声明为URL的一部分,则无法将标准

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

实际上,我已经成功地更改了这个端口,通过在
Listen 80
Listen 8080

但问题是,我需要在url中添加:8080,所以我请求站点如下:

是否可以删除url上的8080


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

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

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

请尝试

您有多个域连接到同一IP,并且还希望为多个端口提供服务。通过在“NameVirtualHost”标记中定义端口,您可以让它工作。如果尝试在不使用名称virtualhost name: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>
服务器配置
听80
听8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
服务器名www.example1.com
DocumentRoot/www/domain-80
服务器名www.example1.com
DocumentRoot/www/domain-8080
服务器名www.example2.org
DocumentRoot/www/otherdomain-80
服务器名www.example2.org
DocumentRoot/www/otherdomain-8080
试试

您有多个域连接到同一IP,并且还希望为多个端口提供服务。通过在“NameVirtualHost”标记中定义端口,您可以让它工作。如果尝试在不使用名称virtualhost name: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>
服务器配置
听80
听8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
服务器名www.example1.com
DocumentRoot/www/domain-80
服务器名www.example1.com
DocumentRoot/www/domain-8080
服务器名www.example2.org
DocumentRoot/www/otherdomain-80
服务器名www.example2.org
DocumentRoot/www/otherdomain-8080

Hi hoxworth,谢谢你的回答,我该怎么做?也许你可以给我一个注释:)通过“明确声明为URL的一部分”,我认为hoxworth的意思正是你在问题中所写的,即
http://localhost:8080
Hi hoxworth,谢谢你的回答,我该怎么做?也许你可以给我一个注释:)通过“明确声明为URL的一部分”,我认为hoxworth的意思正是你在问题中所写的,即
http://localhost:8080
您好,在我看来,您的问题并不是关于stackoverflow的主题。我不想讨论这个话题,因为这个问题是关于网络/服务器问题的,不幸的是,转到serverfault并不能得到更好的答案。(霍克斯沃思回答得恰到好处)嗨,在我看来,你的问题并不是关于stackoverflow的话题。我不想讨论这个话题,因为这个问题是关于网络/服务器问题的,不幸的是,转到serverfault并不能得到更好的答案。(霍克斯沃思回答得恰到好处)