环境:centos7+php+mysql+openresty,目前测试 systemctl status openresty ,systemctl status php-fpm,systemctl status mysql 都 active,正常的状态。
目前:
root 3348 1 0 00:13 ? 00:00:05 php-fpm: master process (/etc/php-fpm.conf) apache 3351 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3352 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3353 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3354 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3355 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3356 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3357 3348 0 00:13 ? 00:00:00 php-fpm: pool www apache 3358 3348 0 00:13 ? 00:00:00 php-fpm: pool www root 18518 18497 0 23:32 pts/1 00:00:00 grep --color=auto php-fpm
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 28071 /var/lib/mysql/mysql.sock unix 3 [ ] STREAM CONNECTED 11800
unix 3 [ ] STREAM CONNECTED 11801 /run/systemd/journal/stdout
贴出自己的 nginx.conf 和 error.log 粘贴如下:
#user root; worker_processes 1;
#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;
#pid logs/nginx.pid;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; client_max_body_size 8m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 2m; #缓冲区代理缓冲用户端请求的最大字节 gzip on; #WAF lua_shared_dict limit 50m; lua_shared_dict guard_dict 100m; lua_shared_dict dict_captcha 70m; lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua"; init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua"; access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua"; server { listen 127.0.0.1; server_name mywebsitedomain.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.php index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}
}
/usr/local/openresty/nginx/logs/error.log
2018/06/26 21:27:10 [alert] 740#740: *7927 open socket #10 left in connection 12
2018/06/26 21:27:10 [alert] 740#740: *7926 open socket #3 left in connection 13
2018/06/26 21:27:10 [alert] 740#740: aborting
![]() | 1 1daydayde 2018-06-28 08:09:32 +08:00 via iPhone access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua"; 放在 http 底下会不会有问题?你的 waf 看着像 httpguard 建议把 nginx 杀掉再启动看看 |
![]() | 2 kmdd33 OP @0312birdzhang systemctl status openresty 正常啊现在 |
![]() | 3 kmdd33 OP @0312birdzhang 请问 nginx 的 error.log 只能显示到 6.26 号,没有昨天和今天的错误日志 |
4 ytlm 2018-06-28 09:39:10 +08:00 debug 日志打开看一下喽, |
![]() | 5 torbrowserbridge 2018-06-28 09:42:07 +08:00 把 lua 那几行注释掉试试 |
![]() | 6 kmdd33 OP @torbrowserbridge 注释掉也不行 |
![]() | 8 kmdd33 OP @0312birdzhang @ytlm # ps -ef |grep nginx root 19205 1 0 00:16 ? 00:00:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf nginx 19364 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19365 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19366 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19367 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19368 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19369 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19370 19363 0 00:20 ? 00:00:00 php-fpm: pool www nginx 19371 19363 0 00:20 ? 00:00:00 php-fpm: pool www root 19989 19205 0 01:08 ? 00:00:00 nginx: worker process root 25860 25839 0 09:49 pts/0 00:00:00 grep --color=auto nginx |
![]() | 9 banksiae 2018-06-28 17:53:39 +08:00 openresty, lua, waf ? |
![]() | 11 defunct9 2018-06-28 19:42:56 +08:00 via iPhone 开 ssh,让我上去试试 |
![]() | 13 kmdd33 OP reload openresty 后 # lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 32255 root 6u IPv4 170338 0t0 TCP localhost:http (LISTEN) nginx 32332 root 6u IPv4 170338 0t0 TCP localhost:http (LISTEN) |
![]() | 14 kmdd33 OP 头疼到现在 |
![]() | 15 sajesemuy 2018-06-29 09:17:11 +08:00 @kmdd33 listen 127.0.0.1:80? 你是在这台服务器上 curl http://127.0.0.1 出现 502 ? |
![]() | 16 kmdd33 OP 同意谢谢各位。在 stackoverflow 上面找到了答案: 解决步骤: 1.在 nginx.conf 中把 error_log and pid 前面的注释去掉。 就像这样,方便得出正确的 error.log user root; worker_processes 1; #error_log logs/error.log; error_log logs/error.log debug; #error_log logs/error.log info; pid logs/nginx.pid; 2.http{}里面的 80 端口正确配置方式是: listen 80; listen [::]:80 default_server; 3.检查哪个 pid 占用了 80 端口:809 这个进程占用了 80 端口 # sudo netstat -tulpn | grep --color :80 tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 809/nginx: master p [root@li1382-238 ~]# sudo kill -2 809 (这个命令很重要) [root@li1382-238 ~]# sudo netstat -tulpn | grep --color :80 [root@li1382-238 ~]# openresty [root@li1382-238 ~]# openresty -t # netstat -antp 这个命令也可以查出来哪个端口占用了 80 端口。 然后重启:openresty |