1:上传压缩包
[root@localhost ~]# ls
nginx-1.18.0.tar.gz
2:解决依赖关系
[root@localhost ~]# yum -y install openssl-devel pcre-devel zlib-devel
3解压压缩包
[root@localhost ~]# tar -xf nginx-1.18.0.tar.gz -C /usr/src/
4进入目录编译安装
[root@localhost ~]# cd /usr/src/nginx-1.18.0/
[root@localhost nginx-1.18.0 ~]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module && make && make install
./configure为里面的一个安装,切换到压缩目录就可以查看到,--prefix=/usr/local/nginx指定安装目录,--user=nginx --group=nginx指定用户以及组,--with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module模块,根据你要使用什么模块去添加,make && make install编译安装
5创建软链接
[root@localhost nginx-1.18.0 ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx
6:开启Nginx软件,关闭防火墙,网页访问
[root@localhost nginx-1.18.0 ~]# nginx
[root@localhost nginx-1.18.0 ~]# iptables -F
nginx可以使用killall不关闭,网页服务,不影响用户体验,刷新网页
killall -s HUP nginx 重新刷新配置