1.选定安装文件目录
例:cd /usr/local/src
2.安装pcre库
```
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make
make install
```
3.安装zlib库
```
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
```
4.安装openssl库
```
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
```
5.安装nginx
```
wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar -zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
./configure
make
make install
```
6.nginx默认安装于/usr/local/nginx文件目录下
7.进入/usr/local/nginx/sbin目录,执行./nginx 启动nginx
```
./nginx //启动nginx
./nginx -s stop //停止nginx
./nginx -s reload //重新加载nginx
./nginx -s quit //退出nginx
```
8.执行curl localhost查看打印为 Welcome to nginx! 即安装nginx成功
9.前端代码打包放入/usr/local/nginx/html下
10.编辑/usr/local/nginx/conf 的 nginx.conf文件
```
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
#自定义端口
listen 6079;
#本地服务ip
server_name localhost;
location / {
#前端代码目录
root /usr/local/nginx/html/Cosmo;
#首页
index index.html;
}
}
# 将 */dds/* 的url中/dds之前的由以下url代理
location /dds/ {
proxy_pass http://192.168.1.157:8081;
}
}