[英]Fresh laravel installation not work in nginx server (Ubuntu)
我刚刚在我的 ubunutu 14.04 lts 中使用新的 Laravel 项目设置了 nginx Web 服务器。 我的项目名称laravel ,当我转到http://localhost/laravel/public/ 时,我可以看到 laravel 欢迎页面显示,但是当我创建一个 url 来测试它时,它不起作用。
Route::get('test', function(){
return 'It is work!!!';
});
我希望当我去http://localhost/laravel/public/test | http://localhost/laravel/public/index.php/test
http://localhost/laravel/public/test | http://localhost/laravel/public/index.php/test
它应该显示它是工作!!! 而不是这个,我得到404 Not Found nginx/1.4.6 (Ubuntu)
。 我不知道有什么问题? 我的机器上安装了php7 ubuntu 1.4.6
。
这里是nginx配置->
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {
#try_files $uri $uri/ =404;
try_files $uri/ $uri /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
请帮我。 我真的很感谢你的帮助。
看起来 Bogdan 已经在评论中回答了这个问题。 但是对于其他人,请确保将您的文档根目录指向 Laravel 项目的 /public 目录。
root /usr/you/laravelinstall/public;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.