1.源安装和包管理工具安装
2.如何检查自己有没有安装nginx
nginx -v 查看nginx版本
systemctl status nginx 查看服务状态
安装sudo命令
切换到root的几种方式
su -
exit
yum install sudo安装sudo
centos中nginx不在默认仓库中,所以需要epel仓库
但是这样有两个仓库,怎么切换
sudo命令的作用: 以用户的账号执行root命令,但是每次执行必须输入密码,确保了每次执行命令的安全性
服务状态:
nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since 一 2024-11-25 10:22:44 CST; 11s ago Process: 3669 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 3667 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 3661 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 3671 (nginx) Tasks: 5 CGroup: /system.slice/nginx.service ├─3671 nginx: master process /usr/sbin/nginx ├─3672 nginx: worker process ├─3673 nginx: worker process ├─3674 nginx: worker process └─3675 nginx: worker process 11月 25 10:22:44 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server... 11月 25 10:22:44 localhost.localdomain nginx[3667]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 11月 25 10:22:44 localhost.localdomain nginx[3667]: nginx: configuration file /etc/nginx/nginx.conf test is successful 11月 25 10:22:44 localhost.localdomain systemd[1]: Started The nginx HTTP and reverse proxy server.
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
loaded:加载完成, /usr/lib/systemd/system/nginx.service: 服务配置地点 disabled:开机自启动设置关闭 vendor preset: disabled 禁用服务器默认配置
Process: 3669 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS): 主进程启动成功 ExecStart执行命令 /usr/sbin/nginx执行路径 3669进程
在主进程启动前有几个检查
Process: 3667 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) 检查nginx配置的语法
Process: 3661 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) 检查nginx是否已存在进程, 有就删除
在CentOS/RHEL上安装Nginx
1.安装EPEL仓库(Nginx通常在EPEL仓库中):sudo yum install epel-release
2.更新软件包列表::sudo yum update
3.安装Nginx:sudo yum install nginx
4.启动Nginx服务:sudo systemctl start nginx
5.设置开机自启:sudo systemctl enable nginx
6.检查Nginx状态:sudo systemctl status nginx
主机ping虚拟机通,但是访问不到虚拟机nginx
问题:防火墙阻挡
关闭防火墙: systemctl stop firewalld(解决)
如何判断是防火墙的原因
1.直到nginx访问的端口, 2.防火墙将哪些端口阻挡了
判断nginx用了哪些端口:
1.看配置文件 2.监听端口
nginx -t检查配置文件语法正确
快速进入etc目录 cd /etc
标签:status,code,sudo,disabled,nginx,usr,安装 From: https://www.cnblogs.com/cat-cat/p/18567040