1.安装依赖
yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl-devel //或者一起安装四个依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2.下载nginx的tar包
3.解压下载的tar包
tar -zxvf nginx-tar.gz
4.安装nginx
//进入解压的nginx目录 cd /nginx //执行命令 ./configure //执行make命令 make //执行make install命令 make install //安装成功后,在usr/local/nginx中有目录,sbin文件下是启动脚本
5.启动nginx
//进入usr/local/nginx/sbin目录 ./nginx
centos 默认防火墙是没有开放端口的
查看开放的端口号
//查看默认开放的端口号 firewall-cmd --list-all
//设置开放的端口号
firewall-cmd -add-service=http -permanent firewall-cmd -add-port=80/tcp --permanent //重启防火墙 firewall-cmd -reload