nginx简介:
Nginx (engine x) 是是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强。
搭建环境:
阿里云CentOS Linux release 7.4.1708 (Core)
nginx-1.11.12.tar.gz
一、 准备
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
二、 下载nginx
wget http://nginx.org/download/nginx-1.11.12.tar.gz
三、 安装nginx
tar zxvf nginx-1.11.12.tar.gz
cd nginx-1.11.12
./configure
make && make install
四、 启动nginx
查看安装位置:whereis nginx
查看版本:
cd /usr/local/nginx/sbin
./nginx –v
判断配置文件是否正确:
./nginx -t -c /usr/local/nginx/conf/nginx.conf
启动:./nginx -c /usr/local/nginx/conf/nginx.conf
重载:./nginx -s reload
五、 测试
http://地址
说明:nginx默认是80端口
六、 配置https证书
配置如下:
# HTTPS server
server {
listen 443 ssl;
server_name 域名;
root /home/ruoyi;
ssl_certificate /home/scert/文件名.pem;
ssl_certificate_key /home/scert/文件名.key;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
client_max_body_size 20M;
proxy_pass http://localhost:8888;
}
}
说明:为了提高证书的加密安全,启用TLS1.2,但配置完后显示仍然是TLS1.0,后来发现,nginx上面配置了很多vhost,只将一个站点修改为TLS1.2是不起作用的,于是,将所有站点的配置都加上了TLS1.2的支持,问题解决。
本文暂时没有评论,来添加一个吧(●'◡'●)