PHP不工作内部页面在亚马逊EC2服务器与nginx和PHP -fpm


PHP not working inside page on Amazon EC2 server with nginx and php-fpm

我使用本教程在Amazon EC2上设置了一个简单的web服务器,使用PHP, mySQL, nginx和PHP -fpm。一切似乎都在运行,html页面打开得很好。我的phpinfo()也可以很好地工作,显示服务器API为FPM/FastCGI和php-fpm为活动。到目前为止一切顺利。

我现在复制了我的一个旧网站,它使用php并且在我的旧服务器上工作良好(顺便说一下,它运行Apache而没有php-fpm),到新服务器并打开index.php页面。它打开了,显示正常,但是Twitter登录按钮显示了这个链接:

<? echo $content;?>

而不是显示"redirect.php",因为它在现场网站。因此,不知何故,似乎页面内的php不工作。使用干净的nginx error.log,重新加载该页面会在日志中生成以下输出:

2016/10/29 12:32:58 [error] 2936#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  session_start(): open(/var/lib/php/session/sess_45g3uvcilj8913naoa1nrenfn3, O_RDWR) failed: Permission denied (13) in /var/www/html/*****/index.php on line 2
PHP message: PHP Notice:  A session had already been started - ignoring session_start() in /var/www/html/*****/index.php on line 6
PHP message: PHP Notice:  Undefined index: access_token in /var/www/html/*****/index.php on line 15" while reading response header from upstream, client: *****, server: *****, request: "GET /tlm/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "*****"

我猜permission denied error可能是原因,但是我很难找出原因。特别是因为phpinfo()文件工作得很好。你可能也看得出来,在这些事情上我是个新手。

关于我的配置:nginx.conf中的user被设置为nginx,/etc/php-fpm.d/www.conf至少包含以下内容:

listen = /var/run/php-fpm/php-fpm.sock
listen.allowed_clients = 127.0.0.1
listen.owner = nginx
listen.group = nginx
listen.mode = 0664
user = nginx
group = nginx

所以,我甚至不确定我有一个比"为什么这个页面不起作用?"更具体的问题。但我还是希望有人能帮上忙。

我看到过很多类似的问题,有时没有一个+x在一些文件夹导致网络服务器的内容是问题,但我已经验证和世界上有+x在每个文件夹导致我的网络服务器文件夹,所以这应该不是问题。

谁能给我指个正确的方向?提前感谢您的耐心等待:)

似乎您的新php安装不允许短标记http://php.net/manual/en/ini.core.php#ini.short-open-tag