ubuntu apache2 更换默认端口

0x00

apache2 默认监听端口是 80,如何修改?

0x01

修改 /etc/apache2/ports.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

# Listen 80

# 改成你要的端口
Listen 8888

# 下面是和 ssl 有关的
<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

通过注释发现还需要修改 /etc/apache2/sites-available/000-default.conf 文件,打开文件后把 <VirtualHost *:80> 中的 80 修改成 8888 即可

最后重启 apache2 服务

1
sudo systemctl restart apache2.service

访问试试吧

0x02

封面出处:http://simpledesktops.com/browse/desktops/2017/feb/28/geo-shapes/

Author: ronething
Link: https://blog.ronething.cn/20181108-apache.html
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.