背景 伺服器A準備下線,故直接將上面的所有應用/資料打包遷移到伺服器B。包括搭建的nginx,遷移到B伺服器後,樓主偷懶,就想著直接./nginx啟動,過程遇到如下問題。 ./nginx ./nginx: error while loading shared libraries: libssl.so ...
背景
伺服器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
參考:https://www.linuxidc.com/Linux/2013-03/81120.htm