douji5746 2016-10-29 02: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 02: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 为什么树莓派5b显示禁止连接
  • ¥20 流量太费!寻找便宜的app音视频SDK或平替方案。
  • ¥15 kubeasz部署遇到问题
  • ¥15 GUIDE to App Designer Migration Tool for MATLAB
  • ¥50 第三代非支配排序遗传算法(NSGA-Ⅲ)和多目标粒子群优化算法(MOPSO)的实现
  • ¥20 plant simulation与python com接口实时数据交互
  • ¥15 有关汽车的MC9S12XS128单片机实验
  • ¥15 求c语言动态链表相关课程有偿,或能将这块知识点讲明白
  • ¥15 FLKT界面刷新异常
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部