重启openresty失败。请问正确命令

安装的路径是:
/usr/local/openresty/nginx

今天修改了nginx.conf文件,需要保存,重新启动

执行:[root@newoneacreland ~]# /usr/local/openresty/nginx -s reload

-bash: /usr/local/openresty/nginx: Is a directory

[root@newoneacreland ~]# /usr/local/openresty/nginx/sbin/nginx -p pwd/ -c conf/nginx.conf

nginx: [alert] could not open error log file: open() "/root/logs/error.log" failed (2: No such file or directory)

请问正确的重启方式?

阅读 6.6k
2 个回答

你在写重启命令时, 并没有使用 nginx 的可执行文件啊.

/usr/local/openresty/nginx -s reload

改为

/usr/local/openresty/nginx/sbin/nginx -s reload

当然上面命令生效的前提是你的 openresty 已经启动了, 才可以 reload 嘛.

第二条命令出错:

/usr/local/openresty/nginx/sbin/nginx -p `pwd`/ -c conf/nginx.conf

是因为你指定了 prefix 为当前目录, 可以看到你的当前目录就是 ~, 即 root 用户的家目录, 即 /root 目录. 而这个目录下你并没有为 nginx 创建 /root/logs 这个目录, 因此报错. 如果不太在意这个配置项目, 直接把这参数去掉就是了, 默认 nginx 的 prefix path 会指向 /usr/local/nginx/, 当然你用的是 openresty, 那就是指向 /usr/local/openresty/nginx/.

参考: 官方文档 - nginx 命令行

看报错信息..

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进