douji5746 2016-10-29 10:47
浏览 76
已采纳

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

I've used this tutorial to set up a simple webserver on Amazon EC2, with PHP, mySQL, nginx and php-fpm. Everything seems to be up and running, html pages are opening just fine. My phpinfo() works fine as well, showing Server API as FPM/FastCGI and php-fpm as active. So far so good.

I now copied one of my old websites, which uses php and is working fine on my old server (which runs Apache without php-fpm by the way), to the new server and opened the index.php page. It opens, displays fine, but the Twitter login button to continue into the application shows this link:

<? echo $content;?>

Instead of showing "redirect.php" as it does on the live website. So somehow it seems as if the php within the page is not working. With a clean nginx error.log, reloading this page generates the following output in the 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: "*****"

I'm guessing that the permission denied error may be the cause, but I'm having a hard time figuring out why. Especially since the phpinfo() file works just fine. As you can probably tell, I'm a novice when it comes to these things.

Something about my config: the user in nginx.conf is set to nginx, and /etc/php-fpm.d/www.conf contains at least the following:

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

So, I'm not even really sure I have a question that's more specific than "Why doesn't this page work?" But I hope that someone is able to help anyway.

I've seen plenty of similar questions, sometimes not having an +x on some of the folders leading up to the webserver content being the problem, but I've verified and world has +x on every folder leading up to my webserver folder so that shouldn't be the problem.

Anyone who might be able to point me in the right direction? Thanks in advance for your patience :)

  • 写回答

1条回答 默认 最新

  • duanao2688 2016-10-30 10:26
    关注

    It seems your new installation of php does not allow the short tag http://php.net/manual/en/ini.core.php#ini.short-open-tag

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器