我的nginx是編譯好的,在configure
的時(shí)候指定的prefix
(/etc/nginx)。但是我部署nginx的時(shí)候的目錄不是configure
時(shí)配置的prefix
,於是會(huì)報(bào)錯(cuò):
正在啟動(dòng) nginx:nginx: [alert] could not open error log file: open() "/etc/nginx/logs/error.log" failed (2: No such file or directory)
2014/10/28 17:56:16 [emerg] 5529#0: mkdir() "/etc/nginx/cache/client_temp" failed (2: No such file or directory)
我想在不重新編譯的情況下,讓它自動(dòng)去新的目錄下面,新的目錄是/etc/nginx2
。 有沒有可能在啟動(dòng)時(shí)指定prefix
。我的編譯參數(shù)大致是:
auto/configure --prefix="/etc/nginx" --with-debug --user=nginx --group=nginx --error-log-path="logs/error.log" --http-log-path="logs/access.log" --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --http-client-body-temp-path=cache/client_temp --http-proxy-temp-path=cache/proxy_temp --http-fastcgi-temp-path=cache/fastcgi_temp --http-scgi-temp-path=cache/scgi_temp --http-uwsgi-temp-path=cache/uwsgi_temp --with-pcre=linux/pcre-8.35 --with-zlib=linux/zlib-1.2.8
歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~
1、 從錯(cuò)誤提示看,猜測(cè)是 /etc/nginx 不存在。 建議試檢查 access_log 和 error_log 配置項(xiàng)目;
2、誰(shuí)編譯誰(shuí)執(zhí)行,不要在A機(jī)器編譯,在B機(jī)器執(zhí)行;
3、 /etc 一般不用來(lái)存放程序,可以使用 /opt 。
nginx執(zhí)行可以使用-c
指定配置文件,拿你的配置來(lái)說(shuō),比如醬紫/etc/nginx/sbin/nginx -c /link/nginx.conf
在nginx.conf
中指定其他內(nèi)容的路徑即可。
/etc
目錄一般存放的是軟體設(shè)定檔
編輯init.d下的啟動(dòng)文件,指定nginx的啟動(dòng)工作環(huán)境
/usr/sbin/nginx -p $BASE_DIR/usr/local/nginx_newdir
或指定設(shè)定檔
/usr/sbin/nginx -c $BASE_DIR/etc/nginx/nginx.conf
當(dāng)然,你可以兩個(gè)參數(shù)一起用。