search

Home  >  Q&A  >  body text

Specify prefix when nginx starts

My nginx is compiled, and the prefix(/etc/nginx) is specified when configure. But when I deploy nginx, the directory is not the prefix configured when configure, so an error will be reported:

正在启动 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)

I want to let it automatically go to a new directory without recompiling. The new directory is /etc/nginx2. Is it possible to specify prefix at startup. My compilation parameters are roughly:

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
天蓬老师天蓬老师2781 days ago666

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 17:27:25

    1. From the error message, it is guessed that /etc/nginx does not exist. It is recommended to check the access_log and error_log configuration items;
    2. Whoever compiles is responsible for execution. Don’t compile on machine A and execute on machine B;
    3. /etc is generally not used to store programs, you can use /opt.

    reply
    0
  • 给我你的怀抱

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

    nginx execution can use the path of other content specified in -c指定配置文件,拿你的配置来说,比如酱紫/etc/nginx/sbin/nginx -c /link/nginx.confnginx.conf.


    /etcThe directory generally stores software configuration files

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:27:25

    Edit the startup file under init.d and specify the startup working environment of nginx

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

    Or specify the configuration file

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

    Of course, you can use both parameters together.

    reply
    0
  • Cancelreply