首頁 > php框架 > YII > 主體

nginx不支援yii怎麼辦

藏色散人
發布: 2020-02-03 10:25:27
原創
2673 人瀏覽過

nginx不支援yii怎麼辦

nginx不支援yii怎麼辦? nginx部署yii2的方法

只需要修改nginx.config設定檔內容,在裡面增加server,並且root寫成index.php檔案在的目錄下就可以

還要設定config/web.php裡的cookieValidationKey值,以及一些目錄的存取權限需要設定成777

nginx設定檔內容

#user  nobody;
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;
    #gzip  on;
    server {
        listen       80;
        server_name  localhost;
        #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  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
            include         fastcgi.conf;
        }
        # 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;
    #    }
    #}
    #yi正mjh graduation project config
    server {
        charset utf-8;
        client_max_body_size 128M;
           
        listen 8080;
        server_name www.mjh.com;
        root    /var/www/mjhGraduation/web;
        index   index.php;
        access_log      /var/www/mjhGraduation/access.log main;
        error_log       /var/www/mjhGraduation/error.log;
        location /{
                 # Redirect everything that isn't a real file to index.php
                try_files $uri $uri/ /index.php?args;
        }
        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_pass 127.0.0.1:9000;
                try_files $uri = 404;
        }
        error_page 404 /404.html;
        location ~ /\.(ht|svn|git){
                deny all;
        }
    }
    #gsh graduation project config
    server {
        charset utf-8;
        client_max_body_size 128M;
           
        listen 8088;
        server_name www.mjh.com;
        root    /var/www/gshGraduation/web;
        index   index.php;
        access_log      /var/www/gshGraduation/access.log main;
        error_log       /var/www/gshGraduation/error.log;
        location /{
                 # Redirect everything that isn't a real file to index.php
                try_files $uri $uri/ /index.php?args;
        }
        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_pass 127.0.0.1:9000;
                try_files $uri = 404;
        }
        error_page 404 /404.html;
        location ~ /\.(ht|svn|git){
                deny all;
        }
    }
    # 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;
    #    }
    #}
}
登入後複製

相關文章教學推薦:yii教學

以上是nginx不支援yii怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板