【发布时间】:2017-02-20 04:01:20
【问题描述】:
我在由 Vagrant 1.8.6/VirtualBox 5.1.6 管理的 Ubuntu 14.04、PHP 7.1 和 Apache 2.4.23 堆栈上运行 Symfony 3.1.5。我正在尝试使用我制作的简单控制器在前端呈现响应:
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\BrowserKit\Response;
class LandingController {
/**
* @Route("/", name="homepage")
*/
public function showAction(){
return new Response('This is the landing page!');
}
}
当我尝试通过/app_dev.php 访问我的 Symfony 前端时,我看到了:
Warning: SessionHandler::read(): Session data file is not created by your uid
500 Internal Server Error - ContextErrorException
我的 Apache 日志显示:
CRITICAL - Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: SessionHandler::read(): Session data file is not created by your uid" at /var/www/conan/var/cache/dev/classes.php line 366
Symfony 开发日志如下:
==> /var/www/conan/var/logs/dev.log <==
[2016-10-11 14:23:04] request.INFO: Matched route "{route}". {"route":"homepage","route_parameters":{"_controller":"AppBundle\\Controller\\LandingController::showAction","_route":"homepage"},"request_uri":"http://conan.dev/app_dev.php/","method":"GET"} []
[2016-10-11 14:23:04] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: SessionHandler::read(): Session data file is not created by your uid" at /var/www/conan/var/cache/dev/classes.php line 366 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Warning: SessionHandler::read(): Session data file is not created by your uid at /var/www/conan/var/cache/dev/classes.php:366)"} []
鉴于这似乎是与会话相关的问题,我参考了 Session Management 的 Symfony 文档。它指出:
Symfony 会话与 php.ini 指令 session.auto_start = 1 不兼容 该指令应在 php.ini、webserver 指令或 .htaccess 中关闭。
session.auto_start = 0 在我的php.ini 中,该文件归用户和组root 所有:
$ ls -lta /etc/php/7.1/fpm/php.ini
-rw-r--r-- 1 root root 70584 Sep 30 07:29 /etc/php/7.1/fpm/php.ini
我已尝试按照 Symfony 文档中的说明创建一个 .htaccess(我将其放在我的 DocumentRoot 中),但错误仍然存在。
我已经搜索了几个主题和问题以寻找解决方案,但没有找到任何解决方案。任何想法是什么原因造成的?
【问题讨论】:
标签: php apache session symfony