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
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.
nginx execution can use the path of other content specified in
-c
指定配置文件,拿你的配置来说,比如酱紫/etc/nginx/sbin/nginx -c /link/nginx.conf
在nginx.conf
./etc
The directory generally stores software configuration filesEdit the startup file under init.d and specify the startup working environment of nginx
Or specify the configuration file
Of course, you can use both parameters together.