PHP 在使用 nginx 和 php-fpm 的 Amazon EC2 服务器上无法在页面内部工作

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

我已经使用 this tutorial 在 Amazon EC2 上设置了一个简单的网络服务器,其中包括 PHP、mySQL、nginx 和 php-fpm。一切似乎都正常,运行、html 页面打开得很好。我的 phpinfo() 也工作正常,显示服务器 API 为 FPM/FastCGI 和 php-fpm 为活动状态。到目前为止一切顺利。

我现在复制了我的一个旧网站,它使用 php 并且在我的旧服务器上运行良好(顺便说一句,它运行 Apache 而没有 php-fpm),到新服务器并打开了 index.php 页面。它打开,显示正常,但继续进入应用程序的 Twitter 登录按钮显示此 link:

<? 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: "*****"

我猜测可能是权限被拒绝错误导致的,但我很难找出原因。特别是因为 phpinfo() 文件工作得很好。正如你可能会说的那样,我在这些事情上是个新手。

关于我的配置:nginx.conf 中的用户设置为 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

所以,我什至不确定我有一个比 "Why doesn't this page work?" 更具体的问题,但我希望有人能够提供帮助。

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

谁能给我指出正确的方向?预先感谢您的耐心等待:)

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