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 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 Ubuntu开机显示器只显示kernel,是没操作系统(相关搜索:显卡驱动)
  • ¥15 VB.NET如何绘制倾斜的椭圆
  • ¥15 arbotix没有/cmd_vel话题
  • ¥15 odoo17的分包重新供应路线如何设置?可从销售订单中实时直接触发采购订单或相关单据
  • ¥15 用C语言怎么判断字符串的输入是否符合设定?
  • ¥15 通信专业本科生论文选这两个哪个方向好研究呀
  • ¥50 我在一个购物网站的排队系统排队,这个排队到号后重新定向到目标网站进行购物,但是有技术牛通过技术方法直接跳过排队系统进入目标网址购物,有没有什么软件或者脚本可以用