免费注册 查看新帖 |

Chinaunix

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

[服务应用] nginx服务正常启动-无法访问web [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-01-09 19:17 |只看该作者 |倒序浏览
本帖最后由 MoreGon 于 2016-01-09 19:21 编辑

环境:centos6.5 nginx php
之前服务器是正常,可以正常访问web,突然访问不了且没有错误提示
nginx服务是正常启动的,我查了error.log没报错,access.log之前有大量访问我清除之后,自己尝试各种访问服务器地址,access.log都没有记录
也不是防火墙的问题,防火墙已经关闭了
求帮助!

ngin.conf配置如下:

user www;
worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

error_log  /srv/logs/nginx/error.log debug;
pid /srv/logs/nginx/nginx.pid;

worker_rlimit_nofile 65535;
events {
    use epoll;
    worker_connections 65535;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    charset  utf-8;
error_log logs/nginx_error.log  debug;
server {
        listen       80;
        server_name  erp.ysl.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /opt/nginx/html;
            index  index.html index.htm index.php;
        }

        location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
          root   html;
        }
    }

    keepalive_timeout 60;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types   text/plain application/x-javascript text/css application/xml;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout    300;
    fastcgi_read_timeout    300;
    fastcgi_buffer_size     64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;  

    open_file_cache max=102400 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;

    client_max_body_size 128m;
    client_header_buffer_size 4k;
    large_client_header_buffers  4 4k;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include site/*.conf;
}

include site/*.conf; 配置如下

server {
    listen       80;
    index  index.html index.php;
    root /srv/www/erp;

    location ~ \.git {
        return 500;
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }

    location ~ ^/shopadmin {
        rewrite ^/(.*)$ /index.php/$1 last;
    }

    location ~ \.php {
        fastcgi_pass unix:/srv/logs/php/php-cgi.sock;
        include fastcgi.conf;
        include path_info.conf;
    }
   
    location ~ \.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
        expires      30d;
    }

    access_log /srv/logs/nginx/access.log;
}

论坛徽章:
0
2 [报告]
发表于 2016-01-09 20:13 |只看该作者
端口在系统中还存在?

论坛徽章:
0
3 [报告]
发表于 2016-01-09 20:21 |只看该作者
回复 2# QaSanil


    80?

存在啊,之前都正常在跑的

论坛徽章:
8
操作系统版块每日发帖之星
日期:2016-01-11 06:20:00操作系统版块每日发帖之星
日期:2016-01-12 06:20:00每日论坛发贴之星
日期:2016-01-12 06:20:00操作系统版块每日发帖之星
日期:2016-01-13 06:20:00每日论坛发贴之星
日期:2016-01-13 06:20:00操作系统版块每日发帖之星
日期:2016-01-14 06:20:0015-16赛季CBA联赛之广夏
日期:2016-01-16 23:04:54IT运维版块每日发帖之星
日期:2016-01-17 06:20:00
4 [报告]
发表于 2016-01-09 21:25 |只看该作者
菜鸟来就解
http://bbs.chinaunix.net/thread-4232928-1-1.html
这是我刚刚发的,求解惑

求职 : Linux运维
论坛徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亚洲杯之约旦
日期:2015-04-05 20:08:292015年亚洲杯之澳大利亚
日期:2015-04-09 09:25:552015年亚洲杯之约旦
日期:2015-04-10 17:34:102015年亚洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亚洲杯之日本
日期:2015-04-16 16:28:552015年亚洲杯纪念徽章
日期:2015-04-27 23:29:17操作系统版块每日发帖之星
日期:2015-06-06 22:20:00操作系统版块每日发帖之星
日期:2015-06-09 22:20:00
5 [报告]
发表于 2016-01-09 21:43 |只看该作者
问题有几个
  location / {
            root   /opt/nginx/html;
            index  index.html index.htm index.php;
        }

        location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;  未填路径
          include fastcgi_params;
        }

               
--------------------------------------------------
                include site/*.conf;,如果有多个vhost,我们一般全部放在site/*.conf路径下,不会在nginx.conf里定义vhost
        server {
        listen       80;
        server_name  erp.ysl.com;
-------------------------------------------------       
你有两个vhost,都用80端口,会端口占用
                server {
        listen       80;
        server_name  erp.ysl.com;
               
                server {
    listen       80;
    index  index.html index.php;
    root /srv/www/erp;
        --------------------------------------------------------------------
       
        location ~ \.git$ {  加$表示结尾
        return 500;
    }
       
----------------------------------------------------
又用socket又用tcp/IP,在php-fpm很难对应资源池
        location ~ \.php {
        fastcgi_pass unix:/srv/logs/php/php-cgi.sock;
               
                 location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;


这几个问题未解决,访问不了就不不奇怪了

求职 : Linux运维
论坛徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亚洲杯之约旦
日期:2015-04-05 20:08:292015年亚洲杯之澳大利亚
日期:2015-04-09 09:25:552015年亚洲杯之约旦
日期:2015-04-10 17:34:102015年亚洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亚洲杯之日本
日期:2015-04-16 16:28:552015年亚洲杯纪念徽章
日期:2015-04-27 23:29:17操作系统版块每日发帖之星
日期:2015-06-06 22:20:00操作系统版块每日发帖之星
日期:2015-06-09 22:20:00
6 [报告]
发表于 2016-01-09 21:45 |只看该作者
本帖最后由 lyhabc 于 2016-01-09 21:45 编辑

错误日志
有php的错误日志,有nginx的,有vhost的访问日志
/usr/local/php-fpm/var/log/phperror.log
/usr/local/nginx/logs/nginx_error.log
/usr/local/nginx/logs/wwwop.cn.log  
/usr/local/php-fpm/var/log/php-fpm.log

论坛徽章:
0
7 [报告]
发表于 2016-01-09 22:55 |只看该作者
回复 5# lyhabc

修改后这样:  还是不行,大大帮忙再看看
user www;
worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

error_log  /srv/logs/nginx/error.log debug;
pid /srv/logs/nginx/nginx.pid;

worker_rlimit_nofile 65535;
events {
    use epoll;
    worker_connections 65535;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    charset  utf-8;

    keepalive_timeout 60;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types   text/plain application/x-javascript text/css application/xml;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout    600;
    fastcgi_read_timeout    600;
    fastcgi_buffer_size     64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;  

    open_file_cache max=102400 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;

    client_max_body_size 128m;
    client_header_buffer_size 4k;
    large_client_header_buffers  4 4k;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include site/*.conf;
}

    include site/*.conf;
server {
    listen       80;
    index  index.html index.php;
    root /srv/www/erp;

    location ~ \.git$ {
        return 500;
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }

    location ~ ^/shopadmin {
        rewrite ^/(.*)$ /index.php/$1 last;
    }

    location ~ \.php {
        fastcgi_pass unix:/srv/logs/php/php-cgi.sock;
        include fastcgi.conf;
        include path_info.conf;
    }
   
    location ~ \.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
        expires      30d;
    }

    access_log /srv/logs/nginx/access.log;
}


   

求职 : Linux运维
论坛徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亚洲杯之约旦
日期:2015-04-05 20:08:292015年亚洲杯之澳大利亚
日期:2015-04-09 09:25:552015年亚洲杯之约旦
日期:2015-04-10 17:34:102015年亚洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亚洲杯之日本
日期:2015-04-16 16:28:552015年亚洲杯纪念徽章
日期:2015-04-27 23:29:17操作系统版块每日发帖之星
日期:2015-06-06 22:20:00操作系统版块每日发帖之星
日期:2015-06-09 22:20:00
8 [报告]
发表于 2016-01-10 09:32 |只看该作者
你vi一个1.php
vim /usr/local/nginx/html/1.php
增加
<?php
phpinfo();
?>

测试: curl  localhost/1.php
还有,最好把这段话放在一个单独的vhost文件里面,好排错
server {
    listen       80;
    index  index.html index.php;
    root /srv/www/erp;

    location ~ \.git$ {
        return 500;
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }

    location ~ ^/shopadmin {
        rewrite ^/(.*)$ /index.php/$1 last;
    }

    location ~ \.php {
        fastcgi_pass unix:/srv/logs/php/php-cgi.sock;
        include fastcgi.conf;
        include path_info.conf;
    }
   
    location ~ \.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
        expires      30d;
    }

    access_log /srv/logs/nginx/access.log;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP