centos安装nginx并配置SSL证书

风流不在谈锋胜,袖手无言味最长。这篇文章主要讲述centos安装nginx并配置SSL证书相关的知识,希望能为你提供帮助。
安装nginx的命令
sudo yum install epel-release
sudo yum install nginx
让nginx随系统启动而启动
sudo systemctl enable nginx
常用命令
启动:nginx
【centos安装nginx并配置SSL证书】停止:nginx -s stop
重载配置:nginx -s reload
配置路径:/etc/nginx/
日志路径:/var/log/nginx
打开配置文件/etc/nginx/conf/nginx.conf
server
{
listen 443;
server_name your-domain.com www.your-domain.com; #你的域名
ssl on;
ssl_certificate/root/ssl/your-domain.crt; #SSL证书文件
ssl_certificate_key /root/ssl/your-domain.key; #SSL证书文件
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_buffer_size128k;
proxy_buffers32 32k;
proxy_busy_buffers_size 128k;
proxy_pass http://127.0.0.1:912;
}
}
server
{
listen 80;
server_name your-domain.com www.your-domain.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
配置完成之后要重新加载nginx:nginx -s reload
如果是之前别人维护的服务器,不知道配置文件在哪里的话,可以直接使用find命令查找:
[root@localhost /]# find / -name nginx.conf
/root/lnmp1.5/conf/nginx.conf
/usr/local/nginx/conf/nginx.conf

    推荐阅读