1.启用网卡
vi /etc/sysconfig/network-scripts/ifcfg-ens33
ONBOOT=yes //是否随网络服务启动,ens33生效
2.关闭防火墙
systemctl disable firewalld.service //永久性关闭防火墙
systemctl stop firewalld.service //停止防火墙
3.确认停用selinux
vi /etc/selinux/config
设置: SELINUX=disabled
4.安装依赖
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
yum -y install wget httpd-tools vim
5.安装
http://nginx.org/en/linux_packages.html //Linux安装地址
http://nginx.org/en/download.html //windos安装
sudo yum install yum-utils
vi /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
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
ls
yum list | grep nginx //查看是否有可用的nginx包
yum install nginx -y //安装
nginx -v 查看版本号
nginx -V 查看编译参数
rpm -ql nginx 查看安装目录
启动nginx:
systemctl start nginx.service = service start nginx (以前的) 或者 nginx -s reload
systemctl restart nginx.service
systemctl reload nginx.service
systemctl stop nginx.service