【问题标题】:Symfony 3.4, apache 2, ubuntu 16, php 7.2 - 500 errorSymfony 3.4、apache 2、ubuntu 16、php 7.2 - 500 错误
【发布时间】:2018-01-09 17:52:35
【问题描述】:

我尝试在 app.php 中使用 die() 进行调试,但我看到这一行出现错误。在此行脚本起作用之前。

$response = $kernel->handle($request);

检查日志:

   tail /var/log/apache2/error.log

里面没有数据。在检查之前,我删除了这个文件并创建了它,所以它是空的。

虚拟主机:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port t$
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName 178.62.70.115

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/symfony_3_subscribers_in_file_demo/web

    <Directory "/var/www/symfony_3_subscribers_in_file_demo/web">
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

如果我去 app_dev.php,那么我得到

您无权访问此文件。检查 app_dev.php 了解更多信息 信息。

我已经清除了这里所说的缓存:

Symfony 3 Apache 500 Internal Server Error

还有什么地方可以寻找问题?顺便说一句,在我的开发机器上它是一样的 - app.php 也给出 500 错误。只有 app_dev.php 有效。

更新

回答评论 - 日志和缓存目录是否可写:

drwxrwxr-x 4 darius darius  4096 Jan  8 10:02 cache
drwxrwxr-x 2 darius darius  4096 Jan  8 10:02 logs

由于每个都有一个减号,因此它们是部分可写的。

【问题讨论】:

  • var/logsvar/cache 等目录是否可写?
  • @ArtOsi - 部分是的。也许这就足够了。 symfony 安装脚本不是没有处理权限吗?
  • 在 3.x 版本中不,您已设置权限 chmod 777 -R var/log/ 或其他内容

标签: php apache symfony


【解决方案1】:

正如 ArtOsi 所写 - 写作存在问题。

在var文件夹中将缓存、日志和会话文件夹的写入权限设置为777后,它开始工作了。

【讨论】:

    【解决方案2】:

    需要授权才能访问 Symfony 中的开发环境。

    打开 web/app_dev.php 文件并将您的 ip 添加到信任列表中。

    if (isset($_SERVER['HTTP_CLIENT_IP'])
        || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
        || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1','27.131.14.9']) || PHP_SAPI === 'cli-server')
    ) {
        header('HTTP/1.0 403 Forbidden');
        exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
    }
    

    受信任的 IP 在代码中的数组中定义:

    ['127.0.0.1', '::1','27.131.14.9', 'YourTrustedIP']
    

    【讨论】:

      猜你喜欢
      • 2018-10-11
      • 2012-07-11
      • 1970-01-01
      • 2018-11-05
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 2013-09-05
      相关资源
      最近更新 更多