首頁  >  問答  >  主體

nginx啟動時指定prefix

我的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。我的編譯參數大致是:

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
天蓬老师天蓬老师2712 天前605

全部回覆(3)我來回復

  • phpcn_u1582

    phpcn_u15822017-05-16 17:27:25

    1、 從錯誤提示看,猜測是 /etc/nginx 不存在。 建議試檢查 access_log 和 error_log 配置項目;
    2、誰編譯誰執行,不要在A機器編譯,在B機器執行;
    3、 /etc 一般不用來存放程序,可以使用 /opt 。

    回覆
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:27:25

    nginx執行可以使用-c指定配置文件,拿你的配置来说,比如酱紫/etc/nginx/sbin/nginx -c /link/nginx.confnginx.conf中指定其他內容的路徑即可。


    /etc目錄一般存放的是軟體設定檔

    回覆
    0
  • ringa_lee

    ringa_lee2017-05-16 17:27:25

    編輯init.d下的啟動文件,指定nginx的啟動工作環境

    /usr/sbin/nginx -p $BASE_DIR/usr/local/nginx_newdir
    

    或指定設定檔

    /usr/sbin/nginx -c $BASE_DIR/etc/nginx/nginx.conf 
    

    當然,你可以兩個參數一起用。

    回覆
    0
  • 取消回覆