我刚刚使用新的 laravel 项目在我的 ubunutu 14.04 lts 中设置了 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
它应该显示 是工作!!! 而不是这个,我得到 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;
}
}
请帮我。我真的很感谢你的帮助。
最佳答案
看起来博格丹已经在评论中回答了这个问题。但是对于其他任何人,请确保将您的文档根目录指向您的 Laravel 项目的/public 目录。
root /usr/you/laravelinstall/public;
关于php - 新的 laravel 安装在 nginx 服务器(Ubuntu)中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36385355/