一、 原配置文件:
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
二、 配置格式
Listen [IP-address:]portnumber [protocol]
For example, to make the server accept connections on bothport 80 and port 8000, use:
Listen 80
Listen 8000
To make the server accept connections on two specifiedinterfaces and port numbers, use
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
The optional protocol argument is not required for mostconfigurations. If not specified, https is the default forport 443 and http the default for all other ports. Theprotocol is used to determine which module should handle a request, andto apply protocol specific optimizations with the AcceptFilter directive.
You only need to set the protocol if you are running on non-standardports. For example, running an https site on port 8443:
Listen 192.170.2.1:8443 https
三、 说明不指定IP地址则表示侦听服务器上的所有IP
Listen指令可以出现多次,每一行可以指定一个特定的IP和端口
修改侦听的端口后,需重启服务器生效
限制其必须通过SSL通信时,Protocol需要定义为https
修改端口, vim /etc/httpd/conf/httpd.conf
如果要新增一个端口,可以编辑主配置文件,也可以在conf.d目录下,创建一个.conf文件,指定Listen指令。
四、示例: 增加一个侦听的8080端口
[root@liuqing ~]# cat /etc/httpd/conf.d/listenport.conf
Listen 192.168.99.28:8080
[root@liuqing ~]# httpd -t
Syntax OK
[root@liuqing ~]# systemctl restart httpd
[root@liuqing ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 192.168.99.28:8080 *:*
LISTEN 0 128 [::]:80 [::]:*
五、 手册