【发布时间】:2016-04-16 03:51:32
【问题描述】:
我使用 laravel 5.1 和 nginx/1.8 这是我第一次使用 Nginx 服务器
当我尝试访问 laravel 应用主页时,路线运行良好
get('/', function () {
return view('welcome');
});
但是当我尝试访问任何其他页面时
get('/home', function () {
return 'Home Page';
// Or Blade Page
//return view('home');
});
Nginx 返回
我在/etc/nginx/nginx.conf上的设置文件
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
#root /usr/share/nginx/html;
root /var/www/nginx/html;
index index.php index.html index.htm;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
更新
/var/log/nginx/error.log的最后结果
#3 /var/www/nginx/html/laravel/vendor/laravel/framework/src/Illuminate /Foundation/Exceptions/Handler.php(49): Monolog\Logger->错误(对象(Symfo 2016/01/11 22:59:38 [错误] 22510#0: *31 "/var/www/nginx/html/laravel/" 的目录索引被禁止,客户端:127.0.0.1,服务器:_,请求: “GET /laravel/ HTTP/1.1”,主机:“localhost”
注意:html/laravel -> laravel 是应用名称
有什么建议吗?
【问题讨论】:
标签: php laravel nginx laravel-5.1