欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 高考 > linux配置nginx

linux配置nginx

2025/2/24 19:13:11 来源:https://blog.csdn.net/Awesome_py/article/details/143742252  浏览:    关键词:linux配置nginx

1.查看nginx状态

systemctl status nginx

状态如果是Active: active (running)则是正常的

[root@hcss-ecs-9b96 ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)Active: active (running) since Wed 2024-11-13 13:41:11 CST; 16min agoProcess: 603696 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)Process: 603639 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)Process: 603637 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)Main PID: 603699 (nginx)Tasks: 3 (limit: 11427)Memory: 16.9MCGroup: /system.slice/nginx.service├─603699 nginx: master process /usr/sbin/nginx├─603700 nginx: worker process└─603701 nginx: worker process

2.查看Nginx进程

如果Nginx正在运行,您还可以使用ps命令来查看Nginx进程

ps aux | grep nginx

3.检查Nginx配置文件是否正确无误

nginx -t

4.查看Nginx的版本

nginx -v
# 如果查看更详细
nginx -V

5.修改nginx配置

vim /etc/nginx/nginx.conf

增加容器端口8090指向域名

server {listen 80;server_name www.tieyongjie.cn;  # 替换为您的域名location / {proxy_pass http://localhost:8090;  # 指向Docker容器的端口8080proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;}

6. 设置开机自启动

# 设置 nginx 开机自启动
systemctl enable nginx
# 验证
systemctl is-enabled nginx

输出如下即表示开机自启动设置成功

[root@hcss-ecs-9b96 ~]# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@hcss-ecs-9b96 ~]# systemctl is-enabled nginx
enabled

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词