首页 > 编程知识 正文

怎么重启nginx,重启tomcat服务

时间:2023-05-06 12:03:51 阅读:160763 作者:2903

1、方式一:手动启动方式

1.1、《cd usr/local/nginx/syldxn》./nginx 1.2、重新启动kill -HUP主进程号或进程号文件路径,或单击《cd /usr/local/nginx/syldxn 关闭usr/local/nginx/conf/nginx.conf或《cd /usr/local/nginx/syldxn》./nginx -t 1.4、查询/nginx -t 1.4 停止kill -QUIT主进程编号停止kill -TERM主进程编号强制停止kill -9 nginx如果在logs目录中设置了pid文件路径,则为kill-signal type '/nginx.PID'1.5,检查nginx服务是否启动ps -ef|grep nginx 2,方式2 :在配置/etc/init .中

vi /etc/init.d/nginx ()输入以下代码) ) )。

#!/yld xn/bash # nginxstartupscriptforthenginxhttpserver # itisv.0.0.2 version.# chkconfig 3360-8515 # description 3360 nginxisahigh-performancewebandproxyserver.# ithasalotoffeatures, utit ' snotforeveryone.# processname : nginx # pidfile :/var/run/nginx.PID # config 3360/usr/local/nginx nging nginx/conf/nginx.conf nginx _ PID=/var/run/nginx.pidretetx init.d/functions # sourcenetworkingconfiguration checkthatnetworkingisup.[ $ { networking }|| exit0# startnginxdaemonsfunctions.start ({ if [-e $ nginx _ PID ] ); thenecho ' nginxalreadyrunning . ' exit1fiecho-n $ ' starting $ Prog : ' daemon $ nginxd-c $ { nginx _ config } rete nginx return $ retval } # stopnginxdaemonsfunctions.stop ({ echo-n $ } echo [ $ retval=0] RM-f/var/lock/subsys reloadnginxservicefunctions.reload kill-hup ` cat $ { nginx _ PID } ` killproc $ nginxd-hup retval=$? echo } # seehowwewerecalled.case ' $1' instart (start; stop ) stop; 读; 读; 重新开始(stopstart; 状态(status $ Prog retval=$? * echo $ ' usage 3360 $ Prog { start|reload|status } ' exit1esac exit $ retval 3360 wq保存并退出

设置对文件的访问权限

chmod ax/etc/init.d/nginx (ax==allusercanexecute的所有用户均可执行) ) ) ) ) ) ) )。

同样,您也可以修改nginx配置文件nginx.conf,然后使用上面的命令重新加载并运行新的配置文件。

设置启动时的自动启动:

方式一:配置到/etc/rc.local

如果将此命令添加到rc.local文件中,nginx将在打开电源时缺省启动

vi /etc/rc.local

添加一行/etc/init.d/nginx start保存并退出后,将启用下一次重新启动。

方法将nginx配置为自启动服务

1 .添加到服务管理列表,开机自动启动

[ root @ nginx~~ ] # chkconfig-- add nginx

[ root @ nginx~~ ] # chkconfignginxon

[ root @ nginx~~ ] # chkconfig nginx-- list

nginx 0:关断1:关断2:开关:开关4:开关5:开关6:关断

2、启动、停止nginx,重新启动无中断服务

[ root @ example~] # servicenginxstart

[ root @ example~] # servicenginxstop

[ root @ example~] # servicenginxreload

3 .请确认端口

[ root @ nginx~~ ] # netstat-ntlp|grep :80

TCP 00.0.0.0:80.0.0.0: * listen 3889/nginx

同样适用于Mysql、php-fpm等其他服务

这样就可以在控制台上轻松操作nginx。 确认nginx的当前状态,启动nginx,停止nginx,重新启动nginx…

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。