1.环境搭建
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2,安装PCRE
//进入工作目录
cd /opt/
//下载
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
//解压
tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make && make install
3,安装nginx
cd /opt/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
# 加载 stream 模块
# ./configure --prefix=/madi/nginx/ --with-stream=dynamic
./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/pcre-8.35
make && make install
//不出意外输入下面命令即可查看版本
/opt(你的安装)/nginx/sbin/nginx -v
4,常用命令
/opt(你的安装)/nginx/sbin/nginx -s reload # 重新载入配置文件
/opt(你的安装)/nginx/sbin/nginx -s reopen # 重启 Nginx
/opt(你的安装)/nginx/sbin/nginx -s stop # 停止 Nginx
5,常用配置
server {
listen 443 ssl;
server_name xiaochun.cloud;
# ssl证书地址
ssl_certificate /etc/nginx/conf.d/xiaochun.cloud/xiaochun.cloud.pem;
ssl_certificate_key /etc/nginx/conf.d/xiaochun.cloud/xiaochun.cloud.key;
# ssl验证相关配置
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# try_files $uri $uri/ /index.html;
# gzip_static on;
client_max_body_size 1000m; # 请求体最大1G
client_body_timeout 120;
proxy_pass http://192.168.21.103:3003;
proxy_http_version 1.1;
# websocket 配置
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 1200s; # 无操作断开时间
}
# location /api {
# proxy_pass http://192.168.1.7:8008;
# proxy_read_timeout 90;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $http_connection;
# 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_set_header X-Forwarded-Proto $scheme;
# proxy_cache_bypass $http_upgrade;
# }
error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root /usr/share/nginx/html;
# }
}