nginx启动时指定prefix
天蓬老师
天蓬老师 2017-05-16 17:25:25
0
3
604

我的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
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(3)
phpcn_u1582

1、 从错误提示看,猜测是 /etc/nginx 不存在。 建议试检查 access_log 和 error_log 配置项;
2、谁编译谁执行,不要在A机器编译,在B机器执行;
3、 /etc 一般不用来存放程序,可以使用 /opt 。

给我你的怀抱

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


/etc目录一般存放的是软件配置文件

左手右手慢动作

编辑init.d下的启动文件,指定nginx的启动工作环境

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

或者指定配置文件

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

当然,你可以两个参数一起用。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!