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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算