zhangjd0952 发表于 2017-6-6 11:16:30

LNMP安装Yii2.0 basic框架失败

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


502 Bad Gatewaynginx

报错日志
2017/06/06 11:01:12 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

# ll
drwxrwxrwx 2 www www4096 Feb2 00:55 assets
drwxrwxrwx 2 www www4096 Feb2 00:55 css
-rwxrwxrwx 1 www www   318 Feb2 00:55 favicon.ico
-rwxr-xr-x 1 www www   434 Jun5 23:32 index.php
-rwxrwxrwx 1 www www   501 Feb2 00:55 index-test.php
-rwxrwxrwx 1 www www5141 Jun3 17:44 requirements.php
-rwxrwxrwx 1 www www    23 Feb2 00:55 robots.txt



LNMP环境的状态
# 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配置文件
# cat nginx.conf
#user root;
#userwww www;
worker_processes auto;
error_log/home/wwwlogs/nginx_error.logcrit;
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_typeapplication/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_length1k;
      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 \.";

      #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;
}





虚拟主机的配置
# pwd
/usr/local/nginx/conf/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_indexindex.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;
      }
    }

licess 发表于 2017-6-6 20:06:35

回复 1# 的帖子

location ~ \.php$ { 到 } 删除

不清楚每部分的作用不要随便拷贝网上的配置文件
页: [1]
查看完整版本: LNMP安装Yii2.0 basic框架失败