1. 程式人生 > >centos7編譯安裝nginx及無縫升級https

centos7編譯安裝nginx及無縫升級https

itl download err sha2 進行 ast ref 配置文件 CP

安裝依賴:

[html] view plain copy
  1. yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
下載nginx:
[html] view plain copy
  1. wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
  2. tar -zxvf nginx-1.10.1.tar.gz
  3. cd nginx-1.10.1
配置nginx:

1、默認配置

[html] view plain copy
  1. ./configure
2、自定義配置

[html] view plain copy
  1. ./configure \
  2. --prefix=/usr/local/nginx \
  3. --conf-path=/usr/local/nginx/conf/nginx.conf \
  4. --pid-path=/usr/local/nginx/conf/nginx.pid \
  5. --lock-path=/var/lock/nginx.lock \
  6. --error-log-path=/var/log/nginx/error.log \
  7. --http-log-path=/var/log/nginx/access.log \
  8. --with-http_gzip_static_module \
  9. --http-client-body-temp-path=/var/temp/nginx/client \
  10. --http-proxy-temp-path=/var/temp/nginx/proxy \
  11. --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
  12. --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
  13. --http-scgi-temp-path=/var/temp/nginx/scgi
編譯安裝nginx:

[html] view plain copy
  1. make
  2. make install
設置nginx開機並啟動:

[html] view plain copy
  1. vi /etc/rc.local
在rc.local文件中寫入:

[html] view plain copy
  1. /usr/local/nginx/sbin/nginx
設置啟動文件權限:

[html] view plain copy
  1. chmod 755 /etc/rc.local
啟動和停止nginx命令:

[html] view plain copy
  1. cd /usr/local/nginx/sbin/
  2. ./nginx
  3. ./nginx -s stop
  4. ./nginx -s quit
  5. ./nginx -s reload
nginx無縫升級https:

1、查看nginx是否支持ssl:1、查看nginx是否支持ssl:

[html] view plain copy
  1. /usr/local/nginx/sbin/nginx -V
查看 configure arguments 信息中是否包含 -with-http_ssl_module 字樣,如果沒有則需要重新編譯。找到之前安裝 Nginx 時的編譯目錄,配置ssl模塊:

[html] view plain copy
  1. ./configure --with-http_ssl_module
  2. make
2、因為這次是升級nginx,所以不需要執行 make install,首先備份原nginx執行腳本:

[html] view plain copy
  1. mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

3、把新編譯的nginx執行腳本拷貝到相應的目錄下:

[html] view plain copy
  1. cd objs/
  2. cp nginx /usr/local/nginx/sbin/
4、最後進行平滑升級

[html] view plain copy
  1. cd ..
  2. make upgrade
5、編輯配置文件

[html] view plain copy
  1. cd /usr/local/nginx/conf
  2. vim nginx.conf
[html] view plain copy
  1. listen 443;
  2. server_name 域名;
  3. index index.html index.htm index.php;
  4. root 項目根路徑;
  5. ssl on;
  6. ssl_certificate 證書路徑及文件;
  7. ssl_certificate_key 證書路徑及文件;
  8. ssl_session_timeout 5m;
  9. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  10. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  11. ssl_prefer_server_ciphers on;

版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/dreamsqifan/article/details/73467672

centos7編譯安裝nginx及無縫升級https