Nginx系列一:yum安装Nginx稳定版本、主线版本

目录

一、    安装Nginx Stable稳定版    2

二、    安装Nginx Mainline主线版    3

1、登录http://nginx.org官网,复制YUM文件    3

2、创建YUM文件    4

3、安装yum的扩展包    4

4、开启nginx的主线版本仓    4

5、安装nginx的主线版    4

三、    启动Nginx    4

四、    关闭防火墙和SElinux    5

五、    使用浏览器访问Nginx默认站点    6

 

 

  1. 安装Nginx Stable稳定版

yum info nginx 查看YUM的Nginx版本

yum install nginx 安装Nginx

  1. 安装Nginx Mainline主线版-开发版本

1、登录http://nginx.org官网,复制YUM文件

 

2、创建YUM文件

[root@node1 ~]# vi /etc/yum.repos.d/nginx.repo

[nx-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

 

3、安装yum的扩展包

yum install yum-utils -y

4、开启nginx的主线版本仓

yum-config-manager --enable nginx-mainline

5、查看将要安装的Nginx版本

yum info nginx

6、安装nginx的主线版

yum install nginx -y

  1. 启动Nginx

service nginx start

ps -ef |grep nginx

 

 

  1. 关闭防火墙和SElinux

1、关闭firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

 

 

2、快速关闭SElinux:

/usr/sbin/setenforce 0 立刻关闭 SELINUX

/usr/sbin/setenforce 1 立刻启用 SELINUX

 

加到系统默认启动里面

echo "/usr/sbin/setenforce 0" >> /etc/rc.local

这样,我们在不需要在CentOS系统中开启SELINUX的时候,就可以快速的去关闭了,以及在需要的时候,在开启它。

 

 

3、关闭iptables:

[root@localhost ~]# systemctl restart iptables.service #重启防火墙使配置生效

[root@localhost ~]# systemctl enable iptables.service #设置防火墙开机启动

[root@localhost ~]# systemctl disable iptables.service #禁止防火墙开机启动

 

  1. 使用浏览器访问Nginx默认站点

 

   

猜你喜欢

转载自blog.51cto.com/monty/2540193