Php 新的laravel安装在nginx服务器(Ubuntu)中不起作用
我刚刚在我的ubunutu 14.04 lts和fresh laravel项目中设置了nginx web服务器。我的项目名称laravel,当我转到时,我可以看到laravel欢迎页面的显示,但当我创建url进行测试时,它不起作用Php 新的laravel安装在nginx服务器(Ubuntu)中不起作用,php,laravel,ubuntu,nginx,Php,Laravel,Ubuntu,Nginx,我刚刚在我的ubunutu 14.04 lts和fresh laravel项目中设置了nginx web服务器。我的项目名称laravel,当我转到时,我可以看到laravel欢迎页面的显示,但当我创建url进行测试时,它不起作用 Route::get('test', function(){ return 'It is work!!!'; }); 我希望当我去http://localhost/laravel/public/test | http://localhost/la
Route::get('test', function(){
return 'It is work!!!';
});
我希望当我去http://localhost/laravel/public/test | http://localhost/laravel/public/index.php/test
它应该显示这是工作取而代之的是404未找到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;
这是因为文档
root
应该指向public
目录,所以它应该是/usr/share/nginx/html/laravel/public
,并使用http://localhost
。解释得很好。如果你想在你的nginx安装上运行多个网站,我建议你使用像http://laravel.local
,而不是像http://localhost/laravel
。您可以阅读这篇文章,它解释了设置虚拟主机是多么容易。嗨@Bogdan!我真的很感谢你的帮助:)不客气。