1.安装 yum-utils
工具包
sudo yum install yum-utils
2.设置yum源,文件地址: /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
3.安装nginx
sudo yum install nginx
4.配置和命令
主配置文件路径: /etc/nginx/nginx.conf
修改events配置:
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
基本命令:
帮助: nginx -h
查看版本: nginx -v
启动: nginx
重启: nginx -s reload
停止: nginx -s stop
检查配置: nginx -t
服务命令:
查看服务状态: systemctl status nginx
设置开机启动: systemctl enable nginx
启动nginx服务: systemctl start nginx
重启nginx服务: systemctl reload nginx
停止nginx服务: systemctl stop nginx