服务器端口修改脚本,Apach服务器基础---修改侦听的端口

一、     原配置文件:

#

# 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                                                                [::]:*

五、 手册

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值