VPS侦探论坛

 找回密码
 注册
查看: 3600|回复: 1

LNMP安装Yii2.0 basic框架失败

[复制链接]
发表于 2017-6-6 11:16:30 | 显示全部楼层 |阅读模式

浏览器访问http://shop.imooc.com/          502错误,不知配置文件哪配置错了,求高手指点,谢谢!!


502 Bad Gatewaynginx

报错日志
2017/06/06 11:01:12 [error] 4954#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.220, server: shop.imooc.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "shop.imooc.com"




Yii2.0框架的目录
/home/wwwroot/basic/web

[root@zjd web]# ll
drwxrwxrwx 2 www www  4096 Feb  2 00:55 assets
drwxrwxrwx 2 www www  4096 Feb  2 00:55 css
-rwxrwxrwx 1 www www   318 Feb  2 00:55 favicon.ico
-rwxr-xr-x 1 www www   434 Jun  5 23:32 index.php
-rwxrwxrwx 1 www www   501 Feb  2 00:55 index-test.php
-rwxrwxrwx 1 www www  5141 Jun  3 17:44 requirements.php
-rwxrwxrwx 1 www www    23 Feb  2 00:55 robots.txt



LNMP环境的状态
[root@zjd vhost]# lnmp status
nginx (pid 3618 3617 3615 3614 3613) is running...
php-fpm is runing!
SUCCESS! MySQL running (4144)

Nginx Virtualhost list:
shop.imooc.com





Nginx配置文件
[root@zjd conf]# cat nginx.conf
#user root;
#user  www www;
worker_processes auto;
error_log  /home/wwwlogs/nginx_error.log  crit;
pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

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

        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 120;

        tcp_nodelay on;

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

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        #limit_conn_zone $binary_remote_addr zone=perip:10m;
        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

        server_tokens off;
        access_log off;

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
include vhost/*.conf;
}





虚拟主机的配置
[root@zjd vhost]# pwd
/usr/local/nginx/conf/vhost

[root@zjd vhost]# cat shop.imooc.com.conf
server {
    listen 80;
    server_name shop.imooc.com;
    root /home/wwwroot/basic/web;
    index index.php;
    access_log /home/wwwroot/basic/web/access.log;
    error_log  /home/wwwroot/basic/web/error.log;


    include enable-php.conf;



    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }



    location ~ \.php$ {
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                #include fastcgi.conf;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                try_files $uri =404;

        }


    location ~* /\. {
            deny all;
        }




    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                expires      30d;
        }

    location ~ .*\.(js|css)?$ {
                expires      12h;
        }


    location ~ /.svn/ {
                deny all;
        }
    }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-6-6 20:06:35 | 显示全部楼层

回复 1# 的帖子



location ~ \.php$ { 到 } 删除

不清楚每部分的作用不要随便拷贝网上的配置文件
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-17 18:35 , Processed in 0.025433 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表