RASBERRY PI apache啟動錯誤

安裝apache了我的apache無法啟動

sudo service apache2 restart

錯誤

‘[….] Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed because the control process exited with error code.See “systemctl status apache2.service” and “journalctl -xe” for details. failed!

所以我輸入stemctl status apache2.service’它出現了以下錯誤!

● apache2.service – The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2021-10-12 00:56:56 JST; 37s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 30146 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)Oct 12 00:56:56 raspberrypi apachectl[30146]: AH00558: apache2: Could not reliably determine the server’s fully qualifOct 12 00:56:56 raspberrypi apachectl[30146]: (98)Address already in use: AH00072: make_sock: could not bind to addresOct 12 00:56:56 raspberrypi apachectl[30146]: (98)Address already in use: AH00072: make_sock: could not bind to addresOct 12 00:56:56 raspberrypi apachectl[30146]: no listening sockets available, shutting downOct 12 00:56:56 raspberrypi apachectl[30146]: AH00015: Unable to open logsOct 12 00:56:56 raspberrypi apachectl[30146]: Action ‘start’ failed.Oct 12 00:56:56 raspberrypi apachectl[30146]: The Apache error log may have more information.Oct 12 00:56:56 raspberrypi systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILUREOct 12 00:56:56 raspberrypi systemd[1]: apache2.service: Failed with result ‘exit-code’.Oct 12 00:56:56 raspberrypi systemd[1]: Failed to start The Apache HTTP Server.

KEYWORD (98)Address already in use

先要找出那個process佔有了port80

lsof -i :http,https

找出process id霸佔了port 80, 再用ps指出來

殺掉80端口的 process

sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill

問題點

一般http server 用的都是80 port。除了Apache 以外,還安裝了nginx,nginx也設在80

所以產生衝突產生。如要共存,解決方式就是換不同的service port 。

nginx更換端口

修改 /etc/nginx/sites-enabled 中的 default 文件

sudo nano /etc/nginx/sites-available/default

listen   8080;## listen for ipv4; this line is default and implied

完成!!

魔鏡教程 資源 小锋学长生活大爆炸

https://www.bilibili.com/video/BV1cV411r7xG/?spm_id_from=333.788.recommend_more_video.3

https://blog.csdn.net/sxf1061700625/article/details/109697345

http://xfxuezhang.cn/WEB/