質問
セットアップしようとしています ララヴェル 操作するPHPフレームワーク nginx. 。これが私のディレクトリ構造です:
/project
/application
/laravel
/public
index.php
/legacy
/index.php
/stylesheets
default.css
基本的に私が持っているものは標準です ララヴェル w/ aをダウンロードします legacy
私の非MVCプロジェクトからすべてのファイルを保持するフォルダーがスローされます。
要求されたページ/ファイルがレガシー内に存在するかどうかを最初に確認するには、nginxが必要です。もしそうなら、それを使用したいと思います。そうでなければ、私はララヴェルに戻りたい index.php
にあるファイル project/public/
.
Nginx構成に関しては専門家ではないので、提供できるヘルプが最も高く評価されます。
解決
server {
server_name .laravel.dev;
root /home/tamer/code/laravel/public;
index index.php index.html;
#browse folders if no index file
autoindex on;
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# enforce NO www
if ($host ~* ^www\.(.*))
{
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}
# canonicalize codeigniter url end points
# if your default controller is something other than "welcome" you should change the following
if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
{
rewrite ^(.*)$ / permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# catch all
error_page 404 /index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php.socket;
fastcgi_index index.php;
#include fastcgi_params;
include /home/tamer/code/nginx/fastcgi_params;
}
access_log /home/tamer/code/laravel/storage/logs.access.log;
error_log /home/tamer/code/laravel/storage/logs.error.log;
}
所属していません StackOverflow