centos 7.2 yum安装Nginx教程
1、添加Nginx存储库
sudo yum install epel-release
2、安装Nginx
sudo yum install nginx
3、启动Nginx
sudo systemctl start nginx
4、添加到防火墙
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
注意:firewall is not running
这里启动下防火墙
systemctl start firewalld
开放端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-port=23560/tcp
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=33481/tcp
5、安装成功后的Nginx地址
/usr/share/nginx/html/ 站点目录
/etc/nginx/conf.d/ 自定义Nginx站点配置文件存放目录
/etc/nginx/nginx.conf 全局配置
nginx -c nginx.confN ginx启动
6、查看nginx版本
nginx -V
查看到是:nginx/1.12.2
返回到Nginx的目录
cd /usr/share/
停止Nginx
systemctl stop nginx
启动Nginx
systemctl start nginx
卸载Nginx
yum remove nginx