我的nginx是編譯好的,在configure
的時候指定的prefix
(/etc/nginx)。但是我部署nginx的時候的目錄不是configure
時配置的prefix
,于是會報錯:
正在啟動 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)
我想在不重新編譯的情況下,讓它自動去新的目錄下面,新的目錄是/etc/nginx2
。有沒有可能在啟動時指定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
歡迎選擇我的課程,讓我們一起見證您的進步~~
1、 從錯誤提示看,猜測是 /etc/nginx 不存在。 建議試檢查 access_log 和 error_log 配置項;
2、誰編譯誰執(zhí)行,不要在A機器編譯,在B機器執(zhí)行;
3、 /etc 一般不用來存放程序,可以使用 /opt 。
nginx執(zhí)行可以使用-c
指定配置文件,拿你的配置來說,比如醬紫/etc/nginx/sbin/nginx -c /link/nginx.conf
在nginx.conf
中指定其他內(nèi)容的路徑即可。
/etc
目錄一般存放的是軟件配置文件
編輯init.d下的啟動文件,指定nginx的啟動工作環(huán)境
/usr/sbin/nginx -p $BASE_DIR/usr/local/nginx_newdir
或者指定配置文件
/usr/sbin/nginx -c $BASE_DIR/etc/nginx/nginx.conf
當然,你可以兩個參數(shù)一起用。