1、问题描述
$ yum
执行yum出现异常:libssh2.so.1: cannot open shared object file: No such file or...


2、解决方案
查询so文件是否存在:

whereis libssh2.so.1
libssh2.so: /usr/local/lib/libssh2.so /usr/local/lib/libssh2.so.1    

注:如果不存在则要安装该so文件

tar zxvf libssh2-1.4.3.tar.gz 
 ./configure
make&&make install 

3、由2可知libssh2.so.1存在目录:/usr/local/lib/libssh2.so.1


4、设置libssh2.so.1软链接

ln -s /usr/local/lib/libssh2.so.1 /lib64

功能是为某一个文件在另外一个位置建立一个同步的链接,这个命令最常用的参数是-s,具体用法是:ln -s 源文件 目标文件


5、总结
针对其他cannot open shared object file: No such file or... 情况,应该与此类似,可以尝试通过此方案解决。


处理方法:
查询是否有对应库:

[root@iZbp1dra1xxfrim8vv0f00Z ~]# whereis libssh2.so.1
libssh2.so: /usr/lib64/libssh2.so.1

[root@iZ2ze0dgv0zpedpa3d238tZ ~]# whereis libnspr4.so
libnspr4: /lib64/libnspr4.so

根据提示已经安装好了libssh2.so.1,对应文件路径/usr/lib64/libssh2.so.1,使用正常的上传替换


报错

Apache配置文件有错
[root@iZ28v0nom3mZ ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: httpd: Syntax error on line 55 of /www/wdlinux/httpd-2.2.31/conf/httpd.conf: Cannot load /www/wdlinux/httpd-2.2.31/modules/libphp5.so into server: libjpeg.so.62: cannot open shared object file: No such file or directory

处理:
[root@iZ28v0nom3mZ ~]# whereis libjpeg.so.62
libjpeg.so: /usr/lib/libjpeg.so /usr/lib64/libjpeg.so /usr/lib64/libjpeg.so.62
路径:/usr/lib64/libjpeg.so.62
找正常的进行替换
[root@iZ28v0nom3mZ ~]# service httpd start
Starting httpd: Warning: DocumentRoot [/www/web/default] does not exist
[ OK ]


报错:

Apache配置文件有错
httpd: Syntax error on line 55 of /www/wdlinux/httpd-2.2.31/conf/httpd.conf: Cannot load /www/wdlinux/httpd-2.2.31/modules/libphp5.so into server: liblber-2.4.so.2: cannot open shared object file: No such file or directory
处理:
[root@iZm5e546opi6pmphz6nz30Z ~]# whereis libicuuc.so.42
libicuuc.so: /usr/lib64/libicuuc.so /usr/lib64/libicuuc.so.42


报错:

[root@iZ2ze0dgv0zpedpa3d238tZ ~]# /www/wdlinux/phps/55/bin/php-fpm start
Starting php-fpm /www/wdlinux/phps/55/sbin/php-fpm: error while loading shared libraries: liblber-2.4.so.2: cannot open shared object file: No such file or directory
failed
处理:
[root@iZm5e546opi6pmphz6nz30Z ~]# whereis liblber-2.4.so.2
liblber-2.4.so: /usr/lib64/liblber-2.4.so /usr/lib64/liblber-2.4.so.2


报错:

[root@iZbp1dra1xxfrim8vv0f00Z ~]# service httpd start
Starting httpd: httpd: Syntax error on line 55 of /www/wdlinux/httpd-2.2.31/conf/httpd.conf: Cannot load /www/wdlinux/httpd-2.2.31/modules/libphp5.so into server: libssh2.so.1: cannot open shared object file: No such file or directory [FAILED]
[oot@iZbp1dra1xxfrim8vv0f00Z ~]# /www/wdlinux/phps/55/bin/php-fpm start
Starting php-fpm /www/wdlinux/phps/55/sbin/php-fpm: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
[root@iZm5e546opi6pmphz6nz30Z ~]# whereis liblber-2.4.so.1
liblber-2.4.so: /usr/lib64/liblber-2.4.so /usr/lib64/liblber-2.4.so.1


报错:

项目中碰到的问题,编译好的so文件,放到其他机器上去加载,报了错误,
cannot restore segment prot after reloc: Permission denied。
网上查了一下,原因是selinux的问题,selinux的设置太过严格导致的。解决的办法是在root用户下,修改/etc/selinux/config 文件,

把SELINUX=enforcing 改成 SELINUX=disabled

然后,保存关闭,重启机器就可以了。
另外还有一个暂时关闭的方法,就是 /usr/sbin/setenforce 0 。