nginx -v 時提示:error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,意思是找不到libpcre.so.1這個模組,而導致啟動失敗。7 X3 A* w, h: P$ U& q" F
要解決這個方法非常容易 如果是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& t) j$ t) b
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
, D; {0 O% h2 c) i' P' e; Buseradd -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 t) { ] ~( k7 m8 R
vi /etc/passwd 查看是否已新增nginx : g% o! v* K! F5 O* ?8 ^; `! j
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 |