2016-07-19 19 views
1

AWS EC2 ubuntuでホストされているlaravel V5.1.11サイトでngnixというサーバーを使用しています。私は正常にサイトを設定しましたが、私の内側のページは機能しません。laravel内部のページがAWS EC2 Nginxで動作していません

Configがある:

server { 
    listen 82; 
    server_name www.example.com; 
    return 301 https://$server_name$request_uri; 
} 

server { 
    listen 83; 
    server_name www.example.com; 
    root /home/in4matic/example-website-dev/public; 



    location/{ 
      index index.php; 
      try_files $uri $uri/ /index.php?q=$uri&$args; 

    } 


    location ~* \.php$ { 
     fastcgi_index index.php; 
     fastcgi_pass 127.0.0.1:9000; 
     include   fastcgi_params; 
     #fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param SCRIPT_FILENAME $document_root/index.php; 
     #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_NAME  $fastcgi_script_name; 

    } 
} 

私はそれをどのように修正することができます。

+0

nginxの設定を含める必要があります。 .htaccessファイルも追加できます。共有ホストからlaravelアプリケーションを移行するのはちょっと難しいです。共有ホストでlaravelを起動して実行するために行われたいくつかの「調整」を削除する必要があるからです。 –

+0

ここで 'nginx configuration'を含める必要があります –

+0

あなたの質問には何が間違っているのかを見て、あなたの問題やいくつかのガイダンスの解決策を提供してください。 –

答えて

0

laravel appをapacheからnginxに移動するには多くの変更が必要ありませんが、laravelは.htaccessファイルを使用してnginxで動作しないURL書き換えを行うため、nginx configファイルを変更する必要があります。ここに私の設定ファイルの例があります:

server { 
    listen  80; 
    server_name your-website.com; 

    # note that these lines are originally from the "location /" block 
    root /usr/share/nginx/html; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ /index.php?$args; 
    } 

    location ~ \.php$ { 
     try_files $uri /index.php =404; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass 127.0.0.1:9000 # Keep this as per your old config; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
    } 

} 

私はすべてのlaravelアプリケーションにこの設定を使っています。

とストレージディレクトリが適切な権限を持っていることを確認してください。

関連する問題