https://www.51anidea.com/forum.php?mod=viewthread&tid=266
(出处: Linux教程网)
一、介绍:Nginx是一款Web'服务器、反向代理服务器、电子邮件服务器。
二、安装
1、安装nginx yum源
# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2、安装nginx
# yum -y install nginx
3、启动nginx
# systemctl start nginx.service
若端口被其他服务占用,可以关闭其他服务或者开通81端口
(1)关闭其他服务
a、找到占用端口的服务
# netstat -tnlp
b、关闭服务(关闭相应服务,不一定是apache)
#systemctl stop httpd
c、重新启动nginx
# systemctl start nginx.service
(2)开通81端口
a、打开配置文件
#vi /etc/nginx/nginx.conf
根据其引用配置找到/etc/nginx/conf.d/*.conf
b、打开被nginx.conf引用的文件*.conf
# vi /etc/nginx/conf.d/*.conf
c、将80端口修改为81端口
listen 81
保存退出。
4、设置nginx开机自动启动
# systemctl enable nginx.service
5、查看nginx版本
# nginx -v
输出如下:
nginx version: nginx/1.14.2
已安装上了最新稳定版的nginx。
三、测试(若使用的是80端口则不加端口号)
浏览器打开http://服务器ip地址:81,
出现以下页面即表示安装成功:
四、卸载nginx
#yum -y remove nginx