第一步:先查看tomcat占用的进程号

  ps -ef|grep tomcat

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

注意:我的启动的tomcat比较多所以有两个:

linux 小总结 随笔 第1张

 

第二步:根据进程号,查看进程所占用的端口

  netstat -apn

linux 小总结 随笔 第2张

 

 一个配置三个端口 分别对象应不同的端口

 

 

 

nginx关闭重启

启动、停止 nginx

# 1.启动nginx shell> nginx # 可通过ps -ef | grep nginx查看nginx是否已启动成功 # 2.停止nginx shell> nginx -s stop # 3. 重新启动 shell> nginx -s reload
[root@iZuf6cquliue1go3pupgm2Z sbin]# ps -ef | grep nginx
root     10528  4074  0 15:57 pts/0    00:00:00 grep nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]# 
[root@iZuf6cquliue1go3pupgm2Z sbin]# ./nginx //启动nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]# 
[root@iZuf6cquliue1go3pupgm2Z sbin]# ps -ef | grep nginx //查看nginx是否启动
root     10530     1  0 15:57 ?        00:00:00 nginx: master process ./nginx
nobody   10531 10530  0 15:57 ?        00:00:00 nginx: worker process
root     10533  4074  0 15:57 pts/0    00:00:00 grep nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]# ./nginx -s stop //停止nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]# 
[root@iZuf6cquliue1go3pupgm2Z sbin]# ps -ef | grep nginx 
root     10536  4074  0 15:57 pts/0    00:00:00 grep nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]# 
[root@iZuf6cquliue1go3pupgm2Z sbin]# 

[root@iZuf6cquliue1go3pupgm2Z sbin]# ./nginx -s reload  //重启nginx
[root@iZuf6cquliue1go3pupgm2Z sbin]#

PS:提示是出现端口被占用。需要我们到 vi nginx.conf 文件修改端口号

[root@iZuf6cquliue1go3pupgm2Z sbin]#  ./nginx 
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

 netstat -ntlp|grep 80查看端口号 80被java占用所有我换成了8081

linux 小总结 随笔 第3张

 linux 小总结 随笔 第4张

重启提示这个问题:[root@iZuf6cquliue1go3pupgm2Z sbin]# ./nginx -s reload
                               nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

解决

           使用nginx -c的参数指定nginx.conf文件的位置

             添加上路径/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 linux 小总结 随笔 第5张

看nginx.pid文件已经有了。

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄