无法在 Ubuntu 16.04 和 PHP 7 上安装 php-curl

无法在 Ubuntu 16.04 和 PHP 7 上安装 php-curl

命令:sudo apt-get install php-curl

输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  php7.0-curl
The following NEW packages will be installed:
  php-curl php7.0-curl
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 28,8 kB of archives.
After this operation, 125 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 php7.0-curl amd64 7.0.4-7ubuntu2 [26,9 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 php-curl all 1:7.0+35ubuntu6 [1.930 B]
Fetched 28,8 kB in 6s (4.630 B/s)                                              
Selecting previously unselected package php7.0-curl.
(Reading database ... 261818 files and directories currently installed.)
Preparing to unpack .../php7.0-curl_7.0.4-7ubuntu2_amd64.deb ...
Unpacking php7.0-curl (7.0.4-7ubuntu2) ...
Selecting previously unselected package php-curl.
Preparing to unpack .../php-curl_1%3a7.0+35ubuntu6_all.deb ...
Unpacking php-curl (1:7.0+35ubuntu6) ...
Processing triggers for libapache2-mod-php7.0 (7.0.4-7ubuntu2) ...
Processing triggers for php7.0-fpm (7.0.4-7ubuntu2) ...
Job for php7.0-fpm.service failed because the control process exited with error code. See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details.
invoke-rc.d: initscript php7.0-fpm, action "restart" failed.
dpkg: error processing package php7.0-fpm (--unpack):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 php7.0-fpm
E: Sub-process /usr/bin/dpkg returned an error code (1)

输出sudo systemctl status php7.0-fpm.service

● php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Qua 2016-05-04 11:38:06 BRT; 4min 30s ago
  Process: 491 ExecStart=/usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf (code=exited, status=78)
  Process: 481 ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS)
 Main PID: 491 (code=exited, status=78)

Mai 04 11:38:06 douglas-acer systemd[1]: Starting The PHP 7.0 FastCGI Process Manager...
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: [/etc/php/7.0/fpm/php-fpm.conf:127] value is NULL for a ZEND_INI_PAR
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: PHP:  syntax error, unexpected '$' in Unknown on line 1
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: failed to load configuration file '/etc/php/7.0/fpm/php-fpm.conf'
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: FPM initialization failed
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Main process exited, code=exited, status=78/n/a
Mai 04 11:38:06 douglas-acer systemd[1]: Failed to start The PHP 7.0 FastCGI Process Manager.
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Unit entered failed state.
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Failed with result 'exit-code'.

输出journalctl -xe

-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit php7.0-fpm.service has begun starting up.
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: [/etc/php/7.0/fpm/php-fpm.conf:127] value is NULL for a ZEND_INI_PAR
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: PHP:  syntax error, unexpected '$' in Unknown on line 1
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: failed to load configuration file '/etc/php/7.0/fpm/php-fpm.conf'
Mai 04 11:38:06 douglas-acer php-fpm7.0[491]: [04-May-2016 11:38:06] ERROR: FPM initialization failed
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Main process exited, code=exited, status=78/n/a
Mai 04 11:38:06 douglas-acer systemd[1]: Failed to start The PHP 7.0 FastCGI Process Manager.
-- Subject: Unit php7.0-fpm.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit php7.0-fpm.service has failed.
-- 
-- The result is failed.
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Unit entered failed state.
Mai 04 11:38:06 douglas-acer systemd[1]: php7.0-fpm.service: Failed with result 'exit-code'.
Mai 04 11:38:08 douglas-acer sudo[31791]: pam_unix(sudo:session): session closed for user root
Mai 04 11:38:24 douglas-acer com.ubuntu.OneConf[1548]: WARNING:oneconf.hosts:Error in loading other_hosts file: [Errno 2] No such file or direct
Mai 04 11:39:01 douglas-acer CRON[585]: pam_unix(cron:session): session opened for user root by (uid=0)
Mai 04 11:39:01 douglas-acer CRON[587]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
Mai 04 11:39:01 douglas-acer CRON[585]: pam_unix(cron:session): session closed for user root
Mai 04 11:39:01 douglas-acer CRON[586]: pam_unix(cron:session): session opened for user root by (uid=0)
Mai 04 11:39:01 douglas-acer CRON[588]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean)
Mai 04 11:39:02 douglas-acer CRON[586]: pam_unix(cron:session): session closed for user root
Mai 04 11:40:01 douglas-acer CRON[656]: pam_unix(cron:session): session opened for user smmsp by (uid=0)
Mai 04 11:40:01 douglas-acer CRON[657]: (smmsp) CMD (test -x /etc/init.d/sendmail && test -x /usr/share/sendmail/sendmail && test -x /usr/lib/sm
Mai 04 11:40:01 douglas-acer sm-msp-queue[676]: My unqualified host name (douglas-acer) unknown; sleeping for retry
Mai 04 11:40:29 douglas-acer AptDaemon[31697]: INFO: Quitting due to inactivity
Mai 04 11:40:29 douglas-acer AptDaemon[31697]: INFO: Quitting was requested
Mai 04 11:40:29 douglas-acer org.freedesktop.PackageKit[764]: 11:40:29 AptDaemon [INFO]: Quitting due to inactivity
Mai 04 11:40:29 douglas-acer org.freedesktop.PackageKit[764]: 11:40:29 AptDaemon [INFO]: Quitting was requested
Mai 04 11:41:01 douglas-acer sm-msp-queue[676]: unable to qualify my own domain name (douglas-acer) -- using short name
Mai 04 11:41:01 douglas-acer CRON[656]: pam_unix(cron:session): session closed for user smmsp
Mai 04 11:42:36 douglas-acer sudo[707]:  douglas : TTY=pts/1 ; PWD=/home/douglas ; USER=root ; COMMAND=/bin/systemctl status php7.0-fpm.service
Mai 04 11:42:36 douglas-acer sudo[707]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mai 04 11:43:33 douglas-acer sudo[707]: pam_unix(sudo:session): session closed for user root
Mai 04 11:43:35 douglas-acer sudo[752]:  douglas : TTY=pts/1 ; PWD=/home/douglas ; USER=root ; COMMAND=/bin/systemctl status php7.0-fpm.service
Mai 04 11:43:35 douglas-acer sudo[752]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mai 04 11:43:48 douglas-acer sudo[752]: pam_unix(sudo:session): session closed for user root

我不确定是否相关,但我在安装 PHP7 时也遇到了问题,@oerdnj 在这里解决了这个问题:Ubuntu 16.04 升级后 PHP 呈现为文本

答案1

php-fpm.conf您发布的日志中指出有一个错误(删除了时间戳):

ERROR: [/etc/php/7.0/fpm/php-fpm.conf:127] value is NULL for a ZEND_INI_PAR
PHP:  syntax error, unexpected '$' in Unknown on line 1
ERROR: failed to load configuration file '/etc/php/7.0/fpm/php-fpm.conf'
ERROR: FPM initialization failed

修复你的 php-fpm.conf 并运行以测试语法:

$ sudo /usr/sbin/php-fpm7.0 --test

输出应如下所示:

[04-May-2016 17:10:59] NOTICE: configuration file /etc/php/7.0/fpm/php-fpm.conf test is successful

相关内容