Amazon Linux 2023에서 설정한 방식입니다.
1.sudo dnf install -y openssl mod_ssl
2. sudo systemctl restart httpd
3. sudo wget -O /etc/yum.repos.d/snapd.repo \
https://bboozzoo.github.io/snapd-amazon-linux/al2023/snapd.repo
4. dnf install snapd -y
4. sudo snap install --classic certbot
5. sudo ln -s /snap/bin/certbot /usr/bin/certbot
6. sudo vi /etc/httpd/config/httpd.conf
ServerName hello.com
Listen 80
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName hello.com
</VirtualHost>
해당 설정을 해주지 않는다면 다음 에러가 출력된다.
Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.
2가지 방식 중 한가지를 선택한다. 첫 번째 방식의 경우에는 인증키 발급부터 아파치 웹서버에 대한 설정으로 자동으로 구성해주며 crontab을 통한 인증키를 자동으로 갱신해준다. 반면 2번째 방식의 경우에는 인증키만을 발급해주며 아파치 설정을 수동으로 설정해줘야 한다.
인증키 발급 및 자동 설정 방식
sudo certbot --apache
인증키 발급 방식
sudo certbot certonly --apache
관리자에 대한 이메일 주소
약관여부
등록하고자 하는 도메인을 입력하면 성공적으로 인증키가 발급된다.
snap로 설치한경우 자동으로 갱신이 되도록 설정이 되어있으며 이는 systemctl list-timers
에서 확인할 수 있다.
구체적인 파일은 /etc/systemd/system/snap.certbot.renew.service와 snap.certbot.renew.timer에 해당하는 내용들이 작성되어있다.
/etc/systemd/system/snap.certbot.renew.service
[Unit]
# Auto-generated, DO NOT EDIT
Description=Service for snap application certbot.renew
# 의존성
Requires=var-lib-snapd-snap-certbot-3834.mount
# 함께 시작하는 다른 유닛
Wants=network.target
# 유닛이 시작될 순서 지정
After=var-lib-snapd-snap-certbot-3834.mount network.target snapd.apparmor.service
X-Snappy=yes
[Service]
EnvironmentFile=-/etc/environment
ExecStart=/usr/bin/snap run --timer="00:00~24:00/2" certbot.renew
SyslogIdentifier=certbot.renew
Restart=no
WorkingDirectory=/var/snap/certbot/3834
TimeoutStopSec=30
Type=oneshot
/etc/systemd/system/snap.certbot.renew.timer
[Unit]
# Auto-generated, DO NOT EDIT
Description=Timer renew for snap application certbot.renew
Requires=var-lib-snapd-snap-certbot-3834.mount
After=var-lib-snapd-snap-certbot-3834.mount
X-Snappy=yes
[Timer]
Unit=snap.certbot.renew.service
OnCalendar=*-*-* 03:42
OnCalendar=*-*-* 20:07
[Install]
WantedBy=timers.target
Ref
https://certbot.eff.org/instructions?ws=apache&os=centosrhel7&tab=standard
https://github.com/bboozzoo/snapd-amazon-linux
'Linux > web server' 카테고리의 다른 글
아파치 환경변수 mod_env 설정 (0) | 2024.06.25 |
---|---|
Apache 다른 경로로 서비스 실행하기 (0) | 2024.06.08 |