简体   繁体   English

删除NGINX日志后,如何重新启动日志记录?

[英]How do you restart logging after deleting an NGINX log?

I deleted my NGINX log because it was very large, thinking that NGINX would automatically create a new one in its place. 我删除了NGINX日志,因为它很大,以为NGINX会自动在其位置创建一个新日志。 It didn't, and now I don't have logs. 没有,现在我没有日志。 The file was previously located at /opt/nginx/logs/error.log . 该文件先前位于/opt/nginx/logs/error.log I tried creating a new file with the same permissions in the same location but it doesn't appear to have helped. 我尝试在同一位置创建一个具有相同权限的新文件,但似乎没有帮助。 I'm running nginx/1.4.7 on an ubuntu 12.10 server. 我正在ubuntu 12.10服务器上运行nginx / 1.4.7。

How do I get my logging back? 如何找回我的日志?

I've tried sudo service nginx restart and it says nginx: unrecognized service . 我试过sudo service nginx restart ,它说nginx: unrecognized service I think this might be because I'm using NGINX with Phusion Passenger to serve a rails app and Passenger has changed a few things. 我认为这可能是因为我将NGINX与Phusion Passenger一起使用来提供Rails应用程序,而Passenger改变了一些事情。 For example, NGINX lives in /opt/nginx instead of init.d . 例如,NGINX位于/opt/nginx而不是init.d

Passenger author here. 乘客作者在这里。

Restarting Nginx would actually make the log file come back. 重新启动Nginx的实际上使日志文件回来。 It's just that you're not using the right method to restart Nginx, because your Nginx install was installed from source. 只是您没有使用正确的方法来重新启动Nginx,因为您的Nginx安装是从源代码安装的。

Init scripts, eg /etc/init.d/nginx and service nginx restart , are not provided by the default Nginx source code. 默认的Nginx源代码未提供初始化脚本,例如/etc/init.d/nginxservice nginx restart Init scripts are actually extensions provided by the operating system's Nginx package. 初始化脚本实际上是操作系统的Nginx软件包提供的扩展。 If you install Nginx from source, then you can't use init scripts to control Nginx anymore. 如果从源代码安装Nginx,那么您将无法再使用初始化脚本来控制Nginx。 Instead, you will use more generic operating system primitives to control Nginx, such as PID files and signals. 相反,您将使用更多通用的操作系统原语来控制Nginx,例如PID文件和信号。 Learn more at the Passenger documentation . 在旅客文档中了解更多信息

Restarting Nginx is to be done by sending signals to it and by starting it again through the Nginx command. 通过向Nginx发送信号并通过Nginx命令再次启动Nginx来完成。 For example: 例如:

sudo kill $(cat /opt/nginx/logs/nginx.pid)
sudo /opt/nginx/sbin/nginx

To learn more about restarting an Nginx that was installed from source, read this part of the Passenger documentation . 要了解有关重新启动从源代码安装的Nginx的更多信息,请阅读乘客文档的这一部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM