doulai2025 2016-10-10 14:50
浏览 170
已采纳

无法将lighttpd配置为PHP 7

Apart from logging to the wrong file (the error log defined for that vhost defined last),
lighty does not let me use PHP 7. What am I missing?

cgi.fix_pathinfo is enabled in /etc/php/7.0/fpm/php.ini.

How can I make sure you're using the FastCGI-enabled version? What else should I look for?

version info (shrinked to the necessary)

> lsb_release -a
Description:    Ubuntu 16.04.1 LTS
Codename:       xenial

> lighttpd -v
lighttpd/1.4.35 (ssl) - a light and fast webserver
Build-Date: Apr 18 2016 15:36:10


> php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )

> php-cgi -v
PHP 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1 (cgi-fcgi)

> php-fpm7.0 -v
PHP 7.0.8-0ubuntu0.16.04.3 (fpm-fcgi)

lighty config file excerpt

> head -41 /etc/lighttpd/lighttpd.conf | tail -9
fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php-cgi",
                     "socket" => "/tmp/php.socket",
                     "bin-environment" => (
                       "PHP_FCGI_CHILDREN" => "16",
                       "PHP_FCGI_MAX_REQUESTS" => "1000"
                     ),
                "broken-scriptfilename" => "enable"
                 )))

tryouts

If I change the socket to an invalid path, restarting lighttpd works fine; but the server is unreachable. (bind failed for: (invalid path) in the error log); so this seems like the correct config file.

Modifying /etc/lighttpd/conf-available/15-fastcgi-php.conf in the same way has no effect at all.

Changing the socket to "/var/run/php/php7.0-fpm.sock" has no effect either (php_info() still says PHP 5.6 after restarting lighty).

After changing bin-path to /usr/sbin/php-fpm7.0 , I still get no error when restarting lighttpd, but the web server is unreachable.

error log excerpt

> tail /var/log/lighttpd/error.log
(no output)
> tail /var/log/lighttpd/somevhost/error.log
2016-10-10 16:48:02: (log.c.164) server started
2016-10-10 16:48:02: (mod_fastcgi.c.1112) the fastcgi-backend /usr/sbin/php-fpm7-0 failed to start:
2016-10-10 16:48:02: (mod_fastcgi.c.1116) child exited with status 2 /usr/sbin/php-fpm7-0
2016-10-10 16:48:02: (mod_fastcgi.c.1119) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2016-10-10 16:48:02: (mod_fastcgi.c.1406) [ERROR]: spawning fcgi failed.
2016-10-10 16:48:02: (server.c.1022) Configuration of plugins failed. Going down.

update I just uninstalled php5 hoping this would resolve the issues; but that didn´t help either. Instead, I seem to have no way to get php5 back.

  • 写回答

1条回答 默认 最新

  • download201401 2016-10-11 11:32
    关注

    Tried a search engine? https://www.google.com/?gws_rd=ssl#q=lighttpd+ubuntu+php+7

    The first hit: https://www.howtoforge.com/tutorial/installing-lighttpd-with-php7-php-fpm-and-mysql-on-ubuntu-16.04-lts/ suggests

    ## Start an FastCGI server for php (needs the php7.0-cgi package)
    fastcgi.server += ( ".php" =>
            ((
                    "socket" => "/var/run/php/php7.0-fpm.sock",
                    "broken-scriptfilename" => "enable"
            ))
    )
    

    to go along with php.ini cgi.fix_pathinfo=1

    You can follow the instructions on the page above to have Ubuntu run php7.0-fpm as a service, or you can configure lighttpd to start up the fastcgi.server backend by setting "bin-path" in the fastcgi.server definition, but do not do both.

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

报告相同问题?

悬赏问题

  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测