Ruby on rails 停止和关闭的命令;启动nginx
我正在开发Rails v2.3.2应用程序。在Ubuntu机器上 现在,我想让两个rake任务分别停止和启动*Nginx*,用于此的命令是什么Ruby on rails 停止和关闭的命令;启动nginx,ruby-on-rails,ubuntu,nginx,Ruby On Rails,Ubuntu,Nginx,我正在开发Rails v2.3.2应用程序。在Ubuntu机器上 现在,我想让两个rake任务分别停止和启动*Nginx*,用于此的命令是什么 task :start_nginx do puts "stop Nginx..." system '...' #What is the command to stop Nginx? end task :stop_nginx do puts "stop Nginx..." system '...' #W
task :start_nginx do
puts "stop Nginx..."
system '...' #What is the command to stop Nginx?
end
task :stop_nginx do
puts "stop Nginx..."
system '...' #What is the command to start Nginx?
end
这取决于系统
如果您使用的是upstart,则命令如下:
start nginx
stop nginx
否则,可能是以下情况之一:
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/rc.d/nginx start
/etc/rc.d/nginx stop
甚至可能:
nginx
killall -9 nginx
如果您刚刚在Ubuntu上安装了常规nginx软件包,那么您已经有了一个启动脚本,如:
/etc/init.d/nginx (start|stop)
如果您没有,请查看:
通过以root用户身份运行/usr/local/nginx/sbin/nginx来启动服务器
您可以通过执行以下命令来停止服务器
kill `cat /var/run/nginx.pid`
关于debian/ubuntu
/etc/init.d/nginx (start|stop|reload)
在centOS/RHEL
service nginx (start|stop|reload)
您必须以root用户身份登录。Ubuntu中正确的策略是使用service而不是init.d
sudo service nginx stop
sudo service nginx start
sudo service nginx restart
为什么有两次启动和停止?它们都需要运行吗?或者其中一个是正常的?这取决于您的系统,例如debian使用
/etc/init.d
,而arch使用/etc/rc.d