1、准备yum源
vi /etc/yum.repo.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enable=1
准备好了源之后,更新源
$ yum clean all
$ yum makecache
2、安装nginx
$ yum install -y nginx
安装成功之后可以通过 $ nginx -v查看版本
# nginx -v
nginx version: nginx/1.13.0
3、启动nginx并通过浏览器查看页面
systemctl start nginx
===编译安装命令===
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module