安装依赖:
- yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载nginx:
- wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
- tar -zxvf nginx-1.10.1.tar.gz
- cd nginx-1.10.1
配置nginx:
1、默认配置
2、自定义配置
- ./configure \
- --prefix=/usr/local/nginx \
- --conf-path=/usr/local/nginx/conf/nginx.conf \
- --pid-path=/usr/local/nginx/conf/nginx.pid \
- --lock-path=/var/lock/nginx.lock \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --with-http_gzip_static_module \
- --http-client-body-temp-path=/var/temp/nginx/client \
- --http-proxy-temp-path=/var/temp/nginx/proxy \
- --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
- --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
- --http-scgi-temp-path=/var/temp/nginx/scgi
编译安装nginx:
设置nginx开机并启动:
在rc.local文件中写入:
- /usr/local/nginx/sbin/nginx
设置启动文件权限:
启动和停止nginx命令:
- cd /usr/local/nginx/sbin/
- ./nginx
- ./nginx -s stop
- ./nginx -s quit
- ./nginx -s reload
nginx无缝升级https:
1、查看nginx是否支持ssl:1、查看nginx是否支持ssl:
- /usr/local/nginx/sbin/nginx -V
查看 configure arguments 信息中是否包含 -with-http_ssl_module 字样,如果没有则需要重新编译。找到之前安装 Nginx 时的编译目录,配置ssl模块:
- ./configure --with-http_ssl_module
- make
2、因为这次是升级nginx,所以不需要执行 make install,首先备份原nginx执行脚本:
- mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
3、把新编译的nginx执行脚本拷贝到相应的目录下:
- cd objs/
- cp nginx /usr/local/nginx/sbin/
4、最后进行平滑升级
5、编辑配置文件
- cd /usr/local/nginx/conf
- vim nginx.conf
- listen 443;
- server_name 域名;
- index index.html index.htm index.php;
- root 项目根路径;
-
- ssl on;
- ssl_certificate 证书路径及文件;
- ssl_certificate_key 证书路径及文件;
-
- ssl_session_timeout 5m;
-
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
- ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
- ssl_prefer_server_ciphers on;
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dreamsqifan/article/details/73467672