【问题标题】:Nginx configs for symfony3symfony3 的 Nginx 配置
【发布时间】:2016-03-29 14:17:56
【问题描述】:

我在使用 nginx 时遇到了一些问题。 我在 Symfony3 上创建了新项目。 Config.php 说,一切都很好。 dev_app.php - 也是。 但是当我尝试在没有任何其他路由的情况下打开站点时,例如 sitename.com nginx 返回 403 错误。 当我尝试启动 symfnoy 服务器(bin/console server:start)时,它也是被禁止的。 sitename.com:8000 返回我无法打开此页面。

站点可用配置是

upstream phpfcgi {
    server 127.0.0.1:8000;
}

server {
    listen 80;

    server_name localhost;
    root /home/staging/www/web;

    error_log /home/staging/logs/staging.error.log;
    access_log /home/staging/logs/staging.access.log;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}

我用 crud 添加了新实体,但任何操作都不起作用。 我会很高兴得到任何帮助。谢谢

【问题讨论】:

  • 你查看过 nginx 和 PHP 日志吗?您的目录权限设置正确吗?
  • 你考虑过reading the manual 吗?
  • 是的,我阅读了手册。此代码也不起作用。日志为空
  • 有没有可能 /app.php/$1 应该是 /app.php$1 ?

标签: php nginx symfony


【解决方案1】:

尝试添加

rewrite ^/app\.php/?(.*)$ /$1 permanent;

在任何location 部分之前的server 部分中(例如,在root /home/staging/www/web; 行之后)。

【讨论】:

    猜你喜欢
    • 2016-09-30
    • 2016-09-28
    • 1970-01-01
    • 2016-12-03
    • 2019-01-05
    • 1970-01-01
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多