安装完Nginx之后,启动报错。
[vagrant@localhost sbin]$ sudo ./nginx
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
运行ldd命令,找到Nginx的依赖共享库文件。
vagrant@localhost sbin]$ ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so.1 => (0x00007fff1b74a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000032b2600000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000032b3a00000)
libpcre.so.1 => not found
libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00000032b4200000)
libc.so.6 => /lib64/libc.so.6 (0x00000032b1a00000)
/lib64/ld-linux-x86-64.so.2 (0x00000032b1600000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000032b1e00000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00000032b3200000)
原来是真的没找到libpcre.so.1文件。
进入lib64文件夹,对libpcre.so.0.0.1做软连接。
[vagrant@localhost lib64]$ cd /lib64/
[vagrant@localhost lib64]$ sudo ln -s libpcre.so.0.0.1 libpcre.so.1
再次运行ldd命令,就能够找到libpcre.so.1依赖库了。
[vagrant@localhost lib64]$ ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so.1 => (0x00007fffd43d5000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000032b2600000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000032b3a00000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00000032b1e00000)
libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00000032b4200000)
libc.so.6 => /lib64/libc.so.6 (0x00000032b1a00000)
/lib64/ld-linux-x86-64.so.2 (0x00000032b1600000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002aebb7623000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00000032b3200000)
ok, 如今就能够成功启动Nginx。
[vagrant@localhost sbin]$ sudo ./nginx
[vagrant@localhost sbin]$ sudo netstat -ntlp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17529/nginx