我刚刚用全新的laravel项目在我的ubunutu 14.04Lts中设置了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;
}
}
请帮帮我。我真的很感谢你的帮助。
看起来Bogdan已经在评论中回答了这个问题。但对于其他人,请确保将您的文档根指向Laravel项目的/public目录。
root /usr/you/laravelinstall/public;