0、准备工作(已经安装可以不需要再安装)
yum install git
yum install zlib-devel
yum install bzip2-devel
yum install openssl-devel
yum install ncurses-devel
yum install sqlite-devel
cd/usr/local/srcwget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
xz -d Python-2.7.12.tar.xz
tar -xf Python-2.7.12.tar
编译python
cd Python-2.7.12/
./configure --prefix=/usr/local/python2.7
make && make install
ln -s /usr/local/python2.7/bin/python2.7 /usr/local/bin/python
解决系统 Python 软链接指向 Python2.7 版本后,yum是不兼容 Python 2.7的,所需要指定 yum 的Python版本
vi /usr/bin/yum 将头部的
!/usr/bin/python 改成 #!/usr/bin/python2.6.6
2、nginx安装(自行度娘)
3、生成密钥文件
git clone https://github.com/letsencrypt/letsencrypt
进入letsencrypt目录cdletsencrypt
生成证书(需先停止nginx)
./letsencrypt-auto certonly --standalone --email abc@163.com -d ******
在/etc/letsencrypt/live/******(自己的域名) 下面看到privkey.pem和fullchain.pem
4、配置到nginx
server {
listen 443 ssl;
server_name www.youtbuy.com;
ssl_certificate /etc/letsencrypt/live/www.youtbuy.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.youtbuy.com/privkey.pem;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
5、证书有效期为90天,需要延期
./letsencrypt-auto certonly --renew-by-default --email abc@163.com -d ******
6、查看证书有效期的命令
openssl x509 -noout -dates -in /etc/letsencrypt/live/demo.baidu.com/cert.pem
7、设置crontab自动更新证书
00 05 01 * * /usr/local/src/letsencrypt/letsencrypt-auto certonly --renew-by-default --email 74****@.com -d demo.baidu.com
作者:品儒
链接:https://www.jianshu.com/p/3c56d444cb29
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
网友评论