nginx -v 時提示:error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,意思是找不到libpcre.so.1這個模組,而導致啟動失敗。
- R ^4 k* S/ G3 d2 o要解決這個方法非常容易 如果是32位系统 [root@lee ~]# ln -s /usr/local/lib/libpcre.so.1 /lib 如果是64位系统 [root@lee ~]# ln -s /usr/local/lib/libpcre.so.1 /lib64 然後再啟動nginx就OK了 [root@lee ~]# service nginx start : R! \) B0 y' z4 A) j% }& h
BUT service nginx start show error: nginx: unrecognized service Solution: 原因是找不到啟動的script 及 可執行檔 cp /usr/sbin/nginx /etc/init.d/ nginx是執行檔 複製別台server 之 /etc/rc.d/init.d/nginx 到 本機 /etc/rc.d/init.d/nginx 此處nginx 是啟動的script 再一次 service nginx start show error: Starting nginx: nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:2 原因是沒有 nginx 用戶及群組 Sol: groupadd -r nginx% @0 V5 q) w9 j4 @2 c
useradd -r -g nginx -s /bin/false -M nginx or /usr/sbin/groupadd -f nginx /usr/sbin/useradd -M -s /sbin/nologin -g nginx nginx //-M 不建立使用者目錄
8 R# w) W% T" Q; X8 L* i$ E
vi /etc/passwd 查看是否已新增nginx & x* Y% i1 @0 w b0 o# I' R3 M
again service nginx start show error: Starting nginx: nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (2: No such file or directory) Sol: 查無 /var/cache/nginx/ 此目錄 mkdir /var/cache/nginx again service nginx start ======ok |