php - 如何设置文档根目录以使用 Nginx 加载 Laravel 应用程序?

标签 php linux laravel nginx laravel-5

我的网站一直显示 phpinfo();当我降落在它上面时

  • 我的根目录应该是:/home/forge/aveniros/public
  • 我不知道在哪里设置它。
  • 我决定在以下位置配置我的设置:~/etc/nginx/sites-available/default
<小时/>
server {

    listen 80 default_server;
    server_name
    default;
    root / home / forge / aveniros / public;
    index index.html index.htm index.php;

    #
    FORGE SSL(DO NOT REMOVE!)# ssl_certificate;#
    ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf - 8;

    location / {
        try_files $uri $uri / /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log /
        var / log / nginx /
        default -error.log error;

    error_page 404 / index.php;

    location~\.php$ {
        fastcgi_split_path_info ^ (. + \.php)(/.+)$;
            fastcgi_pass unix: /var/run / php5 - fpm.sock; fastcgi_index index.php; include fastcgi_params;
        }

        location~/\.ht {
        deny all;
    }
}
<小时/>

然后,我在保存后运行sudo service nginx restart。 似乎没有任何效果。

有人可以告诉我我在这里做错了什么吗?

最佳答案

您需要将服务器名称设置为_,当前您仅监听对名称默认的请求。

server_name  _;

关于php - 如何设置文档根目录以使用 Nginx 加载 Laravel 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29805404/

相关文章:

laravel - 在 laravel V6.14.0 上安装 Dusk

php - 删除与 Laravel 5.7 模式匹配的 Redis 键

php - 神秘的 2012 年 2 月 10 日未设置为数组

php - 使用 PHP 更新 mysql 数据

javascript - Laravel 和 Jquery Var 长度

linux - Elixir:在 Ubuntu 上安装 Elixir 会终止正在运行的 Couch DB 实例

linux - native KDE 寻找 Qt 5 应用程序

php - PHP 循环内的脚本

php - 如何修复我的表格以防止破坏我的 css div?循环

linux - 服务器修补电子邮件通知 Linux 脚本