跳到主要内容

宝塔重启 laravel 报403

起因

测试服务器为了方便使用了宝塔面板,因为测试服务器的配置很低,所以会经常卡死。卡死之后需要重新启动服务器,每次重启后的项目(laravel) 都会报403错误。

分析

查看nginx的错误日志,发现了以下错误:

2020/04/22 15:12:40 [emerg] 4185#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2020/04/22 15:12:40 [emerg] 4185#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2020/04/22 15:12:40 [emerg] 4185#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2020/04/22 15:12:40 [emerg] 4185#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2020/04/22 15:12:40 [emerg] 4185#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2020/04/22 15:12:40 [emerg] 4185#0: still could not bind()

这个错误是因为80端口被占用了。

解决

服务器终端执行:

netstat -ntlp|grep 80

找出占用80端口的进程:

tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 1189/nginx: master
tcp6 0 0 :::80 :::
LISTEN 1189/nginx: master

占用80 端口的进程竟然是nginx,我迷惑了......
不管了,kill 掉这个进程,然后再启动Nginx,就解决了。