### 1、安装nginx,超简单
> sudo apt-get install nginx
### 2、修改配置文件,超简单
> sudo vim /etc/nginx/sites-available/default
或者下载到本地编辑并上传覆盖
### 3、停止、重启服务,超简单
> sudo nginx
> sudo nginx -s stop
### 4、通过设置反向代理,实现负载均衡,提高性能
1)、修改配置文件,如下
```
upstream webs{
server 127.0.0.1:81 max_fails=3 fail_timeout=40s;
server 127.0.0.1:82 max_fails=3 fail_timeout=40s;
server 127.0.0.1:83 max_fails=3 fail_timeout=40s;
server 127.0.0.1:84 max_fails=3 fail_timeout=40s;
server 127.0.0.1:85 max_fails=3 fail_timeout=40s;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://webs;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 1800;
proxy_set_header X-Scheme $scheme;
}
}
gzip on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
```
2)、停止、重启nginx