centos7 compile and install nginx upgrade https

Install dependencies:

 

[html]  view plain  copy
 
  1. yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel  

Download 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  

Configure nginx:

 

1. Default configuration

 

[html]  view plain  copy
 
  1. ./configure  

2. Custom configuration

     First, execute nginx -V to print out the current configuration, for example:

    

 

./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

Add the configuration you want, such as ssl, and re-execute

./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  --with-http_ssl_module

Compile and install nginx:

Set up nginx to boot and start:

 

 

[html]  view plain  copy
 
  1. vi /etc/rc.local  

In the rc.local file write:

 

 

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

Set startup file permissions:

 

 

[html]  view plain  copy
 
  1. chmod 755 /etc/rc.local  

Start and stop nginx commands:

 

 

[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 seamlessly upgrade https:

 

1. Check whether nginx supports ssl: 1. Check whether nginx supports ssl:

 

[html]  view plain  copy
 
  1. /usr/local/nginx/sbin/nginx -V  

2. Because this is an upgrade of nginx, there is no need to execute make install. First, back up the original nginx execution script:

 

 

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

 

3. Copy the newly compiled nginx execution script to the corresponding directory:

 

[html]  view plain  copy
 
  1. cd objs /  
  2. cp nginx /usr/local/nginx/sbin/  

4. Finally, smooth upgrade

 

 

[html]  view plain  copy
 
  1. cd ..  
  2. make upgrade  

5. Edit the configuration file

 

 

[html]  view plain  copy
 
  1. cd /usr/local/nginx/conf  
  2. vim nginx.conf  
[html]  view plain  copy
 
  1. listen       443;  
  2. server_name domain name;  
  3. index index.html index.htm index.php;  
  4. root project root path;  
  5.   
  6. ssl on;  
  7. ssl_certificate certificate path and file;  
  8. ssl_certificate_key certificate path and file;  
  9.   
  10. ssl_session_timeout  5m;  
  11.   
  12. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
  13. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256: HIGH:! aNULL:! MD5:! RC4:! DHE;  
  14. ssl_prefer_server_ciphers  on;  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326184103&siteId=291194637