一、nginx官网下载nginx
nginx官网:http://nginx.org/en/download.html
P.S. 这里我下载的是nginx-1.18.0.tar.gz
二、nginx安装
1、安装nginx相关模块
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
2、解压nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz
3、进入到解压后的文件夹 nginx-1.18.0中
cd nginx-1.18.0
4、编译并安装nginx
编译
# 设置/usr/local/nginx为nginx安装路径
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module
# 编译。如果需要动态替换相关模块的话,只需要执行到这一步,然后将objs文件夹中新生成的nginx替换到sbin/下即可
make
# 安装
make install
5、配置ssl
#进入/usr/local/nginx/conf,修改nginx.conf。将HTTPS注释的Server打开,并填写自己的相关配置
# HTTPS server
server {
# 监听443端口
listen 443 ssl;
# 域名或IP
server_name localhost;
# 修改证书
ssl_certificate 1_XXX.com_bundle.crt;
ssl_certificate_key 2_XXX.com.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;
location / {
root html;
index index.html index.htm;
}
}