php - 新的 laravel 安装在 nginx 服务器(Ubuntu)中不起作用

标签 php laravel ubuntu nginx

我刚刚使用新的 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/

相关文章:

php - 使用 PHP 调用 API 的 file_get_contents() 与 curl

php - 在 Laravel 5 中打开 autoload.php 失败

laravel - spatie/laravel-medialibrary 如何获取上传图像的尺寸?

php - Laravel 在 Controller 中使用公共(public)静态函数是不是很糟糕

JAVA_HOME 在 ubuntu 中不工作

java - Ubuntu 上的 Netbeans 不保存面板位置

php - 在达到一定时间之前安全退出应用程序?

php - 如何在android TextView 上查看php脚本的结果

php - 如何在数据库中存储许多图像

ubuntu - 在 ubuntu 上安装软件时依赖性无法满足 libgcrypt11