如何在Nginx / OpenServer上部署Yii2高级应用程序?

时间:2017-09-01 05:29:14

标签: nginx yii2

我需要使用Yii2高级模板在本地计算机上运行该项目。 当我尝试打开主页面(project.loc /)

时,问题是逻辑异常错误
    LogicException
    The template "E:\OSPanel\domains\project.loc\frontend\views\catalog\index" 
    could not be found at 
    "E:\OSPanel\domains\project.loc\frontend\E:\OSPanel\domains\project.loc\frontend\views\catalog\index.phtml".

404 NOT FOUND页面上有project.loc/staff

申请结构:

project.loc/
  common
  console
  environments
  files
  frontend
  staff
  vendor

OpenServer有一个Nginx基本配置(我把它放在域的根目录下)。我只更改了location /location /staff

#-----------------------------------------------#
# Начало блока конфигурации хоста
#-----------------------------------------------#

server {
    listen         %ip%:%httpport%;
    listen         %ip%:%httpsport% ssl;
    server_name    %host% %aliases%;

    ssl_certificate               "%sprogdir%/userdata/config/cert_files/server.crt";
    ssl_certificate_key           "%sprogdir%/userdata/config/cert_files/server.key";

    #add_header Strict-Transport-Security "max-age=94608000";

    # if ($request_method !~* ^(GET|HEAD|POST)$ ){return 403;}
    location ~ /\. {deny all;}

    location / {
        root       "%hostdir%/frontend/web";
        try_files  $uri /frontend/web/index.php?$args;
        index      index.php index.html index.htm;
    }

    location /staff {
        alias  "%hostdir%/staff/web";
        rewrite  ^(/staff)/$ $1 permanent;
        try_files  $uri /staff/web/index.php?$args;
    }

    location ~ \.php$ {
        root                               "%hostdir%";
        try_files                          $uri =404;
        # if (!-e $document_root$document_uri){return 404;}
        fastcgi_pass                       backend;
        fastcgi_index                      index.php;
        fastcgi_buffers                    4 64k;
        fastcgi_connect_timeout            1s;
        fastcgi_ignore_client_abort        off;
        fastcgi_next_upstream              timeout;
        fastcgi_read_timeout               5m;
        fastcgi_send_timeout               5m;
        fastcgi_param    CONTENT_TYPE      $content_type;
        fastcgi_param    CONTENT_LENGTH    $content_length;
        fastcgi_param    DOCUMENT_URI      $document_uri;
        fastcgi_param    DOCUMENT_ROOT     $document_root;
        fastcgi_param    GATEWAY_INTERFACE CGI/1.1;
        fastcgi_param    HTTPS             $https;
        fastcgi_param    QUERY_STRING      $query_string;
        fastcgi_param    REQUEST_METHOD    $request_method;
        fastcgi_param    REQUEST_URI       $request_uri;
        fastcgi_param    REMOTE_ADDR       $remote_addr;
        fastcgi_param    REMOTE_PORT       $remote_port;
        fastcgi_param    SERVER_ADDR       $server_addr;
        fastcgi_param    SERVER_PORT       $server_port;
        fastcgi_param    SERVER_NAME       $host;
        fastcgi_param    SERVER_PROTOCOL   $server_protocol;
        fastcgi_param    SERVER_SOFTWARE   nginx;
        fastcgi_param    SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        fastcgi_param    SCRIPT_NAME       $fastcgi_script_name;
        fastcgi_param    TMP               "%sprogdir%/userdata/temp";
        fastcgi_param    TMPDIR            "%sprogdir%/userdata/temp";
        fastcgi_param    TEMP              "%sprogdir%/userdata/temp";
    }

    # Подключение веб-инструментов
    #---------------------------------------#
    # <Не изменяйте этот блок конфигурации>
    location /openserver/ {
        root     "%sprogdir%/modules/system/html";
        index    index.php;
        %allow%allow    all;
        allow    127.0.0.0/8;
        allow    ::1/128;
        allow    %ips%;
        deny     all;
        location /openserver/server-status {
            stub_status on;
        }
        location ~ ^/openserver/.*\.php$ {
            root                               "%sprogdir%/modules/system/html";
            fastcgi_pass                       backend;
            fastcgi_index                      index.php;
            fastcgi_buffers                    4 64k;
            fastcgi_connect_timeout            1s;
            fastcgi_ignore_client_abort        off;
            fastcgi_next_upstream              timeout;
            fastcgi_read_timeout               5m;
            fastcgi_send_timeout               5m;
            fastcgi_param    CONTENT_TYPE      $content_type;
            fastcgi_param    CONTENT_LENGTH    $content_length;
            fastcgi_param    DOCUMENT_URI      $document_uri;
            fastcgi_param    DOCUMENT_ROOT     $document_root;
            fastcgi_param    GATEWAY_INTERFACE CGI/1.1;
            fastcgi_param    HTTPS             $https;
            fastcgi_param    QUERY_STRING      $query_string;
            fastcgi_param    REQUEST_METHOD    $request_method;
            fastcgi_param    REQUEST_URI       $request_uri;
            fastcgi_param    REMOTE_ADDR       $remote_addr;
            fastcgi_param    REMOTE_PORT       $remote_port;
            fastcgi_param    SERVER_ADDR       $server_addr;
            fastcgi_param    SERVER_PORT       $server_port;
            fastcgi_param    SERVER_NAME       $host;
            fastcgi_param    SERVER_PROTOCOL   $server_protocol;
            fastcgi_param    SERVER_SOFTWARE   nginx;
            fastcgi_param    SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            fastcgi_param    SCRIPT_NAME       $fastcgi_script_name;
            fastcgi_param    TMP               "%sprogdir%/userdata/temp";
            fastcgi_param    TMPDIR            "%sprogdir%/userdata/temp";
            fastcgi_param    TEMP              "%sprogdir%/userdata/temp";
        }
    }
    # <Не изменяйте этот блок конфигурации/>
    #---------------------------------------#
}

#-----------------------------------------------#
# Конец блока конфигурации хоста
#-----------------------------------------------#

0 个答案:

没有答案