Centos Install Nginx Mainline Version and Configure Https

CentOS 7 安装nginx(非编译安装)

http://nginx.org/en/linux_packages.html#RHEL-CentOS

1
2
3
yum install sudo
sudo yum install yum-utils
vim /etc/yum.repos.d/nginx.repo
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
1
2
3
sudo yum-config-manager --enable nginx-mainline
sudo yum install nginx
vim /etc/nginx/conf.d/default.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
server {
    listen  80;
    server_name llinx.me;
    rewrite ^(.*)$  https://$host$1 permanent;
}

server {
    listen 443 ssl;
    server_name llinx.me;

    ssl_certificate /etc/ssl/llinx.me.cer;
    ssl_certificate_key /etc/ssl/llinx.me.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv2 SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers on;
    location / {
        root /var/www;
        index index.html index.htm;
    }

}

PS: ssl_certificate_key 这玩意拼写不要错了, 我也不知道从哪找了一个, 导致 nginx -t 的时候一直提示 ssl_certficate_key ( <= 这个是错误的, 少了个i) , 但是对着看半天也没看出啥问题 nginx -V 也有https模块的

Licensed under CC BY-NC-SA 4.0
记录平时瞎折腾遇到的各种问题, 方便查找
使用 Hugo 构建
主题 Stack 3.29.0Jimmy 设计