PHP 7.4.1因缺少 libonig.so.2文件不能启动的问题处理
yum update更新完系统以后发现php7不能运行,访问nginx直接报502,tail查看nginx error log报错如下
2021/02/25 14:46:24 [crit] 1746#0: *6 connect() to unix:/usr/local/php7/var/run/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: 10.8.118.36, server: zc.hongsin.cn, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/usr/local/php7/var/run/php-cgi.sock:", host: "xxx.xxxx.cn"
看样子是php-fpm没有运行,使用systemctl查看php-fpm服务
systemctl status php-fpm7
● php-fpm7.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm7.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 四 2021-02-25 14:48:12 CST; 4min 48s ago
Process: 26537 ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf (code=exited, status=127)
Main PID: 26537 (code=exited, status=127)
2月 25 14:48:12 wiki-cmdb systemd[1]: Started The PHP FastCGI Process Manager.
2月 25 14:48:12 wiki-cmdb php-fpm[26537]: /usr/local/php7/sbin/php-fpm: error while loading shared libraries: libonig.so.2: cannot open shared object file: No such file or directory
2月 25 14:48:12 wiki-cmdb systemd[1]: php-fpm7.service: main process exited, code=exited, status=127/n/a
2月 25 14:48:12 wiki-cmdb systemd[1]: Unit php-fpm7.service entered failed state.
2月 25 14:48:12 wiki-cmdb systemd[1]: php-fpm7.service failed.
关键信息:
2月 25 14:48:12 wiki-cmdb php-fpm[26537]: /usr/local/php7/sbin/php-fpm: error while loading shared libraries: libonig.so.2: cannot open shared object file: No such file or directory
查看php7版本:
/usr/local/php7/bin/php -V
/usr/local/php7/bin/php: error while loading shared libraries: libonig.so.2: cannot open shared object file: No such file or directory
看来就是libonig.so.2文件找不到的原因了,解决步骤:
安装对应组件,并做软连接
yum install oniguruma libsodium -y
ln -s /usr/lib64/libonig.so /usr/lib64/libonig.so.2
查看libonig.so库
ll /usr/lib64/libonig.so*
lrwxrwxrwx 1 root root 16 1月 4 17:42 /usr/lib64/libonig.so -> libonig.so.5.0.0
lrwxrwxrwx 1 root root 21 2月 25 14:57 /usr/lib64/libonig.so.2 -> /usr/lib64/libonig.so
lrwxrwxrwx 1 root root 16 1月 4 17:41 /usr/lib64/libonig.so.5 -> libonig.so.5.0.0
-rwxr-xr-x 1 root root 539352 5月 27 2020 /usr/lib64/libonig.so.5.0.0
启动php-fpm服务,查看版本号:
systemctl start php-fpm7
/usr/local/php7/bin/php -v
PHP 7.4.1 (cli) (built: Dec 27 2019 13:39:08) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
问题解决,应用恢复访问。
Tag标签:「php libonig php-fpm」更新时间:「2021-11-03 23:38:49」阅读次数:「1228」