下载工具
apt-get install openssl apt-get install libssl-dev yum -y install openssl openssl-devel
1、安装prce库
①进入local文件夹cd /usr/local
②下载压缩包: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
2、安装zlib库
①进入local文件夹cd /usr/local
②下载 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
3、安装OpenSSL
①进入local文件夹cd /usr/local
②下载 wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
③解压缩 tar -zxvf openssl-1.0.1t.tar.gz
④进入解压缩文件夹 cd openssl-1.0.1t
⑤执行安装
./config
make
make install
4、安装nginx
①进入local文件夹 cd /usr/local
②下载 wget https://nginx.org/download/nginx-1.10.1.tar.gz
③解压缩 tar -zxvf nginx-1.10.1.tar.gz
④进入解压缩文件夹 cd nginx-1.10.1
⑤执行安装
./configure
make
make install
5、验证nginx是否配置有误,看到如下提示,配置无误。
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
6、启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
查看进程
ps -ef|grep nginx
关闭
pkill -9 nginx
7 进入nginx cd /usr/local/nginx //这是我的nginx安装的路劲
8 重启nginx ./sbin/nginx -s reload
然后重启会遇到这个问题 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
解决方法是: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 然后在执行重启使用nginx -c的参数指定nginx.conf文件的位置
windows下面使用nginx反向代理和负载均衡
下载 openresty
然后启动命令是 nginx.exe
重启 nginx.exe -s reload
nginx配置cors
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; if ($request_method = 'OPTIONS') { return 204; }