修改端口号方法转载自:https://blog.muumlover.com/2016/11/apache2-setup.html
新手使用阿里云debian9 安装apache2后 输入如下命令启动apache时报错:
sudo systemctl status apache2
● apache2.service - The Apache HTTP Server Loaded: loaded
(/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-06-30 16:21:58 CST;
8ms ago Process: 4607 ExecStart=/usr/sbin/apachectl start
(code=exited, status=1/FAILURE)Jun 30 16:21:58 iZuf61117nu6xzs3cu9ckzZ apachectl[4607]: AH00558:
apache2: Could not reliably determine the server’s fully Jun 30
16:21:58 iZuf61117nu6xzs3cu9ckzZ apachectl[4607]: (98)Address already
in use: AH00072: make_sock: could not bind to Jun 30 16:21:58
iZuf61117nu6xzs3cu9ckzZ apachectl[4607]: no listening sockets
available, shutting down Jun 30 16:21:58 iZuf61117nu6xzs3cu9ckzZ
apachectl[4607]: AH00015: Unable to open logs Jun 30 16:21:58
iZuf61117nu6xzs3cu9ckzZ apachectl[4607]: Action ‘start’ failed. Jun 30
16:21:58 iZuf61117nu6xzs3cu9ckzZ apachectl[4607]: The Apache error log
may have more information. Jun 30 16:21:58 iZuf61117nu6xzs3cu9ckzZ
systemd[1]: apache2.service: Control process exited, code=exited
status=1 Jun 30 16:21:58 iZuf61117nu6xzs3cu9ckzZ systemd[1]: Failed to
start The Apache HTTP Server. Jun 30 16:21:58 iZuf61117nu6xzs3cu9ckzZ
systemd[1]: apache2.service: Unit entered failed state. Jun 30
16:21:58 iZuf61117nu6xzs3cu9ckzZ systemd[1]: apache2.service: Failed
with result ‘exit-code’. Hint: Some lines were ellipsized, use -l to
show in full. Processing triggers for libc-bin (2.24-11+deb9u4) …
Processing triggers for systemd (232-25+deb9u11) …
?原因:端口被占用
?解决办法:修改端口号 vim /etc/apache2/ports
【小白vim操作提示(win10)】 键入
i
进入输入模式,shift + Fn + Ins
粘贴段落,按Esc
退出输入模式,键入:wq
保存配置
# 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 8080
<IfModule ssl_module>
Listen 8088 </IfModule>
<IfModule mod_gnutls.c>
Listen 8088 </IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet///////
再次启动Apache2 :成了~ sudo systemctl status apache2
【小白再次温馨提示】按q退出那个绿绿的或者红红的状态(因为我就是小白(;´д`)ゞ)