nginx默认安装80端口修改

本文指导如何修改Nginx默认的80端口为8888,以避免与Tomcat等服务冲突。涉及配置文件位置、default文件编辑、重启及配置文件加载。遇到'invalid PID number'错误时,提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

nginx默认安装80端口修改

nginx默认安装80端口修改

在这里插入图片描述
nginx安装启动发现80默认端口冲突,一般是和tomcat服务冲突了。
所以在这里我们直接取修改nginx的默认端口。
通过whereis nginx我们知道了nginx的配置文件目录
在配置文件目录下的sites-available目录中我们找到了default文件,进行修改,修改前先备份。
在这里插入图片描述
vi进去后将80端口修改成8888端口号
在这里插入图片描述
修改后
在这里插入图片描述

重启nginx,启动后没有报错。
在这里插入图片描述
改对应映射nginx.conf配置文件后可以重新加载一下
nginx -s reload

参考:
You can run two server on the same port using nginx:

https://serverfault.com/questions/242679/how-to-run-multiple-nginx-instances-on-different-port
If you installed gitlab-omnibus and if you want to change the default port:

Open /etc/gitlab/gitlab.rb
Add external_url “http:// domain:NewPort”
Run gitlab-ctl reconfigure
If you have installed gitlab manually locate nginx’s folder (you can type whereis nginx on the console) and modify gitlab’s file on the sites-available subfolder. Normally the file you have to modify is: /etc/nginx/sites-available/gitlab

/etc/nginx/sites-available

其他报错
nginx重启报错:nginx: [error] invalid PID number “” in “/run/nginx.pid”
问题描述:执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错
    nginx: [error] invalid PID number “” in “/run/nginx.pid”

解决办法
    需要先执行

nginx -c /etc/nginx/nginx.conf

nginx.conf文件的路径可以从nginx -t的返回中找到。

nginx -s reload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云浩舟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值