加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php7.0-fpm无法正常工作

发布时间:2020-12-13 13:55:10 所属栏目:PHP教程 来源:网络整理
导读:我已经在Ubuntu 16.04机器上安装了Apache php7.0和 mysql,我得到了答案“php没有运行”.这是我的vhost配置: VirtualHost *:80 ServerAdmin webmaster@example.com ServerName www.example.com DocumentRoot /var/www/sites/www.example.com/httpdocs Script
我已经在Ubuntu 16.04机器上安装了Apache php7.0和 mysql,我得到了答案“php没有运行”.这是我的vhost配置:
<VirtualHost *:80>
  ServerAdmin webmaster@example.com
  ServerName www.example.com
  DocumentRoot /var/www/sites/www.example.com/httpdocs
  ScriptAlias "cgi-bin" "/var/www/sites/wwww.example.com/cgi-bin"

  ErrorLog ${APACHE_LOG_DIR}/www.example.com.error_log

  LogLevel debug

  CustomLog ${APACHE_LOG_DIR}/www.example.com.log combined

    <IfModule mod_fastcgi.c>

    AddHandler php7-fcgi .php
    Action php7-fcgi /php7-fcgi virtual
    Alias /php7-fcgi-kermit /usr/lib/cgi-bin/php7-fcgi-kermit
    FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi-kermit -socket /run/php/php7.0-fpm.kermit.sock -pass-header Authorization

    <Directory "/usr/lib/cgi-bin">
    Require all granted
    </Directory>
    </IfModule>

  <IfModule mod_fastcgi.c>
    <FilesMatch ".+.ph(p[345]?|t|tml)$">
      SetHandler php7-fcgi-kermit
    </FilesMatch>
  </IfModule>

</VirtualHost>

当我尝试访问该网站时,它不是解析PHP而是将其打印到屏幕上.

有人有什么想法吗?

我已经摆脱了以前用于处理apache 2.2的所有其他fpm的东西,并将此行添加到conf中

ProxyPassMatch ^/(.*.php(/.*)?)$unix:/var/run/php/php7.0-fpm.kermit.sock|fcgi://localhost/var/www/sites/www.example.com/httpdocs

现在我在错误日志中收到以下错误

[Wed Mar 21 13:04:35.539499 2018] [proxy:error] [pid 26569] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /var/run/php/php7.0-fpm.kermit.sock (localhost) failed

对于套接字来说,permisssions看起来是正确的

srw-rw----  1 kermit   kermit     0 Mar 21 13:00 php7.0-fpm.kermit.sock=

我不知道它在哪里得到=但是

如果您使用的是PHP-FPM,则应考虑使用mod_proxy_fcgi,它是Apache 2.4中新增的,仅适用于此类用例. Apache wiki entry for PHP-FPM有一些良好的入门指导.

mod_proxy_fcgi documentation还包括设置PHP-FPM的具体示例,PHP documentation也提供了有用的信息.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读