2021年2月

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-fpm7.jpg
看样子是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

问题解决,应用恢复访问。

"SQLServer数据库正在使用,所以无法获得对数据库的独占访问权"的问题解决方法

SQLServer2008R2在还原数据库的时候报错,“因为数据库正在使用,所以无法获得对数据库的独占访问权。”,如下图:
1.png
出现该问题的原因已经很明确了,就是有其他用户还在连接着数据库,可以先尝试重启数据库,如果还是如此的话,可采用下面方法:
在master中创建一个存储过程,用来断开和数据库的所有链接:

USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
  --建一个存储过程,断开所有用户连接。  
  create   proc   [dbo].[killspid]   (@dbname   varchar(20))  
  as  
  begin  
  declare   @sql   nvarchar(500)  
  declare   @spid   int  
  set   @sql='declare   getspid   cursor   for    
  select   spid   from   sysprocesses   where   dbid=db_id('''+@dbname+''')'  
  exec   (@sql)  
  open   getspid  
  fetch   next   from   getspid   into   @spid  
  while   @@fetch_status<>-1  
  begin  
  exec('kill   '+@spid)  
  fetch   next   from   getspid   into   @spid  
  end  
  close   getspid  
  deallocate   getspid  
  end  
GO

断开和库的所有链接:

use   master   
exec   killspid   '出问题的数据库名'

实际场景中可以开启防火墙,只允许本机访问数据库,然后执行这个存储过程即可正常进行各种操作;
不建议使用更改数据库为单用户模式,仍然会有类似提示,如下图:
2.png

最新

分类

归档

评论

  • ice: 嗯,少了个cd进入目录·
  • peter: wget https...
  • Emerson: 写的好

其它