MENU

lnmp环境安装依赖composer报错

June 15, 2023 • linux相关

错误

In Process.php line 146:

  The Process class relies on proc_open, which is not available on your PHP i
  nstallation.
$ composer update
PHP Fatal error:  Uncaught TypeError: Return value of Symfony\Component\Process\Process::close() must be of the type int, null returned in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php:1466
Stack trace:
#0 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(1355): Symfony\Component\Process\Process->close()
#1 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(367): Symfony\Component\Process\Process->updateStatus()
#2 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(252): Symfony\Component\Process\Process->start()
#3 phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php(134): Symfony\Component\Process\Process->run()
#4 phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php(76): Composer\Util\ProcessExecutor->doExecute()
#5 phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionGuesser.php(139): Composer\Util\ProcessExecutor->execute()
#6 phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionGuesser.php(78): Co in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php on line 1466

Fatal error: Uncaught TypeError: Return value of Symfony\Component\Process\Process::close() must be of the type int, null returned in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php:1466
Stack trace:
#0 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(1355): Symfony\Component\Process\Process->close()
#1 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(367): Symfony\Component\Process\Process->updateStatus()
#2 phar:///usr/local/bin/composer/vendor/symfony/process/Process.php(252): Symfony\Component\Process\Process->start()
#3 phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php(134): Symfony\Component\Process\Process->run()
#4 phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php(76): Composer\Util\ProcessExecutor->doExecute()
#5 phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionGuesser.php(139): Composer\Util\ProcessExecutor->execute()
#6 phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionGuesser.php(78): Co in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php on line 1466

解决

需要放开 /usr/local/php/etc/php.ini 中的几个函数:proc_open,proc_get_status

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

重启 php-fpm 即可。

composer 安装

php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"

php composer-setup.php

# 移动到全局范围
mv composer.phar /usr/local/bin/composer

# 更新 composer
composer selfupdate