1. /usr/local/nginx/sbin/nginx -V 查看nginx版本与编译安装了哪些模块
nginx version: nginx/1.16.1
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11
2. 安装openssh(如果操作系统之前没有安装)
3. 下载openssl-1.1.0f(版本看操作时的情况了),不必安装
4. 可能还需要下载安装时用到的pcre-8.43与zlib-1.2.11(版本看操作时的情况了),不必安装
5. 下载nginx 1.10.3, 并且configure
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.0f
6. 执行make ,千万不要make install 否则会覆盖现有的nginx
7. 关闭nginx
8. copy ~/download/nginx-1.10.3/objs/nginx 到现有的/usr/local/nginx/sbin/nginx
9. /usr/local/nginx/sbin/nginx -V 查看编译安装的模块
nginx version: nginx/1.16.1
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0f
10. 修改nginx.conf文件
server {
server_name xxx.yyy.com;
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/xxx.com_server.txt; #公钥
ssl_certificate_key /usr/local/nginx/conf/xxx.com_private.txt; #私钥
location / {
# location的一堆配置
#
#
# ################
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
###########################80端口的处理###############################
server {
listen 80;
server_name xxx.yyy.com;
send_timeout 1800;
rewrite ^(.*)$ https://xxx.yyy.com$1 permanent; # 80端口跳转
}