2016-06-24 11 views
1

Yii2アプリケーションをApacheを使用してnginxに移動しようとしました。私は単一のドメイン上でYii2アドバンストテンプレートを使用していますので、this linkの解決策に従い、frontend/webからbackend/webへのシンボリックリンクを作成します。このソリューションは、私がApacheを使用しているときにうまく動作しますが、nginxを使用しようとするとバックエンドアプリを開くことができません。ApacheからNginxへのYii2の移行 - バックエンドアプリケーションで失敗しました

フロントエンドアプリが正常に動作しますが、私はapp.local/belakangを使用してバックエンドのアプリケーションを開こうとすると、それはフロントエンドアプリで立ち往生ので、ここでは[yii\web\HttpException:404] exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "belakang/site/login".'

を与え、まだapp.local/belakang/site/loginにリダイレクトされますが、シンボリックリンクであるI frontend/webディレクトリにあります。

lrwxrwxrwx 1 vagrant vagrant 17 Jun 24 14:03 belakang -> ../../backend/web 

、これは私が使用しnginxのバーチャルホストの設定です:

server { 
    charset utf-8; 
    client_max_body_size 128M; 

    listen 80; ## listen for ipv4 

    server_name app.local; 
    root  /var/www/html/frontend/web; 
    index  index.php; 

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

    # deny accessing php files for the /assets directory 
    location ~ ^/assets/.*\.php$ { 
     deny all; 
    } 

    location ~ \.php$ { 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     try_files $uri =404; 
    } 

    location ~* /\. { 
     deny all; 
    } 
} 

誰でもapp.local/belakangからバックエンドアプリを開くことができますか?

+0

下の設定を追加することにより、修正、それ自身を、私は、バックエンドのための私のyii2高度なアプリケーションのための特別なサブドメインを作ってきました。サブフォルダの代わりに管理者のために別々のサブドメインを持つ方が良いと思います。 – Taras

答えて

0

location ^~ /belakang { 
     try_files $uri $uri/ /belakang/index.php$is_args$args; 

     location ~ /\.(ht|svn|git) { 
      deny all; 
     } 

     location ~ \.php$ { 
      include fastcgi_params; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_pass unix:/var/run/php/php5-fpm.sock; 
      try_files $uri =404; 
     } 
    } 
関連する問題