免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4257 | 回复: 0
打印 上一主题 下一主题

[Web] nginx1.10.3出现502 Bad Gateway只重重启计算机才能正常 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-03-30 20:05 |只看该作者 |倒序浏览
本帖最后由 eremiter 于 2017-03-31 21:38 编辑

环境centos7 + php5.5 + mysql5.7 + nginx1.10.3


systemctl status php-fpmsystemctl status nginx
systemctl status firewalld都是运行中
systemctl restart php-fpmsystemctl restart nginx
systemctl restart firewalld
重启3个服务,依然无法运行
===================
网站只有几个人访问,目前经常上传图片,每天就会死一次,只有reboot,其它一切重启服务无效
当php出现无法502 bad gateway,html的网页仍正常访问
看了错误,似乎nginx配置有问题,出现路径找不到,但重启电脑就正常了,重启服务无法正常[code brush:bash;toolbar:false;]try_files $uri = 404;[/code]
上面的配置要如何写
配置php-fpm
[code brush:bash;toolbar:false;][www]
listen = 127.0.0.1:9000
      
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
request_terminate_timeout = 0
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache[/code]

nginx配置如下:/etc/nginx/nginx.conf
[code brush:bash;toolbar:false;]user  nginx;
worker_processes  1;
      
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
      
      
events {
   use epoll;
   worker_connections  1024;
}
      
      
http {
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
      
    include       /etc/nginx/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  /var/log/nginx/access.log  main;
      
    sendfile        on;
    #tcp_nopush     on;
      
    keepalive_timeout  65;
      
    gzip  on;
      
    client_max_body_size 8M;
    client_body_buffer_size 128k;
    include /etc/nginx/conf.d/*.conf;
}[/code]
/etc/nginx/conf.d/default.conf


[code brush:bash;toolbar:false;]server {
    listen       80;#端口
    server_name localhost;
      
    root /home/wwwroot/erpbaas; # 网站根目录
    index index.php index.html index.htm;#默认的index
      
    # 建议放内网
    # allow 192.168.0.0/24;
    # deny all;
      
    location / {
      
        if (!-e $request_filename) {
         rewrite ^/(.*)$ /index.php?$1 last;
        #去除url中的index.php 不需要可以不写
      
        }
  }
      
    location ~ \.php$ {
        try_files $uri = 404;
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}[/code]
/etc/nginx/conf.d/fjqinhan.cn.conf
[code brush:bash;toolbar:false;]server {
    listen       80;#端口
    server_name www.fjqinhang.cn fjqinhan.cn;
    root /home/wwwroot/fjqinhan; # 网站根目录
    index index.html index.php;#默认的index
      
    # 建议放内网
    # allow 192.168.0.0/24;
    # deny all;
      
    location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
      
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
      
    location / {
      
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?$1 last;
            #去除url中的index.php 不需要可以不写
      
        }
   }
}[/code]
/etc/php.ini配置
[code brush:bash;toolbar:false;]engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 60
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 6M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
sendmail_path = /usr/sbin/sendmail -t -i
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Assertion]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1[/code]
日志错误/var/log/nginx
[code brush:bash;toolbar:false;]2017/03/30 17:35:21 [error] 5859#5859: *28 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 111.201.202.83, server: www.fjqinhan.cn, request: "GET /forum.php?mod=post&action=newthread&fid=177 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "fjqinhan.cn", referrer: "http://fjqinhan.cn/forum.php?mod=post&action=newthread&fid=177"
2017/03/30 17:35:21 [error] 5859#5859: *28 upstream prematurely closed connection while reading response header from upstream, client: 111.201.202.83, server: www.fjqinhan.cn, request: "POST /forum.php?mod=post&action=newthread&fid=177&extra=&topicsubmit=yes&inajax=1 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "fjqinhan.cn", referrer: "http://fjqinhan.cn/forum.php?mod=post&action=newthread&fid=177&extra=&topicsubmit=yes&inajax=1"
2017/03/30 17:36:37 [error] 5859#5859: *32 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 83.143.240.9, server: www.fjqinhan.cn, request: "GET /member.php?mod=registerfj&inajax=1 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "fjqinhan.cn", referrer: "http://fjqinhan.cn/"
2017/03/30 17:37:03 [error] 5859#5859: *34 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 27.156.0.149, server: www.fjqinhan.cn, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.fjqinhan.cn"
2017/03/30 17:37:09 [error] 5859#5859: *34 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 27.156.0.149, server: www.fjqinhan.cn, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.fjqinhan.cn"
2017/03/30 17:51:57 [error] 859#859: *63 open() "/home/wwwroot/fjqinhan404" failed (2: No such file or directory), client: 181.214.212.98, server: www.fjqinhan.cn, request: "GET /logging.php?action=login HTTP/1.1", host: "fjqinhan.cn", referrer: "http://fjqinhan.cn/member.php?mod=registerfj"
2017/03/30 18:22:38 [error] 859#859: *234 open() "/home/wwwroot/fjqinhan404" failed (2: No such file or directory), client: 114.37.242.64, server: www.fjqinhan.cn, request: "GET /logging.php?action=login HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/member.php?mod=registerfj&inajax=1"
2017/03/30 19:03:34 [warn] 859#859: *681 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 27.156.0.149, server: www.fjqinhan.cn, request: "POST /forum.php?mod=group&action=manage&op=group&fid=329 HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=group&action=manage&fid=329"
2017/03/30 19:07:39 [warn] 859#859: *729 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 27.156.0.149, server: www.fjqinhan.cn, request: "POST /forum.php?mod=group&action=manage&op=group&fid=330 HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=group&action=manage&fid=330"
2017/03/30 19:08:46 [warn] 859#859: *742 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000003, client: 27.156.0.149, server: www.fjqinhan.cn, request: "POST /forum.php?mod=group&action=manage&op=group&fid=330 HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=group&action=manage&fid=330"
2017/03/30 19:09:08 [warn] 859#859: *742 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000004, client: 27.156.0.149, server: www.fjqinhan.cn, request: "POST /forum.php?mod=group&action=manage&op=group&fid=330 HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=group&action=manage&fid=330"
2017/03/30 19:11:29 [error] 859#859: *808 open() "/home/wwwroot/fjqinhan404" failed (2: No such file or directory), client: 27.156.0.149, server: www.fjqinhan.cn, request: "GET /images/portal.php HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=post&action=newthread&fid=330"
2017/03/30 19:18:44 [error] 859#859: *851 open() "/home/wwwroot/fjqinhan404" failed (2: No such file or directory), client: 27.156.0.149, server: www.fjqinhan.cn, request: "GET /images/portal.php HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=post&action=newthread&fid=331"
2017/03/30 19:18:45 [error] 859#859: *851 open() "/home/wwwroot/fjqinhan404" failed (2: No such file or directory), client: 27.156.0.149, server: www.fjqinhan.cn, request: "GET /images/portal.php HTTP/1.1", host: "www.fjqinhan.cn", referrer: "http://www.fjqinhan.cn/forum.php?mod=post&action=newthread&fid=331"[/code][code brush:bash;toolbar:false;]2017/03/29 23:57:22 [error] 1253#1253: *1041 open() "/home/wwwroot/fjqinhang404" failed (2: No such file or directory), client: 140.205.201.31, server: www.fjqinhan.cn, request: "GET /cn/images/portal.php HTTP/1.1", host: "www.fjqinhan.cn"[/code]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP