背景
服务器A准备下线,故直接将上面的所有应用/资料打包迁移到服务器B。包括搭建的nginx,迁移到B服务器后,楼主偷懒,就想着直接./nginx启动,过程遇到如下问题。
./nginx
./nginx: error while loading shared libraries: libssl.so.6: cannot open shared object file: No such file or directory
原因:找不到动态链接库。
问题具体解决过程
(1)安装libssl.so.6
rpm包下载:https://pkgs.org/download/libssl.so.6
安装:rpm2cpiolibstdc++-4.4.7-4.el6.x86_64.rpm |cpio -idvm
(2)LD_LIBRARY_PATH修改
楼主不是root,故只能将libssl.so.6安装到普通用户目录,再通过LD_LIBRARY_PATH添加LD加载目录。
具体在.bashrc中添加:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib/usr/lib64(libssl.so.6具体目录)
(3)安装64位的libssl.so.6
前两个步骤搞定后,启动时候仍遇到这个错误:
./nginx
./nginx: error while loading shared libraries: libssl.so.6: wrong ELF class: ELFCLASS32
错误原因:安装的so.6是32位,当前系统需要64位。
重新下载64位的libssl.so.6再安装步骤(1)(2)操作就可以。
附录:
1、64位 libssl.so.6下载地址
wget ftp://ftp.pbone.net/mirror/www.startcom.org/AS-6.0.0/os/x86_64/Packages/openssl098e-0.9.8e-17.SEL6.x86_64.rpm。
2、查看nginx依赖的so库
ldd nginx
linux-vdso.so.1 => (0x00007fff09fff000)
libpthread.so.0 => /lib64/libpthread.so.0(0x0000003fc8400000)
libcrypt.so.1 => /lib64/libcrypt.so.1(0x0000003fccc00000)
libssl.so.6 => not found
libcrypto.so.6 => not found
libdl.so.2 => /lib64/libdl.so.2(0x0000003fc8000000)
libz.so.1 => /lib64/libz.so.1(0x0000003fc8c00000)
libc.so.6 => /lib64/libc.so.6(0x0000003fc7c00000)
/lib64/ld-linux-x86-64.so.2(0x0000003fc7800000)
libfreebl3.so => /lib64/libfreebl3.so(0x0000003fcd000000)
3、nginx启动参数
./nginx -h
nginx version: nginx/1.4.2
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /home1/xxxx/local/nginx-1.4.2//)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file