![](https://img-blog.csdnimg.cn/img_convert/9678886df1b7864d6117fce586e5cf93.png)
Linux安装:
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
下载nginx-1.16.1.tar.gz
tar -zxvf nginx-1.16.1.tar.gz
mkdir -p /usr/local/nginx
进到nginx-1.16.1.tar.gz里
./configure --prefix=/usr/local/nginx
make && make install
![](https://img-blog.csdnimg.cn/img_convert/09f83c85c5db36c85ca8861e1f8a676d.png)
树形展示目录结构:tree命令(yum install tree)
nginx命令:
配置系统变量:
vim /etc/profile
修改成这样,可能目录不相同
JAVA_HOME=/usr/local/jdk1.8.0_171
export MAVEN_HOME=/usr/local/apache-maven-3.5.4
export NGINX_HOME=/usr/local/nginx
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$NGINX_HOME/sbin:$PATH
PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
验证配置文件正确性:
nginx -t
启停Nginx:
nginx
nginx -s stop
开放80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
重新加载:
nginx -s reload
nginx配置文件结构:
![](https://img-blog.csdnimg.cn/img_convert/edec2693bdf99c5c31e7e2fce2babb59.png)
Nginx应用:
部署静态文件:
![](https://img-blog.csdnimg.cn/img_convert/cd1b10512d902f106294c3172462adad.png)
反向代理:
![](https://img-blog.csdnimg.cn/img_convert/6ae4b47d1d139fa2790825d6a6093bb1.png)
![](https://img-blog.csdnimg.cn/img_convert/5739168e9a76c9846dd8c1f43c5ea76f.png)
正向代理与反向代理最简单的区别: 正向代理隐藏的是用户,反向代理隐藏的是服务器
![](https://img-blog.csdnimg.cn/img_convert/e30e4f00692939dd456228131b5b319f.png)
负载均衡:
![](https://img-blog.csdnimg.cn/img_convert/b9cf64324e30bdcad546d1e5130f2b69.png)
![](https://img-blog.csdnimg.cn/img_convert/996b2fddef7808e5a9cab7fe6d121f47.png)
![](https://img-blog.csdnimg.cn/img_convert/e476d5f8b778d9341e0ee82dd2434772.png)