Home  >  Article  >  Operation and Maintenance  >  What you need to know about certbot opens Amazon EC2 host https (code sharing)

What you need to know about certbot opens Amazon EC2 host https (code sharing)

奋力向前
奋力向前forward
2021-09-03 10:20:331733browse

In the previous article "A brief analysis of checking port occupancy and Kill in Wind and Linux (with code)", we learned about checking port occupancy and Kill in Wind and Linux. The following article will tell you about checking port occupancy and Kill in Wind and Linux. Come and take a look.

What you need to know about certbot opens Amazon EC2 host https (code sharing)

There are so many cloud host operators in China, why would you buy a foreign host? You must be doing some shady things...

Just kidding, maybe you are trying to make a fortune in silence.

I have said before that you can use certbot to apply for a free certificate and open the https

portal

certbot cannot be executed smoothly on Amazon's host, but you can manually modify the source code so that certbot can complete the task.

Use vim to open certbot

#搜索找到这一行
elif [ -f /etc/redhat-release ]; then

#然后替换成如下:
elif [ -f /etc/redhat-release ] || grep 'cpe:.*:amazon_linux:2' /etc/os-release > /dev/null 2>&1; then

#保存退出收工

so that you can use certbot--nginx in one step.

But the premise is that your nginx must be installed under the /etc directory. If it is not in this directory, you can copy the config configuration file of your current nginx installation directory to /etc/nginx . If not, create it manually. After executing certbot --nginx in this way, copy the final configuration file it generated to the current nginx directory, and then restart nginx -s reload.

What the article says certbot needs to modify The place is here https://github.com/certbot/certbot/blob/master/certbot-auto#L779 You can view it on github

Automatically update certificate

#使用root用户
sudo -i

#增加定时任务
crontab -e

#每个月1号2点30分更新
30 2 1 * * /path/to/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"

#dry run
./path/to/certbot-auto renew --dry-run

Recommended learning :Linux video tutorial

The above is the detailed content of What you need to know about certbot opens Amazon EC2 host https (code sharing). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:chuchur.com. If there is any infringement, please contact admin@php.cn delete