makerskorean.kr
- Hostname โ server.makerskorean.kr ์ค์
์ฐ๋ถํฌ ์๋ฒ 24.04.3 LTS์ด๊ณ ๋ณ๊ฒฝ ๋ช ๋ น์ด
์ฐ๋ถํฌ 24.04.3 LTS์์ ํธ์คํธ๋ค์์ server.makerskorean.kr๋ก ๋ณ๊ฒฝํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ด๋ค์ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค:
1๏ธโฃ ํธ์คํธ๋ค์ ๋ณ๊ฒฝ
sudo hostnamectl set-hostname server.makerskorean.kr
2๏ธโฃ /etc/hosts ํ์ผ ์์
ํธ์คํธ๋ค์์ด ์ ๋๋ก ์ธ์๋๋๋ก /etc/hosts ํ์ผ์ ์ถ๊ฐ/์์ ํด์ผ ํฉ๋๋ค.
์์:
sudo nano /etc/hosts
๋ด์ฉ์ ๋ค์ ์ค์ ์ถ๊ฐํ๊ฑฐ๋ ๊ธฐ์กด ์ค์ ์์ :
127.0.0.1 localhost
127.0.1.1 server.makerskorean.kr server
3๏ธโฃ ๋ณ๊ฒฝ ํ์ธ
hostnamectl
๋๋
hostname
4๏ธโฃ ์ ์ฉ ํ์ธ (์ฌ๋ถํ ์์ด๋ ๋ฐ์๋จ)
ping server.makerskorean.kr
๐ ์ด๋ ๊ฒ ํ๋ฉด ์์คํ
ํธ์คํธ๋ค์์ด server.makerskorean.kr๋ก ์ค์ ๋ฉ๋๋ค.
ํน์ ๋ด๋ถ DNS ํ๊ฒฝ๋ ํจ๊ป ์ฐ๊ณ ๊ณ์ ๊ฐ์? ๊ทธ๋ ๋ค๋ฉด /etc/hosts ์์ ์ธ์๋ DNS ์๋ฒ์ ํด๋น ํธ์คํธ๋ค์์ ๋ฑ๋กํด์ผ ์ธ๋ถ์์ ์ ๊ทผ ๊ฐ๋ฅํฉ๋๋ค.
ํ์ฌ makerskorean.kr๋๋ฉ์ธ์ ํด๋ผ์ฐ๋ํ๋ ์ด ํ๋ฆฌํ๋ ์ฌ์ฉ์ค์ธ๋ฐ
/etc/hosts ์์ ์ธ์๋ DNS ์๋ฒ์ ํด๋น ํธ์คํธ๋ค์์ ๋ฑ๋กํด์ผ ์ธ๋ถ์์ ์ ๊ทผ ๊ฐ๋ฅ
๋ง์ต๋๋ค ๐ /etc/hosts ์์ ์ ๋ก์ปฌ ์๋ฒ ๋ด๋ถ์์๋ง ํธ์คํธ๋ค์์ ์ธ์ํ๊ฒ ํ๋ ์ค์ ์ด๊ณ , ์ธ๋ถ์์ server.makerskorean.kr๋ก ์ ์ํ๋ ค๋ฉด DNS ์๋ฒ(์ง๊ธ์ Cloudflare) ์์ ํด๋น ํธ์คํธ๋ค์์ ๋ฑ๋กํด์ผ ํฉ๋๋ค.
๐ Cloudflare์์ ํธ์คํธ๋ค์ ๋ฑ๋ก ๋ฐฉ๋ฒ (Free Plan ๊ธฐ์ค)
- Cloudflare ๋ก๊ทธ์ธ
โ makerskorean.kr ๋๋ฉ์ธ์ ์ ํํฉ๋๋ค. - DNS ๊ด๋ฆฌ ๋ฉ๋ด๋ก ์ด๋
โ “DNS” ํญ์ ํด๋ฆญํฉ๋๋ค. - ์ ๋ ์ฝ๋ ์ถ๊ฐ
- Type:
A(IPv4 ์ฃผ์) ๋๋AAAA(IPv6 ์ฃผ์) - Name:
server(์ฆ,server.makerskorean.kr์ด ๋ฉ๋๋ค) - IPv4 address: ์๋ฒ์ ๊ณต์ธ IP ์ฃผ์ ์ ๋ ฅ
- Proxy status:
- ์ผ๋ฉด(์ฃผํฉ์ ๊ตฌ๋ฆ) Cloudflare ํ๋ก์๋ฅผ ํตํด ์ ์ โ DDoS ๋ณดํธ, ์บ์ฑ ๊ฐ๋ฅ
- ๋๋ฉด(ํ์ ๊ตฌ๋ฆ) ์ง์ ์๋ฒ๋ก ์ ์ โ ๋จ์ DNS๋ง ์ฌ์ฉ
- Type:
- ์ ์ฅ ํ ์ ์ฉ ํ์ธ
- DNS ์ ํ๋ ๋ณดํต ์๋ถ~์์๊ฐ ๋ด์ ์๋ฃ๋ฉ๋๋ค.
- ํ์ธ ๋ฐฉ๋ฒ:
dig server.makerskorean.kr nslookup server.makerskorean.kr ping server.makerskorean.kr
๐ ์ ๋ฆฌ
/etc/hostsโ ์๋ฒ ๋ด๋ถ์์๋ง ์ ํจ- Cloudflare DNS โ ์ธ๋ถ ํด๋ผ์ด์ธํธ๊ฐ
server.makerskorean.kr๋ก ์ ์ ๊ฐ๋ฅํ๊ฒ ๋ง๋๋ ํต์ฌ - ๋ฐ๋์ ์๋ฒ์ ๊ณต์ธ IP๋ฅผ Cloudflare DNS์ ๋ฑ๋กํด์ผ ์ธ๋ถ ์ ๊ทผ์ด ๊ฐ๋ฅํฉ๋๋ค.
ํน์ ์ด ์๋ฒ๊ฐ ์น ์๋น์ค์ฉ์ธ์ง, ์๋๋ฉด ๋ด๋ถ ๊ด๋ฆฌ์ฉ(์: SSH ์ ์)์ธ์ง์ ๋ฐ๋ผ Cloudflare ํ๋ก์ ์ค์ ์ ๋ค๋ฅด๊ฒ ํ๋ ๊ฒ ์ข์ต๋๋ค. ์ํ์๋ฉด ์ ๊ฐ ์น ์๋น์ค์ฉ vs ๊ด๋ฆฌ์ฉ์ ๋ง๋ ์ค์ ์ฐจ์ด๋ฅผ ์ ๋ฆฌํด๋๋ฆด๊น์?
์๋ ์
๋ฐ์ดํธ ์ค์
โ ๊ธฐ๋ณธ ํ๊ฒฝ ์ค๋น ์๋ฃ
2. Virtual Server ์์ฑ
- Virtualmin โ Create Virtual Server
- Domain name:
makerskorean.kr - ์ต์ ์ฒดํฌ:
- Setup website for domain โ
- Setup DNS zone โ
- Setup mail for domain โ
- Setup SSL certificate โ
- Setup MySQL database โ
3. Sub-server ์์ฑ (ํด๋ โ ์๋ธ๋๋ฉ์ธ)
- Virtualmin โ Create Sub-server
- Domain name:
subdomain.makerskorean.kr - Document root:
/var/www/html/subdomain์ง์ - ๊ธฐ์กด ์๋ํ๋ ์ค ์ค์น ํด๋ ๊ทธ๋๋ก ์ฌ์ฉ
- SSL ์ธ์ฆ์ ๋ฐ๊ธ (Letโs Encrypt)
- ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๊ฒฐ ํ์ธ
4. Cloudflare DNS ์ค์
- Cloudflare ๋ฌด๋ฃ ํ๋ ์ฌ์ฉ ์ค์ด๋ฏ๋ก DNS ๋ ์ฝ๋ ์ถ๊ฐ ํ์
- makerskorean.kr Zone์์ ๋ค์ ๋ ์ฝ๋ ์ถ๊ฐ:
- Proxy(๊ตฌ๋ฆ ์์ด์ฝ) โ ํ์ ์ ๋๊ธฐ (์๋ํ๋ ์ค ์ค์น ์ HTTP-01 ์ธ์ฆ ํ์)
5. ์๋ํ๋ ์ค ์ค์ ๋ณ๊ฒฝ
/var/www/html/subdomain/wp-config.phpํ์ธ- ์๋ํ๋ ์ค ๊ด๋ฆฌ์ ํ์ด์ง ์ ์ โ ์ค์ โ ์ผ๋ฐ
- WordPress ์ฃผ์(URL):
https://subdomain.makerskorean.kr - ์ฌ์ดํธ ์ฃผ์(URL):
https://subdomain.makerskorean.kr
- WordPress ์ฃผ์(URL):
- ์ ์ฅ ํ ๋ก๊ทธ์ธ ์ฌ์๋
6. SSL ์ธ์ฆ์ ์ ์ฉ
- Virtualmin โ
Server Configuration โ SSL Certificate - Letโs Encrypt โ
Request Certificate - ๋๋ฉ์ธ:
subdomain.makerskorean.krํฌํจ
7. ํ ์คํธ ๋ฐ ๊ฒ์ฆ
- ๋ธ๋ผ์ฐ์ ์์
https://subdomain.makerskorean.kr์ ์ โ ์๋ํ๋ ์ค ์ ์ ํ์ dig subdomain.makerskorean.kr Aโ ์๋ฒ IP ํ์ธ- SSL Labs โ ์ธ์ฆ์ ์ ํจ์ฑ ๊ฒ์ฌ
- ์๋ํ๋ ์ค ๋ด๋ถ ๋งํฌ๊ฐ ๋ชจ๋ ์ URL๋ก ๋ณ๊ฒฝ๋์๋์ง ํ์ธ
โ ์ต์ข ์ด์ ์ฒดํฌ๋ฆฌ์คํธ
- [ ] Virtualmin Wizard ์๋ฃ
- [ ] makerskorean.kr Virtual Server ์์ฑ
- [ ] subdomain.makerskorean.kr Sub-server ์์ฑ ๋ฐ Document root ๋งคํ
- [ ] Cloudflare DNS ๋ ์ฝ๋ ์ถ๊ฐ
- [ ] ์๋ํ๋ ์ค URL ๋ณ๊ฒฝ
- [ ] SSL ์ธ์ฆ์ ๋ฐ๊ธ ๋ฐ ์ ์ฉ
- [ ] ์ ์ ํ ์คํธ ๋ฐ ๋งํฌ ์ ์ ํ์ธ
์ด ์ ์ฐจ๋ฅผ ๋ฐ๋ฅด๋ฉด ๊ธฐ์กด /var/www/html/subdomain ๊ตฌ์กฐ๋ฅผ ๊ทธ๋๋ก ์ ์งํ๋ฉด์, https://subdomain.makerskorean.kr ํํ๋ก ์๋น์คํ ์ ์์ต๋๋ค.
๐ ์ํ์๋ฉด ์ ๊ฐ ์ฌ๋ฌ ๊ฐ์ ์๋ธ๋๋ฉ์ธ์ ํ ๋ฒ์ Virtualmin Sub-server๋ก ๋ฑ๋กํ๋ ์๋ํ ์ ๋ต๊น์ง ์ ๋ฆฌํด๋๋ฆด ์ ์์ต๋๋ค.
๋ฉ์ผ ์๋ฒ(Postfix/Dovecot) ํ์ฑ
์ข์ต๋๋ค ๐ ์ฐ๋ถํฌ 24.04.3 LTS ํ๊ฒฝ์์ ๋ฉ์ผ ์๋ฒ(Postfix + Dovecot) ๋ฅผ ํ์ฑํํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ก ์งํํ๋ฉด ๋ฉ๋๋ค.
๐ 1. ํจํค์ง ์ค์น
sudo apt update
sudo apt install postfix dovecot-core dovecot-imapd dovecot-pop3d -y
- Postfix โ ๋ฉ์ผ ์ก์ (MTA) ๋ด๋น
- Dovecot โ ๋ฉ์ผ ์์ (IMAP/POP3) ๋ด๋น
๐ 2. Postfix ๊ธฐ๋ณธ ์ค์
์ค์น ์ค์ “๋ฉ์ผ ์๋ฒ ๊ตฌ์ฑ ์ ํ”์ ๋ฌป์ต๋๋ค.
- Internet Site ์ ํ
- System mail name โ
makerskorean.kr์ ๋ ฅ
์ค์น ํ /etc/postfix/main.cf ํ์ผ์ ์ด์ด ์ฃผ์ ์ค์ ์ ํ์ธ/์์ ํฉ๋๋ค:
sudo nano /etc/postfix/main.cf
์์ ์ค์ :
myhostname = server.makerskorean.kr
mydomain = makerskorean.kr
myorigin = /etc/mailname
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
home_mailbox = Maildir/
๐ 3. Dovecot ์ค์
๋ฉ์ผ๋ฐ์ค๋ฅผ Maildir ํ์์ผ๋ก ์ฌ์ฉํ๋๋ก ์ค์ ํฉ๋๋ค.
/etc/dovecot/conf.d/10-mail.conf ์์ :
mail_location = maildir:~/Maildir
์ฌ์ฉ์๋ณ Maildir ์์ฑ:
sudo mkdir -p /etc/skel/Maildir/{cur,new,tmp}
sudo chmod -R 700 /etc/skel/Maildir
๊ธฐ์กด ์ฌ์ฉ์ ํ์๋ ์ ์ฉ:
mkdir -p ~/Maildir/{cur,new,tmp}
chmod -R 700 ~/Maildir
๐ 4. ์๋น์ค ํ์ฑํ ๋ฐ ์ฌ์์
sudo systemctl enable postfix
sudo systemctl enable dovecot
sudo systemctl restart postfix
sudo systemctl restart dovecot
๐ 5. ๋ฐฉํ๋ฒฝ ์ค์ (UFW ์ฌ์ฉ ์)
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 587/tcp # Submission
sudo ufw allow 143/tcp # IMAP
sudo ufw allow 993/tcp # IMAPS
sudo ufw allow 110/tcp # POP3
sudo ufw allow 995/tcp # POP3S
๐ 6. DNS ๋ ์ฝ๋ ์ค์ (Cloudflare์์)
์ธ๋ถ์์ ์ ์์ ์ผ๋ก ๋ฉ์ผ ์ก์์ ํ๋ ค๋ฉด ๋ฐ๋์ DNS ๋ ์ฝ๋๊ฐ ํ์ํฉ๋๋ค:
- MX ๋ ์ฝ๋ โ
makerskorean.krโserver.makerskorean.kr - A ๋ ์ฝ๋ โ
server.makerskorean.krโ ์๋ฒ ๊ณต์ธ IP - SPF ๋ ์ฝ๋ (TXT) โ
v=spf1 a mx ~all - DKIM/DMARC โ ๋ณด์ ๋ฐ ์คํธ ๋ฐฉ์ง์ฉ (์ถ๊ฐ ์ค์ ํ์)
โ
์ฌ๊ธฐ๊น์ง ํ๋ฉด ๊ธฐ๋ณธ์ ์ธ Postfix/Dovecot ๋ฉ์ผ ์๋ฒ๊ฐ ํ์ฑํ๋ฉ๋๋ค.
๋ค๋ง ์ค์ ์ด์ ์์๋ SSL/TLS ์ธ์ฆ์(Letโs Encrypt), ์คํธ ํํฐ(SpamAssassin, Rspamd), DKIM/DMARC ์ค์ ๊น์ง ํด์ฃผ์
์ผ ์ธ๋ถ ๋ฉ์ผ ์๋น์ค(Gmail, Naver, Daum ๋ฑ)์์ ์ ์์ ์ผ๋ก ์ ๋ขฐ๋ฐ์ต๋๋ค.
๐ ์ํ์๋ฉด ์ ๊ฐ ๋ณด์ ๊ฐํ๋ฅผ ์ํ SSL/TLS + DKIM/DMARC ์ค์ ๋จ๊ณ๊น์ง ์ด์ด์ ์ ๋ฆฌํด๋๋ฆด๊น์?
ufw๋ ์ฐ๋ถํฌ์์ ๊ธฐ๋ณธ ๋ฐฉํ๋ฒฝ ๊ด๋ฆฌ ๋๊ตฌ์ด์ง๋ง, ๋ชจ๋ ๋ฐฐํฌํ์ ๊ธฐ๋ณธ ์ค์น๋์ด ์์ง๋ ์์ต๋๋ค. ๋ฉ์์ง์ ๋์จ ๊ฒ์ฒ๋ผ “command not found”๊ฐ ๋จ๋ ์ด์ ๋ ์์ง ์ค์น๋์ง ์์๊ธฐ ๋๋ฌธ์ด์์.
๐ง ํด๊ฒฐ ๋ฐฉ๋ฒ
1. UFW ์ค์น
sudo apt update
sudo apt install ufw -y
2. UFW ํ์ฑํ
sudo ufw enable
3. ๋ฉ์ผ ์๋ฒ ํฌํธ ์ด๊ธฐ
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 587/tcp # Submission
sudo ufw allow 143/tcp # IMAP
sudo ufw allow 993/tcp # IMAPS
sudo ufw allow 110/tcp # POP3
sudo ufw allow 995/tcp # POP3S
4. ์ํ ํ์ธ
sudo ufw status verbose
๐ ๋์ (UFW ๋์ iptables/nftables ์ฌ์ฉ)
๋ง์ฝ UFW ๋์ ์ง์ iptables/nftables๋ฅผ ์ฐ๊ณ ์ถ๋ค๋ฉด, ์ฐ๋ถํฌ 24.04์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก nftables๊ฐ ๊ถ์ฅ๋ฉ๋๋ค. ์์:
sudo iptables -A INPUT -p tcp --dport 25 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 587 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 143 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 993 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 110 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 995 -j ACCEPT
๐ ์ด์ ํ๊ฒฝ์ ๋ฐ๋ผ UFW ์ค์น ํ ๊ฐ๋จํ ๊ด๋ฆฌํ๋ ๋ฐฉ๋ฒ์ด ํธ๋ฆฌํ๊ณ , ๋ณด์ ์ ์ฑ ์ ์ธ๋ฐํ๊ฒ ์ ์ดํ๋ ค๋ฉด nftables/iptables๋ฅผ ์ง์ ์ฐ๋ ๊ฒ ์ข์ต๋๋ค.
ํน์ ์๋ฒ๊ฐ ์ธ๋ถ ์๋น์ค์ฉ(๋ฉ์ผ ์ก์์ )์ธ์ง, ์๋๋ฉด ๋ด๋ถ ํ
์คํธ์ฉ์ธ์ง ์๋ ค์ฃผ์๋ฉด ๋ฐฉํ๋ฒฝ ์ ์ฑ
์ ๋ ๊ตฌ์ฒด์ ์ผ๋ก ์ถ์ฒํด๋๋ฆด ์ ์์ด์.
ub2020@makerskorean:~$ sudo hostnamectl set-hostname server.makerskorean.kr
[sudo] password for ub2020:
ub2020@makerskorean:~$ sudo nano /etc/hosts
ub2020@makerskorean:~$ hostnamectl
Static hostname: server.makerskorean.kr
Icon name: computer-desktop
Chassis: desktop ๐ฅ๏ธ
Machine ID: d793135f40e344dd86694bad80d34fdb
Boot ID: 519e7fa5993f444b831e5a3752bf928a
Operating System: Ubuntu 24.04.3 LTS
Kernel: Linux 6.8.0-90-generic
Architecture: x86-64
Hardware Vendor: Dell Inc.
Hardware Model: Inspiron 3268
Firmware Version: 1.9.0
Firmware Date: Fri 2018-07-13
Firmware Age: 7y 6month 2d
ub2020@makerskorean:~$ ping server.makerskorean.kr
PING server.makerskorean.kr (127.0.1.1) 56(84) bytes of data.
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=1 ttl=64 time=0.072 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=2 ttl=64 time=0.085 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=4 ttl=64 time=0.072 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=5 ttl=64 time=0.074 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=6 ttl=64 time=0.069 ms
64 bytes from server.makerskorean.kr (127.0.1.1): icmp_seq=7 ttl=64 time=0.071 ms
^C
— server.makerskorean.kr ping statistics —
7 packets transmitted, 7 received, 0% packet loss, time 6121ms
rtt min/avg/max/mdev = 0.069/0.073/0.085/0.005 ms
ub2020@makerskorean:~$ sudo apt update
[sudo] password for ub2020:
Hit:1 http://kr.archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://kr.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:3 http://kr.archive.ubuntu.com/ubuntu noble-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease
Hit:6 https://download.webmin.com/download/newkey/repository stable InRelease
Hit:7 https://software.virtualmin.com/vm/7/gpl/apt virtualmin InRelease
Reading package listsโฆ Done
Building dependency treeโฆ Done
Reading state informationโฆ Done
All packages are up to date.
ub2020@makerskorean:~$ sudo apt install postfix dovecot-core dovecot-imapd dovecot-pop3d -y
Reading package listsโฆ Done
Building dependency treeโฆ Done
Reading state informationโฆ Done
postfix is already the newest version (3.8.6-1build2).
postfix set to manually installed.
dovecot-core is already the newest version (1:2.3.21+dfsg1-2ubuntu6.1).
dovecot-core set to manually installed.
dovecot-imapd is already the newest version (1:2.3.21+dfsg1-2ubuntu6.1).
dovecot-imapd set to manually installed.
dovecot-pop3d is already the newest version (1:2.3.21+dfsg1-2ubuntu6.1).
dovecot-pop3d set to manually installed.
The following packages were automatically installed and are no longer required:
lockfile-progs m4 sendmail-base sendmail-cf sensible-mda
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
ub2020@makerskorean:~$ sudo apt autoremove
Reading package listsโฆ Done
Building dependency treeโฆ Done
Reading state informationโฆ Done
The following packages will be REMOVED:
lockfile-progs m4 sendmail-base sendmail-cf sensible-mda
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
After this operation, 2,515 kB disk space will be freed.
Do you want to continue? [Y/n] y
Auto packing the repository in background for optimum performance.
See “git help gc” for manual housekeeping.
[master f6d3a76] saving uncommitted changes in /etc prior to apt run
Author: ub2020 ub2020@server.makerskorean.kr
5 files changed, 5 insertions(+), 6 deletions(-)
(Reading database โฆ 372877 files and directories currently installed.)
Removing sendmail-base (8.18.1-2) โฆ
Removing lockfile-progs (0.1.19build2) โฆ
Removing sendmail-cf (8.18.1-2) โฆ
Removing m4 (1.4.19-4build1) โฆ
Removing sensible-mda (8.18.1-2) โฆ
Processing triggers for install-info (7.1-3build2) โฆ
Processing triggers for man-db (2.12.0-4build2) โฆ
[master 0174324] committing changes in /etc made by “apt autoremove”
Author: ub2020 ub2020@server.makerskorean.kr
21 files changed, 4254 deletions(-)
delete mode 100755 mail/Makefile
delete mode 100644 mail/access.db
delete mode 120000 mail/aliases
delete mode 100644 mail/aliases.db
delete mode 100644 mail/databases
delete mode 100644 mail/sendmail.cf
delete mode 120000 mail/smrsh/mail.local
delete mode 120000 mail/smrsh/procmail
delete mode 100644 mail/submit.cf
delete mode 100644 mail/tls/no_prompt
delete mode 100644 mail/tls/sendmail-client.cfg
delete mode 100644 mail/tls/sendmail-client.crt
delete mode 100644 mail/tls/sendmail-client.csr
delete mode 100644 mail/tls/sendmail-common.key
delete mode 100644 mail/tls/sendmail-common.prm
delete mode 100644 mail/tls/sendmail-server.cfg
delete mode 100644 mail/tls/sendmail-server.crt
delete mode 100644 mail/tls/sendmail-server.csr
delete mode 100755 mail/tls/starttls.m4
delete mode 100644 mail/trusted-users
ub2020@makerskorean:~$ sudo nano /etc/postfix/main.cf
ub2020@makerskorean:~$ sudo nano /etc/dovecot/conf.d/10-mail.conf
ub2020@makerskorean:~$ sudo mkdir -p /etc/skel/Maildir/{cur,new,tmp}
ub2020@makerskorean:~$ sudo chmod -R 700 /etc/skel/Maildir
ub2020@makerskorean:~$ mkdir -p ~/Maildir/{cur,new,tmp}
ub2020@makerskorean:~$ chmod -R 700 ~/Maildir
ub2020@makerskorean:~$ sudo systemctl enable postfix
Synchronizing state of postfix.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable postfix
ub2020@makerskorean:~$ sudo systemctl enable dovecot
Synchronizing state of dovecot.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable dovecot
ub2020@makerskorean:~$ sudo systemctl restart postfix
ub2020@makerskorean:~$ sudo systemctl restart dovecot
ub2020@makerskorean:~$ sudo ufw allow 25/tcp
sudo: ufw: command not found
ub2020@makerskorean:~$ sudo apt install ufw -y
Reading package listsโฆ Done
Building dependency treeโฆ Done
Reading state informationโฆ Done
The following NEW packages will be installed:
ufw
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 169 kB of archives.
After this operation, 869 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu noble/main amd64 ufw all 0.36.2-6 [169 kB]
Fetched 169 kB in 0s (1,282 kB/s)
[master 9e75753] saving uncommitted changes in /etc prior to apt run
Author: ub2020 ub2020@server.makerskorean.kr
3 files changed, 11 insertions(+), 2 deletions(-)
Preconfiguring packages โฆ
Selecting previously unselected package ufw.
(Reading database โฆ 372441 files and directories currently installed.)
Preparing to unpack โฆ/archives/ufw_0.36.2-6_all.deb โฆ
Unpacking ufw (0.36.2-6) โฆ
Setting up ufw (0.36.2-6) โฆ
Creating config file /etc/ufw/before.rules with new version
Creating config file /etc/ufw/before6.rules with new version
Creating config file /etc/ufw/after.rules with new version
Creating config file /etc/ufw/after6.rules with new version
Created symlink /etc/systemd/system/multi-user.target.wants/ufw.service โ /usr/lib/systemd/system/ufw.service.
Processing triggers for rsyslog (8.2312.0-3ubuntu9.1) โฆ
Processing triggers for man-db (2.12.0-4build2) โฆ
[master fa44bb0] committing changes in /etc made by “apt install ufw -y”
Author: ub2020 ub2020@server.makerskorean.kr
18 files changed, 592 insertions(+)
create mode 100644 default/ufw
create mode 100755 init.d/ufw
create mode 100644 logrotate.d/ufw
create mode 120000 rc1.d/K01ufw
create mode 120000 rcS.d/S01ufw
create mode 100644 rsyslog.d/20-ufw.conf
create mode 120000 systemd/system/multi-user.target.wants/ufw.service
create mode 100644 ufw/after.init
create mode 100644 ufw/after.rules
create mode 100644 ufw/after6.rules
create mode 100644 ufw/before.init
create mode 100644 ufw/before.rules
create mode 100644 ufw/before6.rules
create mode 100644 ufw/sysctl.conf
create mode 100644 ufw/ufw.conf
create mode 100644 ufw/user.rules
create mode 100644 ufw/user6.rules
ub2020@makerskorean:~$ sudo ufw enable
Firewall is active and enabled on system startup
ub2020@makerskorean:~$ sudo ufw allow 25/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw allow 587/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw allow 143/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw allow 993/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw allow 110/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw allow 995/tcp
Rule added
Rule added (v6)
ub2020@makerskorean:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
— —— —-
25/tcp ALLOW IN Anywhere
587/tcp ALLOW IN Anywhere
143/tcp ALLOW IN Anywhere
993/tcp ALLOW IN Anywhere
110/tcp ALLOW IN Anywhere
995/tcp ALLOW IN Anywhere
25/tcp (v6) ALLOW IN Anywhere (v6)
587/tcp (v6) ALLOW IN Anywhere (v6)
143/tcp (v6) ALLOW IN Anywhere (v6)
993/tcp (v6) ALLOW IN Anywhere (v6)
110/tcp (v6) ALLOW IN Anywhere (v6)
995/tcp (v6) ALLOW IN Anywhere (v6)
ub2020@makerskorean:~$
vscode๊ฐ hostname์ด ๋ณ๊ฒฝ์ด ๋์ด ssh์ ์์ด ์๋จ
ํธ์คํธ๋ค์์ server.makerskorean.kr๋ก ๋ฐ๊พธ์ ๋ค VS Code์์ SSH ์ ์์ด ์ ๋๋ ๊ฑด, ๋๋ถ๋ถ SSH ์ค์ (hostname/IP ๋ถ์ผ์น) ๋ฌธ์ ๋๋ฌธ์
๋๋ค. ์ ๋ฆฌํด ๋๋ฆด๊ฒ์:
๐ ์์ธ
- VS Code Remote-SSH ์ค์
VS Code๋~/.ssh/configํ์ผ์ ์ ์ฅ๋Host์ด๋ฆ์ ๊ธฐ์ค์ผ๋ก ์ ์ํฉ๋๋ค.
ํธ์คํธ๋ค์์ ๋ฐ๊พธ๋ฉด ๊ธฐ์กด ์ค์ (makerskorean.kr๋๋ IP)๊ณผ ๋ฌ๋ผ์ ธ ์ ์์ด ๋๊ธธ ์ ์์ต๋๋ค. - DNS ๋ฐ์ ๋ฌธ์
Cloudflare DNS์server.makerskorean.krโ ์๋ฒ ๊ณต์ธ IP๊ฐ ๋ฑ๋ก๋์ง ์์๊ฑฐ๋ ์์ง ์ ํ๋์ง ์์๋ค๋ฉด ์ธ๋ถ์์ ์ด๋ฆ์ผ๋ก ์ ์์ด ์ ๋ฉ๋๋ค. - SSH ์๋ฒ๋ IP ๊ธฐ๋ฐ์ผ๋ก ๋์
์ค์ ๋ก SSH๋ ํธ์คํธ๋ค์์ DNS๋ก ํด์ํด IP๋ก ์ ์ํฉ๋๋ค. ์ฆ, ํธ์คํธ๋ค์ ๋ณ๊ฒฝ๋ง์ผ๋ก๋ ์ ์์ด ์ ๋๊ณ , DNS ์ค์ ์ด ๋ง์์ผ ํฉ๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. VS Code SSH ์ค์ ํ์ธ
~/.ssh/config ํ์ผ์ ์ด์ด ์ ํธ์คํธ๋ค์์ ๋ฐ์ํฉ๋๋ค:
nano ~/.ssh/config
์์:
Host makers-server
HostName server.makerskorean.kr
User ubuntu
IdentityFile ~/.ssh/id_rsa
โ ์ ์ฅ ํ VS Code์์ makers-server๋ก ์ ์.
2. DNS ํ์ธ
Cloudflare์์ server.makerskorean.kr โ ์๋ฒ ๊ณต์ธ IP๊ฐ ์ ๋๋ก ๋ฑ๋ก๋์ด ์๋์ง ํ์ธํ์ธ์:
dig server.makerskorean.kr
IP๊ฐ ๋์ค์ง ์์ผ๋ฉด DNS ๋ ์ฝ๋๊ฐ ์๋ชป๋ ๊ฒ๋๋ค.
3. ์์ ํด๊ฒฐ (IP๋ก ์ ์)
DNS ์ ํ๊ฐ ์ ๋์ ๊ฒฝ์ฐ, VS Code์์ ์ง์ IP๋ก ์ ์ ๊ฐ๋ฅํฉ๋๋ค:
Host makers-server-ip
HostName <์๋ฒ๊ณต์ธIP>
User ubuntu
IdentityFile ~/.ssh/id_rsa
4. ์๋ฒ SSH ์๋น์ค ํ์ธ
์๋ฒ์์ SSH๊ฐ ์ ์ ๋์ํ๋์ง ํ์ธ:
sudo systemctl status ssh
๐ ์ ๋ฆฌ
- ํธ์คํธ๋ค์ ๋ณ๊ฒฝ๋ง์ผ๋ก๋ SSH ์ ์์ด ์ ๋ฉ๋๋ค.
- ๋ฐ๋์ Cloudflare DNS โ ์๋ฒ IP ๋งคํ๊ณผ VS Code SSH ์ค์ ์์ ์ด ํ์ํฉ๋๋ค.
- ๊ธํ๊ฒ ์ ์ํด์ผ ํ๋ค๋ฉด IP๋ก ์ง์ ์ ์ํ๋ฉด ๋ฉ๋๋ค.
๐ ํน์ ์ง๊ธ VS Code์์ IP๋ก๋ ์ ์์ด ๋๋์ง ํ์ธํด ๋ณด์ค๋์? ๊ทธ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ DNS ๋ฌธ์ ์ธ์ง, SSH ์ค์ ๋ฌธ์ ์ธ์ง ๋ฐ๋ก ์ขํ๋๋ฆด ์ ์์ต๋๋ค.
์ฌ์ดํธ ์ ์๋ ์๋๋ ๋ฌธ์
์ฌ์ดํธ์ ์ฐ๊ฒฐํ ์ ์์
makerskorean.kr์์ ์๋ตํ๋ ๋ฐ ์๊ฐ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ฆฝ๋๋ค.
๋ค์ ๋ฐฉ๋ฒ์ ์๋ํด ๋ณด์ธ์.
์ฐ๊ฒฐ ํ์ธ
ํ๋ก์ ๋ฐ ๋ฐฉํ๋ฒฝ ํ์ธ
Windows ๋คํธ์ํฌ ์ง๋จ ํ๋ก๊ทธ๋จ ์คํ
ERR_CONNECTION_TIMED_OUT
์ง๊ธ ์ํฉ์ DNS๋ ๋ฑ๋กํ์ง๋ง ์๋ฒ๊ฐ ์ธ๋ถ์์ ์๋ตํ์ง ์๋ ์ํ๋ก ๋ณด์
๋๋ค. ERR_CONNECTION_TIMED_OUT์ ๋ณดํต ๋ค์ ์์ธ ์ค ํ๋์์:
๐ ์ฃผ์ ์์ธ
- DNS ๋ฌธ์
- Cloudflare์์
makerskorean.krโ ์๋ฒ ๊ณต์ธ IP๊ฐ ์ ๋๋ก ๋ฑ๋ก๋์ง ์์๊ฑฐ๋ ์์ง ์ ํ๋์ง ์์. - ํ์ธ:
dig makerskorean.kr nslookup makerskorean.kr
- Cloudflare์์
- ๋ฐฉํ๋ฒฝ/ํฌํธ ๋ฌธ์
- ์๋ฒ ๋ฐฉํ๋ฒฝ(UFW, iptables, ํด๋ผ์ฐ๋ ์ ๊ณต ๋ฐฉํ๋ฒฝ)์ด 80/443 ํฌํธ๋ฅผ ๋ง๊ณ ์์.
- ํ์ธ:
sudo ss -tlnp | grep ':80' sudo ss -tlnp | grep ':443'
- ์น ์๋ฒ ๋ฏธ๊ตฌ๋
- Nginx/Apache๊ฐ ์ค์น๋์ง ์์๊ฑฐ๋ ์คํ ์ค์ด์ง ์์.
- ํ์ธ:
sudo systemctl status nginx sudo systemctl status apache2
- Cloudflare Proxy ์ค์ ๋ฌธ์
- Cloudflare DNS์์ ํ๋ก์(์ฃผํฉ์ ๊ตฌ๋ฆ)๋ฅผ ์ผ๋ฉด ์๋ฒ๊ฐ 80/443 ํฌํธ์์ ์๋ตํด์ผ ํฉ๋๋ค.
- ์๋ฒ๊ฐ ์๋ตํ์ง ์์ผ๋ฉด Cloudflare๊ฐ ์ฐ๊ฒฐ์ ๋ชป ํด์ ํ์์์ ๋ฐ์.
โ ํด๊ฒฐ ์ ์ฐจ
- DNS ํ์ธ
makerskorean.kr์ด ์๋ฒ ๊ณต์ธ IP๋ก ์ ๋งคํ๋๋์ง ํ์ธํ์ธ์.
- ์น ์๋ฒ ์คํ ์ฌ๋ถ ํ์ธ
- Nginx ๋๋ Apache๊ฐ ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค.
์์ ์ค์น:
sudo apt install nginx -y sudo systemctl enable nginx sudo systemctl start nginx- ๋ธ๋ผ์ฐ์ ์์
http://<์๋ฒIP>์ ์ ํ ์คํธ.
- Nginx ๋๋ Apache๊ฐ ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค.
- ๋ฐฉํ๋ฒฝ ํ์ธ
- UFW ์ฌ์ฉ ์:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp - iptables/nftables ์ฌ์ฉ ์ 80/443 ํฌํธ ํ์ฉ.
- UFW ์ฌ์ฉ ์:
- Cloudflare ์ค์ ํ์ธ
- DNS ๋ ์ฝ๋์์
makerskorean.krโ ์๋ฒ IP๊ฐ ๋ง๋์ง ํ์ธ. - ํ๋ก์(์ฃผํฉ์ ๊ตฌ๋ฆ)๋ฅผ ๋๊ณ (ํ์) ํ ์คํธํด๋ณด๋ฉด ์์ธ ํ์ ์ด ์ฌ์.
- DNS ๋ ์ฝ๋์์
๐ ์ ๋ฆฌ
- DNS โ ์๋ฒ IP ํ์ธ
- ์๋ฒ ์น ์๋ฒ(Nginx/Apache) ์คํ ์ฌ๋ถ ํ์ธ
- ๋ฐฉํ๋ฒฝ์์ 80/443 ํฌํธ ํ์ฉ
- Cloudflare ํ๋ก์ ์ค์ ์ ๊ฒ
๐ ๋จผ์ http://<์๋ฒ๊ณต์ธIP>๋ก ์ง์ ์ ์ํด ๋ณด์๋ฉด, DNS ๋ฌธ์ ์ธ์ง ์๋ฒ ๋ฌธ์ ์ธ์ง ๋ฐ๋ก ๊ตฌ๋ถํ ์ ์์ต๋๋ค.
ํน์ ์ ๊ฐ ์ง๊ธ makerskorean.kr์ DNS ๋ ์ฝ๋ ์ํ๋ฅผ ์กฐํํด์ ์ด๋ค IP๋ก ์ฐ๊ฒฐ๋๋์ง ํ์ธํด๋๋ฆด๊น์?
ํ์๋ฒ์ ๋ฉ์ผ์๋ฒ (postfix/Devecot) ํ์คํ ์์ ํ์ ์ ์์๋ฌ ๋ฐ์
๋ฉ์ผ ์๋ฒ(Postfix/Dovecot) ํ์ฑํ ์์ ์ดํ์ ์ฌ์ดํธ ์ ์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค๋ฉด, ๋ช ๊ฐ์ง ํํ ์์ธ์ ์ ๊ฒํด์ผ ํฉ๋๋ค. ๋ฉ์ผ ์๋ฒ ์ค์ ์ด ์น ์๋ฒ์ ์ง์ ์ถฉ๋ํ์ง๋ ์์ง๋ง, ๋คํธ์ํฌ/๋ฐฉํ๋ฒฝ/DNS ์ค์ ์ ๊ฑด๋๋ฆฌ๋ฉด์ ์น ์๋น์ค๊น์ง ์ํฅ์ ์ค ์ ์์ต๋๋ค.
๐ ์ ๊ฒ ํฌ์ธํธ
1. ์๋น์ค ์ํ ํ์ธ
- ์น ์๋ฒ(Nginx/Apache) ๊ฐ ์ ์ ์คํ ์ค์ธ์ง ํ์ธ:
sudo systemctl status nginx sudo systemctl status apache2 - ๋ฉ์ผ ์๋ฒ(Postfix/Dovecot) ๊ฐ ์ ์ ์คํ ์ค์ธ์ง ํ์ธ:
sudo systemctl status postfix sudo systemctl status dovecot
2. ํฌํธ ์ถฉ๋ ์ฌ๋ถ
- Postfix/Dovecot์ ๊ธฐ๋ณธ์ ์ผ๋ก 25, 587, 143, 993, 110, 995 ํฌํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- ์น ์๋ฒ๋ 80, 443 ํฌํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
โ ํน์ ์๋ชป๋ ์ค์ ์ผ๋ก ์น ์๋ฒ ํฌํธ๋ฅผ ๊ฑด๋๋ ธ๋์ง ํ์ธ:
sudo ss -tlnp
์ถ๋ ฅ์์ 80/443 ํฌํธ๊ฐ ์น ์๋ฒ ํ๋ก์ธ์ค(nginx ๋๋ apache2)์ ๋ฌถ์ฌ ์๋์ง ํ์ธํ์ธ์.
3. ๋ฐฉํ๋ฒฝ ์ค์
๋ฉ์ผ ์๋ฒ ํฌํธ ์ด๋ฉด์ ์น ์๋ฒ ํฌํธ(80/443)๊ฐ ์ฐจ๋จ๋์์ ์ ์์ต๋๋ค.
- UFW ์ฌ์ฉ ์:
sudo ufw statusโ 80/tcp, 443/tcp ํ์ฉ ์ฌ๋ถ ํ์ธ - iptables/nftables ์ฌ์ฉ ์:
sudo iptables -L -n sudo nft list ruleset
4. DNS/Cloudflare ์ค์
๋ฉ์ผ ์๋ฒ ํ์ฑํ ํ MX ๋ ์ฝ๋, A ๋ ์ฝ๋ ๋ฑ์ ์์ ํ๋ฉด์ ์น ์๋น์ค์ฉ A ๋ ์ฝ๋(makerskorean.kr โ ์๋ฒ IP)๊ฐ ์๋ชป ๋ณ๊ฒฝ๋์์ ๊ฐ๋ฅ์ฑ๋ ์์ต๋๋ค.
- ํ์ธ:
dig makerskorean.krโ ์ฌ๋ฐ๋ฅธ ์๋ฒ ๊ณต์ธ IP๊ฐ ๋์ค์ง ์์ผ๋ฉด DNS ๋ฌธ์ ์ ๋๋ค.
5. ๋ก๊ทธ ํ์ธ
- ์น ์๋ฒ ๋ก๊ทธ:
sudo tail -f /var/log/nginx/error.log sudo tail -f /var/log/apache2/error.log - ๋ฉ์ผ ์๋ฒ ๋ก๊ทธ:
sudo tail -f /var/log/mail.log sudo tail -f /var/log/dovecot.log
โ ํด๊ฒฐ ๋ฐฉํฅ
- ์น ์๋ฒ๊ฐ ์ฃฝ์๋์ง โ
systemctl status nginx/apache2ํ์ธ ํ ์ฌ์์sudo systemctl restart nginx - ํฌํธ ์ถฉ๋ ์ฌ๋ถ โ
ss -tlnp๋ก ํ์ธ - ๋ฐฉํ๋ฒฝ ๊ท์น โ 80/443 ํ์ฉ ํ์ธ
- DNS ๋ ์ฝ๋ โ makerskorean.kr์ด ์ฌ๋ฐ๋ฅธ IP๋ฅผ ๊ฐ๋ฆฌํค๋์ง ํ์ธ
๐ ์ ๋ฆฌ:
๋ฉ์ผ ์๋ฒ(Postfix/Dovecot) ํ์ฑํ ์์ฒด๋ ์น ์๋ฒ์ ์ง์ ์ถฉ๋ํ์ง ์์ง๋ง, ๋ฐฉํ๋ฒฝ ๊ท์น ๋ณ๊ฒฝ์ด๋ DNS ๋ ์ฝ๋ ์์ ๊ณผ์ ์์ ์น ์ ์์ด ๋งํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค.
๐ ์ฐ์ http://<์๋ฒ๊ณต์ธIP>๋ก ์ง์ ์ ์ํด ๋ณด์ธ์.
- IP๋ก ์ ์์ด ๋๋ฉด DNS ๋ฌธ์
- IP๋ก๋ ์ ์์ด ์ ๋๋ฉด ์น ์๋ฒ/๋ฐฉํ๋ฒฝ ๋ฌธ์
์ํ์๋ฉด ์ ๊ฐ makerskorean.kr์ ํ์ฌ DNS ๋ ์ฝ๋ ์ํ๋ฅผ ์กฐํํด์ ์ด๋ค IP๋ก ์ฐ๊ฒฐ๋๋์ง ๋ฐ๋ก ํ์ธํด๋๋ฆด ์๋ ์์ต๋๋ค.
ufw ๋ ์ค์ฐจํจ
์ข์ต๋๋ค ๐ ์ด์ ufw๊น์ง ์ค์นํ์
จ๋ค๋ฉด, ์น ์๋ฒ์ ๋ฉ์ผ ์๋ฒ๊ฐ ์ธ๋ถ์์ ์ ์์ ์ผ๋ก ์ ์๋๋๋ก ๋ฐฉํ๋ฒฝ ๊ท์น์ ๋ค์ ์ ๋ฆฌํด๋๋ฆด๊ฒ์.
๐ UFW ๊ธฐ๋ณธ ์ค์ ํ์ธ
sudo ufw status verbose
- ํ์ฌ ์ด๋ค ํฌํธ๊ฐ ์ด๋ ค ์๋์ง ํ์ธํฉ๋๋ค.
- ๊ธฐ๋ณธ ์ ์ฑ
์ด
deny๋ผ๋ฉด, ํ์ํ ํฌํธ๋ง ํ์ฉํด์ผ ํฉ๋๋ค.
๐ ์น ์๋น์ค์ฉ ํฌํธ ์ด๊ธฐ
์น ์๋ฒ(Nginx/Apache)๊ฐ ์ธ๋ถ์์ ์ ์ ๊ฐ๋ฅํ๋ ค๋ฉด ๋ฐ๋์ 80/443 ํฌํธ๋ฅผ ์ด์ด์ผ ํฉ๋๋ค:
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
๐ง ๋ฉ์ผ ์๋น์ค์ฉ ํฌํธ ์ด๊ธฐ
Postfix/Dovecot์ ์ํ ํฌํธ:
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 587/tcp # Submission
sudo ufw allow 143/tcp # IMAP
sudo ufw allow 993/tcp # IMAPS
sudo ufw allow 110/tcp # POP3
sudo ufw allow 995/tcp # POP3S
๐ ํ์ธ
๊ท์น ์ ์ฉ ํ ๋ค์ ํ์ธ:
sudo ufw status verbose
โ 80, 443, 25, 587, 143, 993, 110, 995 ํฌํธ๊ฐ ALLOW ์ํ์ธ์ง ํ์ธํ์ธ์.
๐จ ์ถ๊ฐ ์ฒดํฌ
- ์น ์๋ฒ ์คํ ์ฌ๋ถ
sudo systemctl status nginx sudo systemctl status apache2โ ์คํ ์ค์ธ์ง ํ์ธ ํ ํ์ ์ ์ฌ์์:sudo systemctl restart nginx - DNS ํ์ธ
Cloudflare์์makerskorean.krโ ์๋ฒ ๊ณต์ธ IP๊ฐ ์ ๋๋ก ๋ฑ๋ก๋์ด ์๋์ง ํ์ธ:dig makerskorean.kr - ์ง์ IP ์ ์ ํ
์คํธ
๋ธ๋ผ์ฐ์ ์์http://<์๋ฒ๊ณต์ธIP>์ ์ โ ๋๋ฉด DNS ๋ฌธ์ , ์ ๋๋ฉด ๋ฐฉํ๋ฒฝ/์น ์๋ฒ ๋ฌธ์ .
๐ ์ง๊ธ ์ํฉ์์ ๊ฐ์ฅ ๋น ๋ฅธ ์ง๋จ์ ๋ธ๋ผ์ฐ์ ๋ก ์๋ฒ ๊ณต์ธ IP ์ง์ ์ ์์ ๋๋ค.
- IP๋ก ์ ์์ด ๋๋ค๋ฉด Cloudflare DNS ์ค์ ๋ฌธ์
- IP๋ก๋ ์ ์์ด ์ ๋๋ค๋ฉด ์น ์๋ฒ/๋ฐฉํ๋ฒฝ ๋ฌธ์
์ํ์๋ฉด ์ ๊ฐ makerskorean.kr์ ํ์ฌ DNS ๋ ์ฝ๋ ์ํ๋ฅผ ์กฐํํด์ ์ด๋ค IP๋ก ์ฐ๊ฒฐ๋๋์ง ๋ฐ๋ก ํ์ธํด๋๋ฆด๊น์?
ufw ์ค์ฐจํ ์๋ฒ ์ฌ๋ถํ ํ ์๋ฌ๊ฐ ๋ฐ์
์ฌ๋ถํ
ํ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค๋ฉด, ufw ํ์ฑํ ๊ณผ์ ์์ ๋คํธ์ํฌ ์ฐจ๋จ์ด ๊ฑธ๋ ธ์ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค. ํนํ ๊ธฐ๋ณธ ์ ์ฑ
์ด deny๋ก ์ค์ ๋์ด ์์ผ๋ฉด SSH, HTTP/HTTPS๊น์ง ๋งํ์ ์ ์ ๋ถ๊ฐ ์ํ๊ฐ ๋ฉ๋๋ค.
๐ ์ ๊ฒ ๋จ๊ณ
1. UFW ์ํ ํ์ธ
์๋ฒ์ ์ ์์ด ๊ฐ๋ฅํ๋ค๋ฉด ๋จผ์ ํ์ธ:
sudo ufw status verbose
Status: active์ธ์ง ํ์ธ22/tcp,80/tcp,443/tcp๋ฑ์ด ํ์ฉ๋์ด ์๋์ง ํ์ธ
2. SSH ํฌํธ ํ์ฉ ์ฌ๋ถ
์ฌ๋ถํ ํ ์ ์์ด ๋งํ๋ ๊ฐ์ฅ ํํ ์์ธ์ SSH ํฌํธ(22) ๊ฐ ์ฐจ๋จ๋ ๊ฒฝ์ฐ์ ๋๋ค.
sudo ufw allow 22/tcp
3. ๊ธฐ๋ณธ ์ ์ฑ ํ์ธ
sudo ufw default allow outgoing
sudo ufw default deny incoming
โ ์ด๋ ๊ฒ ์ค์ ํ๋ฉด ์ธ๋ถ์์ ๋ค์ด์ค๋ ์ฐ๊ฒฐ์ ๊ท์น์ผ๋ก ํ์ฉํ ๊ฒ๋ง ํต๊ณผํฉ๋๋ค.
๋ฐ๋ผ์ ๋ฐ๋์ 22, 80, 443, ๋ฉ์ผ ๊ด๋ จ ํฌํธ๋ฅผ ํ์ฉํด์ผ ํฉ๋๋ค.
4. ํ์ํ ํฌํธ ๋ค์ ์ด๊ธฐ
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 587/tcp # Submission
sudo ufw allow 143/tcp # IMAP
sudo ufw allow 993/tcp # IMAPS
sudo ufw allow 110/tcp # POP3
sudo ufw allow 995/tcp # POP3S
5. ์๋ฒ ์ ์ ๋ถ๊ฐ ์ ๋ณต๊ตฌ ๋ฐฉ๋ฒ
๋ง์ฝ ๋ฐฉํ๋ฒฝ ๋๋ฌธ์ SSH ์ ์์ด ์์ ํ ๋งํ๋ฒ๋ ธ๋ค๋ฉด:
- ํด๋ผ์ฐ๋ ์๋ฒ๋ผ๋ฉด โ ์ ๊ณต์
์ฒด ์ฝ์์์ “๊ตฌ์ฑ ๋ณต๊ตฌ” ๋๋ “์ฝ์ ์ ์” ๊ธฐ๋ฅ์ ์ฌ์ฉํด ์ง์ ๋ก๊ทธ์ธ ํ
ufw disable์คํ:sudo ufw disable - ํ์๋ฒ๋ผ๋ฉด โ ์ง์ ๋ชจ๋ํฐ/ํค๋ณด๋ ์ฐ๊ฒฐํด์ ๋ก๊ทธ์ธ ํ ์ ๋ช ๋ น ์คํ.
๐ ์ ๋ฆฌ
- ์ฌ๋ถํ ํ ์๋ฌ๋ ๋๋ถ๋ถ SSH ํฌํธ ์ฐจ๋จ ๋๋ฌธ
ufw allow 22/tcp๋ฐ๋์ ์ถ๊ฐ- ์น ์๋น์ค์ฉ ํฌํธ(80/443)์ ๋ฉ์ผ ์๋ฒ ํฌํธ๋ ํ์ฉ ํ์
- ์ ์ ๋ถ๊ฐ ์ ์ฝ์/์ง์ ๋ก๊ทธ์ธ์ผ๋ก
ufw disableํ ๋ค์ ๊ท์น ์ค์
๐ ํน์ ์ง๊ธ ์๋ฒ๊ฐ ํ์๋ฒ(์ง์ ๋ฌผ๋ฆฌ ์ ์ ๊ฐ๋ฅ)์ธ์ง, ์๋๋ฉด ํด๋ผ์ฐ๋ ์๋ฒ(์๊ฒฉ๋ง ์ ์ ๊ฐ๋ฅ)์ธ์ง ์๋ ค์ฃผ์๋ฉด ๋ณต๊ตฌ ๋ฐฉ๋ฒ์ ๋ ๊ตฌ์ฒด์ ์ผ๋ก ์๋ดํด๋๋ฆด ์ ์์ต๋๋ค.
์ ์์๋ฌ ์ดํ ssh๋ฅผ ๋ด๋ถ ์์ดํผ๋ก (192.168.xx.xxx) ์ ์ํด๋ ์ฐ๊ฒฐ์๋จ
๋ด๋ถ IP(192.168.xx.xxx)๋ก๋ SSH ์ ์์ด ์ ๋๋ค๋ฉด, ๋จ์ํ DNS ๋ฌธ์ ๋ ์๋๊ณ ์๋ฒ ์์ฒด์์ SSH ์๋น์ค๋ ๋ฐฉํ๋ฒฝ ์ค์ ์ด ๋งํ ์๋ ์ํ์ผ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค. ๋จ๊ณ๋ณ๋ก ์ง๋จํด ๋ณด๊ฒ ์ต๋๋ค:
๐ ํ์ธํด์ผ ํ ๋ถ๋ถ
1. SSH ์๋น์ค ์ํ
์ฌ๋ถํ ํ SSH ๋ฐ๋ชฌ์ด ์ ์ ์คํ ์ค์ธ์ง ํ์ธ:
sudo systemctl status ssh
active (running)์ํ์ฌ์ผ ํฉ๋๋ค.- ๋ง์ฝ
inactive๋๋failed๋ผ๋ฉด:sudo systemctl restart ssh
2. UFW ๊ท์น ํ์ธ
์ฌ๋ถํ ํ UFW๊ฐ ํ์ฑํ๋๋ฉด์ SSH ํฌํธ(22)๊ฐ ์ฐจ๋จ๋์ ์ ์์ต๋๋ค:
sudo ufw status verbose
22/tcp ALLOWํญ๋ชฉ์ด ๋ฐ๋์ ์์ด์ผ ํฉ๋๋ค.- ์๋ค๋ฉด:
sudo ufw allow 22/tcp sudo ufw reload
3. ๋คํธ์ํฌ ์ธํฐํ์ด์ค ํ์ธ
๋ด๋ถ IP๊ฐ ์ ๋๋ก ์ด์ ์๋์ง ํ์ธ:
ip addr show
192.168.xx.xxx์ฃผ์๊ฐ ์ธํฐํ์ด์ค์ ๋ฐ์ธ๋ฉ๋์ด ์๋์ง ํ์ธํ์ธ์.- DHCP ํ๊ฒฝ์ด๋ผ๋ฉด ์ฌ๋ถํ ํ IP๊ฐ ๋ฐ๋์์ ์๋ ์์ต๋๋ค.
4. ํฌํธ ๋ฆฌ์ค๋ ํ์ธ
SSH ๋ฐ๋ชฌ์ด ์ค์ ๋ก 22๋ฒ ํฌํธ๋ฅผ ์ด๊ณ ์๋์ง ํ์ธ:
sudo ss -tlnp | grep sshd
LISTEN์ํ๋ก0.0.0.0:22๋๋192.168.xx.xxx:22๊ฐ ๋ณด์ฌ์ผ ํฉ๋๋ค.
5. ์ง์ ์ฝ์ ์ ์
๋ง์ฝ ์๊ฒฉ ์ ์์ด ์ ํ ์ ๋๋ค๋ฉด, ํ์๋ฒ๋ผ๋ฉด ๋ชจ๋ํฐ/ํค๋ณด๋๋ก ์ง์ ๋ก๊ทธ์ธํด์:
sudo ufw disable
โ ๋ฐฉํ๋ฒฝ์ ๋ ๋ค ๋ค์ SSH ์ ์์ ์๋ํ์ธ์.
๐ ์ ๋ฆฌ
- SSH ์๋น์ค ์คํ ์ฌ๋ถ โ
systemctl status ssh - UFW ๊ท์น โ
ufw allow 22/tcpํ์ธ - ๋ด๋ถ IP ํ์ธ โ
ip addr show - ํฌํธ ๋ฆฌ์ค๋ ํ์ธ โ
ss -tlnp | grep sshd - ์ ์ ๋ถ๊ฐ ์ โ ์ฝ์ ์ ์ ํ
ufw disable๋ก ๋ณต๊ตฌ
๐ ์ง๊ธ ์ํฉ์์ ๊ฐ์ฅ ๋น ๋ฅธ ๋ณต๊ตฌ ๋ฐฉ๋ฒ์ ์๋ฒ ์ฝ์๋ก ์ง์ ๋ก๊ทธ์ธ ํ ufw disable ์คํ์
๋๋ค.
๊ทธ ๋ค์ SSH ์๋น์ค๊ฐ ์ด์ ์๋์ง ํ์ธํ๊ณ , ๋ค์ ufw allow 22/tcp๋ฅผ ์ถ๊ฐํด์ผ ํฉ๋๋ค.
ํน์ ์๋ฒ์ ์ง์ ๋ชจ๋ํฐ/ํค๋ณด๋๋ก ์ ๊ทผ ๊ฐ๋ฅํ ํ์๋ฒ์ธ๊ฐ์, ์๋๋ฉด ํด๋ผ์ฐ๋ ์๋ฒ๋ผ์ ์๊ฒฉ ์ฝ์๋ง ์ ๊ณต๋๋์?
ํ์๋ฒ์ ssh์ ์์ด ์๋๋ ์ด๋ป๊ฒ ์ฒดํฌ๋ฅผ ํ๋์?
์ข์ ์ง๋ฌธ์ด์์ ๐ ํ์๋ฒ์์ SSH ์ ์์ด ์ ๋ ๋๋ ์๋น์ค ์ํ โ ๋คํธ์ํฌ โ ๋ฐฉํ๋ฒฝ โ ํฌํธ ๋ฆฌ์ค๋ ์์๋ก ์ ๊ฒํ๋ฉด ์์ธ์ ๋น ๋ฅด๊ฒ ์ฐพ์ ์ ์์ต๋๋ค.
๐ SSH ์ ์ ๋ถ๊ฐ ์ฒดํฌ๋ฆฌ์คํธ
1. SSH ์๋น์ค ์คํ ์ฌ๋ถ
sudo systemctl status ssh
active (running)์ด๋ฉด ์ ์inactive๋๋failed๋ผ๋ฉด:sudo systemctl restart ssh
2. ๋คํธ์ํฌ ์ธํฐํ์ด์ค ํ์ธ
ip addr show
- ์๋ฒ๊ฐ
192.168.xx.xxx๊ฐ์ ๋ด๋ถ IP๋ฅผ ์ ๋๋ก ๋ฐ๊ณ ์๋์ง ํ์ธ - DHCP ํ๊ฒฝ์ด๋ฉด ์ฌ๋ถํ ํ IP๊ฐ ๋ฐ๋ ์ ์์ผ๋ ์ฃผ์
3. ํฌํธ ๋ฆฌ์ค๋ ํ์ธ
sudo ss -tlnp | grep sshd
- ์ถ๋ ฅ์
LISTEN์ํ๋ก0.0.0.0:22๋๋192.168.xx.xxx:22๊ฐ ๋ณด์ฌ์ผ ์ ์ - ์ ๋ณด์ด๋ฉด SSH ๋ฐ๋ชฌ์ด ํฌํธ๋ฅผ ์ด์ง ๋ชปํ ์ํ
4. ๋ฐฉํ๋ฒฝ(UFW) ๊ท์น ํ์ธ
sudo ufw status verbose
22/tcp ALLOWํญ๋ชฉ์ด ๋ฐ๋์ ์์ด์ผ ํฉ๋๋ค- ์๋ค๋ฉด:
sudo ufw allow 22/tcp sudo ufw reload
5. ์ง์ ์ฝ์ ์ ์
์๊ฒฉ SSH๊ฐ ์ ํ ์ ๋๋ค๋ฉด, ํ์๋ฒ๋ผ๋ฉด ๋ชจ๋ํฐ/ํค๋ณด๋ ์ง์ ์ฐ๊ฒฐํด์ ๋ก๊ทธ์ธ ํ:
sudo ufw disable
โ ๋ฐฉํ๋ฒฝ์ ๋ ๋ค ๋ค์ SSH ์ ์์ ์๋ํ์ธ์.
๐ ์ ๋ฆฌ
- SSH ์๋น์ค ์คํ ์ฌ๋ถ โ
systemctl status ssh - ๋ด๋ถ IP ํ์ธ โ
ip addr show - ํฌํธ ๋ฆฌ์ค๋ ํ์ธ โ
ss -tlnp | grep sshd - ๋ฐฉํ๋ฒฝ ๊ท์น ํ์ธ โ
ufw status verbose - ์ ์ ๋ถ๊ฐ ์ โ ์ฝ์ ๋ก๊ทธ์ธ ํ
ufw disable๋ก ๋ณต๊ตฌ
๐ ๊ฐ์ฅ ๋จผ์ ์ฝ์์์ systemctl status ssh ํ์ธํด ๋ณด์ธ์.
๋ง์ฝ SSH ์๋น์ค๊ฐ ์ฃฝ์ด ์๋ค๋ฉด, ๋ฐฉํ๋ฒฝ ๋ฌธ์ ๊ฐ ์๋๋ผ ๋จ์ํ ๋ฐ๋ชฌ์ด ์คํ๋์ง ์์ ๊ฒ์ผ ์ ์์ต๋๋ค.
์ํ์๋ฉด ์ ๊ฐ โ์ฌ๋ถํ ํ SSH๊ฐ ์๋์ผ๋ก ์คํ๋๋๋ก ์ค์ ํ๋ ๋ฐฉ๋ฒโ๊น์ง ์ด์ด์ ์๋ ค๋๋ฆด๊น์?
์ ์๋ฌธ์ ๋ ๋ฐฉํ๋ฒฝ ๋ฌธ์ ๋ก ํด๊ฒฐ์ ํ๋๋ฐ ์์ํ์ด์ง๊ฐ ๊ธฐ์กด์ ์๋ํ๋ ์ค๊ฐ ์๋จ๊ณ virtualmin ์๋ด ํ์ด์ง๊ฐ ๋ธ
์, ์ด์ ํต์ฌ์ด ๋ณด์ด๋ค์ ๐
๋ฐฉํ๋ฒฝ ๋ฌธ์ ๋ ํด๊ฒฐํ์
จ์ง๋ง, ์น ์๋ฒ์ ๊ธฐ๋ณธ DocumentRoot๊ฐ Virtualmin ์ค์น ๊ณผ์ ์์ ๋ฐ๋์ด์ ๊ธฐ์กด ์๋ํ๋ ์ค ๋์ Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ์ํฉ์
๋๋ค.
๐ ์์ธ
- Virtualmin ์ค์น ์ Apache/Nginx์ ๊ธฐ๋ณธ ์ฌ์ดํธ ์ค์ ์ ๋ฎ์ด์์ฐ๋ฉด์
/var/www/html๋์ Virtualmin์ ๊ด๋ฆฌ ํ์ด์ง์ฉ DocumentRoot๊ฐ ํ์ฑํ๋จ. - ๋ฐ๋ผ์
makerskorean.kr์ ์ ์ ์๋ํ๋ ์ค๊ฐ ์๋๋ผ Virtualmin ์๋ด ํ์ด์ง๊ฐ ํ์๋ฉ๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. ํ์ฌ DocumentRoot ํ์ธ
Apache ์ฌ์ฉ ์:
grep -i 'DocumentRoot' /etc/apache2/sites-enabled/*.conf
Nginx ์ฌ์ฉ ์:
grep -i 'root' /etc/nginx/sites-enabled/*.conf
โ Virtualmin์ด /var/www/html ๋์ ๋ค๋ฅธ ๋๋ ํ ๋ฆฌ๋ฅผ ๊ฐ๋ฆฌํค๊ณ ์์ ๊ฒ๋๋ค.
2. ์๋ํ๋ ์ค ๊ฒฝ๋ก๋ก ์์
์๋ํ๋ ์ค๊ฐ /var/www/html์ ์ค์น๋์ด ์๋ค๋ฉด, ํด๋น VirtualHost ์ค์ ์ ์์ ํด์ผ ํฉ๋๋ค.
Apache ์์:
sudo nano /etc/apache2/sites-available/makerskorean.kr.conf
๋ด์ฉ ์ค:
DocumentRoot /var/www/html
ServerName makerskorean.kr
ServerAlias www.makerskorean.kr
Nginx ์์:
sudo nano /etc/nginx/sites-available/makerskorean.kr
๋ด์ฉ ์ค:
root /var/www/html;
server_name makerskorean.kr www.makerskorean.kr;
3. ์ฌ์ดํธ ์ค์ ํ์ฑํ
Apache:
sudo a2ensite makerskorean.kr.conf
sudo systemctl reload apache2
Nginx:
sudo ln -s /etc/nginx/sites-available/makerskorean.kr /etc/nginx/sites-enabled/
sudo systemctl reload nginx
4. Virtualmin ๊ธฐ๋ณธ ํ์ด์ง ๋นํ์ฑํ
Virtualmin์ด ๋ง๋ ๊ธฐ๋ณธ ์ฌ์ดํธ ์ค์ ํ์ผ์ ๋นํ์ฑํํด์ผ ํฉ๋๋ค.
์์ (Apache):
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
๐ ์ ๋ฆฌ
- Virtualmin ์ค์น ์ ๊ธฐ๋ณธ DocumentRoot๊ฐ ๋ฐ๋์ด์ ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๊ฒ
- ์๋ํ๋ ์ค ์ค์น ๊ฒฝ๋ก(
/var/www/html)๋ฅผ ๋ค์ VirtualHost ์ค์ ์ ์ง์ ํด์ผ ํจ - Virtualmin ๊ธฐ๋ณธ ์ฌ์ดํธ ์ค์ ์ ๋นํ์ฑํํ๊ณ , makerskorean.kr ๋๋ฉ์ธ์ ๋ง๋ VirtualHost๋ฅผ ํ์ฑํ
๐ ํน์ ์ง๊ธ ์น ์๋ฒ๊ฐ Apache์ธ์ง Nginx์ธ์ง ์๋ ค์ฃผ์๋ฉด, ์ ๊ฐ ๋ฐ๋ก ํด๋น ์๋ฒ์ ๋ง๋ ๊ตฌ์ฒด์ ์ธ ์ค์ ํ์ผ ๊ฒฝ๋ก์ ์์ ๋ฐฉ๋ฒ์ ๋ฑ ๋ง๊ฒ ์ ๋ฆฌํด๋๋ฆด ์ ์์ต๋๋ค.
์ข์ต๋๋ค ๐ Apache ํ๊ฒฝ์์ Virtualmin ์ค์น ํ ๊ธฐ๋ณธ ์๋ํ๋ ์ค ํ์ด์ง ๋์ Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๋จ๊ณ๋ณ๋ก ์ ๋ฆฌํด๋๋ฆด๊ฒ์.
๐ ์์ธ
- Virtualmin ์ค์น ์ Apache์ ๊ธฐ๋ณธ VirtualHost(000-default.conf) ๋ฅผ ๋ฎ์ด์ฐ๊ฑฐ๋ ์๋ก์ด VirtualHost๋ฅผ ์ถ๊ฐํฉ๋๋ค.
- ๊ทธ ๊ฒฐ๊ณผ
makerskorean.kr์์ฒญ์ด/var/www/html๋์ Virtualmin์ด ๋ง๋ DocumentRoot๋ฅผ ๋ฐ๋ผ๋ณด๊ฒ ๋์ด ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๊ฒ๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ (Apache ๊ธฐ์ค)
1. ํ์ฌ ํ์ฑํ๋ ์ฌ์ดํธ ํ์ธ
ls /etc/apache2/sites-enabled/
์ฌ๊ธฐ์ 000-default.conf ๋๋ Virtualmin์ด ๋ง๋ conf ํ์ผ์ด ์์ ๊ฒ๋๋ค.
2. ์๋ํ๋ ์ค์ฉ VirtualHost ์ค์ ๋ง๋ค๊ธฐ/์์
์๋ํ๋ ์ค๊ฐ /var/www/html์ ์ค์น๋์ด ์๋ค๋ฉด, ๋ณ๋์ conf ํ์ผ์ ๋ง๋ค์ด ์ง์ ํฉ๋๋ค.
sudo nano /etc/apache2/sites-available/makerskorean.kr.conf
์์ ์ค์ :
<VirtualHost *:80>
ServerName makerskorean.kr
ServerAlias www.makerskorean.kr
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/makers_error.log
CustomLog ${APACHE_LOG_DIR}/makers_access.log combined
</VirtualHost>
3. ๊ธฐ๋ณธ ์ฌ์ดํธ ๋นํ์ฑํ
Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๊ธฐ๋ณธ ์ฌ์ดํธ๋ฅผ ๋๋๋ค:
sudo a2dissite 000-default.conf
4. ์ ์ฌ์ดํธ ํ์ฑํ
sudo a2ensite makerskorean.kr.conf
sudo systemctl reload apache2
5. HTTPS(SSL) ์ค์ (์ ํ)
๋ง์ฝ SSL์ ์ฐ๊ณ ์๋ค๋ฉด /etc/apache2/sites-available/makerskorean.kr-le-ssl.conf ๊ฐ์ ํ์ผ์ ์์ ํด์ DocumentRoot๋ฅผ /var/www/html๋ก ๋ง์ถฐ์ผ ํฉ๋๋ค.
๐ ์ ๋ฆฌ
- Virtualmin ์ค์น ํ Apache ๊ธฐ๋ณธ VirtualHost๊ฐ ๋ฐ๋์ด ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๊ฒ
- ์๋ํ๋ ์ค DocumentRoot(
/var/www/html)๋ฅผ ์ง์ ํ VirtualHost๋ฅผ ์๋ก ๋ง๋ค๊ณ , ๊ธฐ๋ณธ ์ฌ์ดํธ๋ฅผ ๋นํ์ฑํํ๋ฉด ํด๊ฒฐ - SSL์ ์ฐ๋ ๊ฒฝ์ฐ HTTPS์ฉ conf ํ์ผ๋ ๋์ผํ๊ฒ ์์ ํ์
๐ ์ง๊ธ ์๋ํ๋ ์ค๊ฐ /var/www/html์ ์ค์น๋์ด ์๋ ๊ฒ ๋ง๋์? ๊ทธ๋ ๋ค๋ฉด ์ ๊ฐ ๋ฐ๋ก SSL ํฌํจ ์ค์ ์์๊น์ง ์ ๋ฆฌํด๋๋ฆด ์ ์์ต๋๋ค.
์์ ํ์ด์ง php ์ฝ๋๊ฐ ๋ณด์ด๋ ์๋ฌ
<?php
/**
- Front to the WordPress application. This file doesn’t do anything, but loads
- wp-blog-header.php which does and tells WordPress to load the theme.
* - @package WordPress
*/
/**
- Tells WordPress to load the WordPress theme and output it.
* - @var bool
*/
define( ‘WP_USE_THEMES’, true );
/** Loads the WordPress Environment and Template */
require DIR . ‘/wp-blog-header.php’;
์ง๊ธ ์ฆ์์ ์๋ํ๋ ์ค์ index.php ์ฝ๋๊ฐ ๊ทธ๋๋ก ๋ธ๋ผ์ฐ์ ์ ๋
ธ์ถ๋๋ ์ํฉ์ธ๋ฐ, ์ด๋ ์น ์๋ฒ(Apache)๊ฐ PHP๋ฅผ ์คํํ์ง ์๊ณ ๋จ์ํ ํ
์คํธ๋ก ์ถ๋ ฅํ๊ณ ์๋ค๋ ๋ป์
๋๋ค. ์ฆ, PHP ๋ชจ๋์ด Apache์ ์ ๋๋ก ์ฐ๋๋์ง ์์๊ฑฐ๋ ๋น ์ ธ ์๋ ์ํ์์.
๐ ์์ธ
- PHP ํจํค์ง๊ฐ ์ค์น๋์ง ์์๊ฑฐ๋, Apache์ ์ฐ๋ ๋ชจ๋(
libapache2-mod-php)์ด ๋น ์ ธ ์์ - Virtualmin ์ค์น ๊ณผ์ ์์ PHP ํธ๋ค๋ฌ๊ฐ FastCGI/FPM์ผ๋ก ๋ฐ๋์๋๋ฐ ์ค์ ์ด ๊ผฌ์
- Apache ์ค์ ์์
.phpํ์ผ์ PHP๋ก ์ฒ๋ฆฌํ์ง ์๊ณ ๊ทธ๋ฅ ํ ์คํธ๋ก ๋ด๋ณด๋ด๋ ์ํ
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. PHP ์ค์น ํ์ธ
Ubuntu 24.04 ๊ธฐ์ค์ผ๋ก PHP 8.1/8.2๊ฐ ๊ธฐ๋ณธ ์ ๊ณต๋ฉ๋๋ค. ์ค์น ์ฌ๋ถ ํ์ธ:
php -v
โ ๋ฒ์ ์ด ์ ๋์ค๋ฉด ์ค์น ํ์.
์ค์น:
sudo apt update
sudo apt install php libapache2-mod-php php-mysql -y
2. Apache์ PHP ๋ชจ๋ ํ์ฑํ
sudo a2enmod php8.1 # ๋๋ php8.2, ์ค์น๋ ๋ฒ์ ์ ๋ง๊ฒ
sudo systemctl restart apache2
3. PHP ํ ์คํธ ํ์ด์ง ์์ฑ
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
โ ๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์
โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์ ๋์
4. VirtualHost ์ค์ ํ์ธ
์๋ํ๋ ์ค DocumentRoot(/var/www/html)์ ๋ํด PHP๊ฐ ํ์ฑํ๋์ด์ผ ํฉ๋๋ค./etc/apache2/sites-available/makerskorean.kr.conf ์์ ๋ค์์ด ํฌํจ๋์ด ์๋์ง ํ์ธ:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
์์ผ๋ฉด ์ถ๊ฐ ํ Apache ์ฌ์์:
sudo systemctl reload apache2
5. FPM ๋ฐฉ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
Virtualmin์ PHP-FPM์ ๊ธฐ๋ณธ์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ Apache ์ค์ ์ FastCGI ProxyPass๊ฐ ํ์ํฉ๋๋ค.
๊ฐ๋จํ ํด๊ฒฐํ๋ ค๋ฉด FPM ๋์ libapache2-mod-php ๋ฐฉ์์ผ๋ก ๋๋ฆฌ๋ ๊ฒ ํธํฉ๋๋ค.
๐ ์ ๋ฆฌ
- PHP ์ฝ๋๊ฐ ๊ทธ๋๋ก ๋ณด์ด๋ ๊ฑด Apache๊ฐ PHP๋ฅผ ์คํํ์ง ๋ชปํ๋ ์ํ
libapache2-mod-php์ค์น ๋ฐ ํ์ฑํ โ Apache ์ฌ์์- ์๋ํ๋ ์ค DocumentRoot์ PHP ํธ๋ค๋ฌ ์ ์ฉ ํ์ธ
๐ ์ง๊ธ ์๋ฒ์ PHP๊ฐ ์ค์น๋์ด ์๋์ง (php -v) ๋จผ์ ํ์ธํด ๋ณด์ธ์.
๋ง์ฝ ์ค์น๊ฐ ์ ๋์ด ์๋ค๋ฉด sudo apt install php libapache2-mod-php php-mysql๋ก ๋ฐ๋ก ํด๊ฒฐ๋ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
์ํ์๋ฉด ์ ๊ฐ Virtualmin ํ๊ฒฝ์์ PHP-FPM๊ณผ mod-php ์ค ์ด๋ค ๋ฐฉ์์ ์ฐ๋ ๊ฒ ๋ ์์ ์ ์ธ์ง ๋น๊ต๋ ์ ๋ฆฌํด๋๋ฆด๊น์?
์ง๊ธ ์ฆ์์ ์๋ํ๋ ์ค์ index.php ์ฝ๋๊ฐ ๊ทธ๋๋ก ๋ธ๋ผ์ฐ์ ์ ๋
ธ์ถ๋๋ ์ํฉ์ธ๋ฐ, ์ด๋ ์น ์๋ฒ(Apache)๊ฐ PHP๋ฅผ ์คํํ์ง ์๊ณ ๋จ์ํ ํ
์คํธ๋ก ์ถ๋ ฅํ๊ณ ์๋ค๋ ๋ป์
๋๋ค. ์ฆ, PHP ๋ชจ๋์ด Apache์ ์ ๋๋ก ์ฐ๋๋์ง ์์๊ฑฐ๋ ๋น ์ ธ ์๋ ์ํ์์.
๐ ์์ธ
- PHP ํจํค์ง๊ฐ ์ค์น๋์ง ์์๊ฑฐ๋, Apache์ ์ฐ๋ ๋ชจ๋(
libapache2-mod-php)์ด ๋น ์ ธ ์์ - Virtualmin ์ค์น ๊ณผ์ ์์ PHP ํธ๋ค๋ฌ๊ฐ FastCGI/FPM์ผ๋ก ๋ฐ๋์๋๋ฐ ์ค์ ์ด ๊ผฌ์
- Apache ์ค์ ์์
.phpํ์ผ์ PHP๋ก ์ฒ๋ฆฌํ์ง ์๊ณ ๊ทธ๋ฅ ํ ์คํธ๋ก ๋ด๋ณด๋ด๋ ์ํ
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. PHP ์ค์น ํ์ธ
Ubuntu 24.04 ๊ธฐ์ค์ผ๋ก PHP 8.1/8.2๊ฐ ๊ธฐ๋ณธ ์ ๊ณต๋ฉ๋๋ค. ์ค์น ์ฌ๋ถ ํ์ธ:
php -v
โ ๋ฒ์ ์ด ์ ๋์ค๋ฉด ์ค์น ํ์.
์ค์น:
sudo apt update
sudo apt install php libapache2-mod-php php-mysql -y
2. Apache์ PHP ๋ชจ๋ ํ์ฑํ
sudo a2enmod php8.1 # ๋๋ php8.2, ์ค์น๋ ๋ฒ์ ์ ๋ง๊ฒ
sudo systemctl restart apache2
3. PHP ํ ์คํธ ํ์ด์ง ์์ฑ
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
โ ๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์
โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์ ๋์
4. VirtualHost ์ค์ ํ์ธ
์๋ํ๋ ์ค DocumentRoot(/var/www/html)์ ๋ํด PHP๊ฐ ํ์ฑํ๋์ด์ผ ํฉ๋๋ค./etc/apache2/sites-available/makerskorean.kr.conf ์์ ๋ค์์ด ํฌํจ๋์ด ์๋์ง ํ์ธ:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
์์ผ๋ฉด ์ถ๊ฐ ํ Apache ์ฌ์์:
sudo systemctl reload apache2
5. FPM ๋ฐฉ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
Virtualmin์ PHP-FPM์ ๊ธฐ๋ณธ์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ Apache ์ค์ ์ FastCGI ProxyPass๊ฐ ํ์ํฉ๋๋ค.
๊ฐ๋จํ ํด๊ฒฐํ๋ ค๋ฉด FPM ๋์ libapache2-mod-php ๋ฐฉ์์ผ๋ก ๋๋ฆฌ๋ ๊ฒ ํธํฉ๋๋ค.
๐ ์ ๋ฆฌ
- PHP ์ฝ๋๊ฐ ๊ทธ๋๋ก ๋ณด์ด๋ ๊ฑด Apache๊ฐ PHP๋ฅผ ์คํํ์ง ๋ชปํ๋ ์ํ
libapache2-mod-php์ค์น ๋ฐ ํ์ฑํ โ Apache ์ฌ์์- ์๋ํ๋ ์ค DocumentRoot์ PHP ํธ๋ค๋ฌ ์ ์ฉ ํ์ธ
๐ ์ง๊ธ ์๋ฒ์ PHP๊ฐ ์ค์น๋์ด ์๋์ง (php -v) ๋จผ์ ํ์ธํด ๋ณด์ธ์.
๋ง์ฝ ์ค์น๊ฐ ์ ๋์ด ์๋ค๋ฉด sudo apt install php libapache2-mod-php php-mysql๋ก ๋ฐ๋ก ํด๊ฒฐ๋ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
์ํ์๋ฉด ์ ๊ฐ Virtualmin ํ๊ฒฝ์์ PHP-FPM๊ณผ mod-php ์ค ์ด๋ค ๋ฐฉ์์ ์ฐ๋ ๊ฒ ๋ ์์ ์ ์ธ์ง ๋น๊ต๋ ์ ๋ฆฌํด๋๋ฆด๊น์?
Ubuntu 24.04์์๋ libapache2-mod-php ๋จ๋
ํจํค์ง๊ฐ ์ ๊ณต๋์ง ์๊ณ , PHP ๋ฒ์ ๋ณ ๋ชจ๋(libapache2-mod-php8.3 ๋ฑ)๋ก ์ค์นํด์ผ ํฉ๋๋ค. ๋ฐ๋ผ์ libapache2-mod-php๋ฅผ ์ค์นํ๋ ค๊ณ ํ๋ฉด โno installation candidateโ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํด๊ฒฐ ๋ฐฉ๋ฒ์ ํ์ฌ ์ง์๋๋ PHP ๋ฒ์ ์ ํ์ธํ ๋ค ํด๋น ๋ฒ์ ์ Apache ๋ชจ๋์ ์ค์นํ๋ ๊ฒ์
๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ ๋จ๊ณ๋ณ
1. ํจํค์ง ๋ชฉ๋ก ์ ๋ฐ์ดํธ
sudo apt update
2. ์ค์น ๊ฐ๋ฅํ PHP ๋ฒ์ ํ์ธ
apt-cache search libapache2-mod-php
โ ๋ณดํต Ubuntu 24.04์์๋ PHP 8.3์ด ๊ธฐ๋ณธ ์ ๊ณต๋๋ฉฐ, ๊ฒฐ๊ณผ์ libapache2-mod-php8.3๊ฐ ๋ํ๋ฉ๋๋ค DevTutorial.
3. PHP์ Apache ๋ชจ๋ ์ค์น
sudo apt install php8.3 libapache2-mod-php8.3 php8.3-mysql -y
php8.3โ PHP ๋ณธ์ฒดlibapache2-mod-php8.3โ Apache์ PHP ์ฐ๋ ๋ชจ๋php8.3-mysqlโ ์๋ํ๋ ์ค DB ์ฐ๋์ฉ ํ์ฅ
์ถ๊ฐ๋ก ํ์ํ ํ์ฅ๋ ์ค์นํ ์ ์์ต๋๋ค:
sudo apt install php8.3-{xml,gd,curl,mbstring,zip} -y
4. Apache์ PHP ๋ชจ๋ ํ์ฑํ
sudo a2enmod php8.3
sudo systemctl restart apache2
5. PHP ๋์ ํ์ธ
ํ ์คํธ ํ์ผ ์์ฑ:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์ โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์.
๐ ์ ๋ฆฌ
- Ubuntu 24.04์์๋
libapache2-mod-php๋์ ๋ฒ์ ๋ณ ํจํค์ง(libapache2-mod-php8.3)๋ฅผ ์ค์นํด์ผ ํจ DevTutorial. - ์๋ํ๋ ์ค ์คํ์ ์ํด์๋ PHP ๋ณธ์ฒด + Apache ๋ชจ๋ + MySQL ํ์ฅ์ด ๋ฐ๋์ ํ์.
- ์ค์น ํ Apache ๋ชจ๋ ํ์ฑํ ๋ฐ ์ฌ์์์ ํตํด PHP ์ฝ๋๊ฐ ์คํ๋๋๋ก ํด์ผ ํจ.
๐ ์ง๊ธ ๋ฐ๋ก sudo apt install php8.3 libapache2-mod-php8.3 php8.3-mysql ์คํํด ๋ณด์๋ฉด ์๋ํ๋ ์ค ํ์ด์ง๊ฐ ์ ์์ ์ผ๋ก ๋ฐ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
ํน์ ์๋ํ๋ ์ค๊ฐ MariaDB/MySQL๊ณผ ์ฐ๊ฒฐ๋์ด ์๋ค๋ฉด, DB ํ์ฅ(php8.3-mysql)๊น์ง ๊ผญ ์ค์นํ์
จ๋์?
์ง๊ธ ์ํฉ์ Ubuntu 24.04์์ ๊ธฐ๋ณธ ์ ์ฅ์์ libapache2-mod-php8.3 ํจํค์ง๊ฐ ๋ฐ๋ก ์ ๊ณต๋์ง ์์์ ๋ฐ์ํ๋ ๋ฌธ์ ์
๋๋ค. Ubuntu 24.04๋ PHP 8.3์ ๊ธฐ๋ณธ์ผ๋ก ํฌํจํ์ง๋ง, Apache ๋ชจ๋ ํจํค์ง๊ฐ universe ์ ์ฅ์์ ๋ค์ด์๊ฑฐ๋ ์์ง ํ์ฑํ๋์ง ์์์ ์ ์์ต๋๋ค.
โ ํด๊ฒฐ ๋จ๊ณ
1. Universe ์ ์ฅ์ ํ์ฑํ
๋จผ์ Universe ์ ์ฅ์๋ฅผ ์ผ์ผ ํฉ๋๋ค:
sudo add-apt-repository universe
sudo apt update
2. PHP + Apache ๋ชจ๋ ์ค์น
์ด์ PHP์ Apache ๋ชจ๋์ ์ค์นํฉ๋๋ค:
sudo apt install php8.3 php8.3-cli php8.3-common php8.3-mysql libapache2-mod-php8.3 -y
์ถ๊ฐ๋ก ์๋ํ๋ ์ค์ ํ์ํ ํ์ฅ๋ ์ค์นํ์ธ์:
sudo apt install php8.3-{xml,gd,curl,mbstring,zip} -y
3. Apache์ PHP ๋ชจ๋ ํ์ฑํ
sudo a2enmod php8.3
sudo systemctl restart apache2
4. PHP ๋์ ํ์ธ
ํ ์คํธ ํ์ผ ์์ฑ:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
โ ๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์
โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์ ๋์ํฉ๋๋ค.
๐ ์ ๋ฆฌ
libapache2-mod-php8.3ํจํค์ง๊ฐ ์๋ค๋ ์๋ฌ๋ Universe ์ ์ฅ์๊ฐ ๋นํ์ฑํ๋ ์ํ์์ ๋ฐ์- Universe ์ ์ฅ์ ํ์ฑํ ํ
php8.3+libapache2-mod-php8.3์ค์นํ๋ฉด ํด๊ฒฐ - Apache ๋ชจ๋ ํ์ฑํ ํ ์๋ํ๋ ์ค๊ฐ ์ ์์ ์ผ๋ก PHP๋ฅผ ์คํํ๊ฒ ๋ฉ๋๋ค
๐ ์ง๊ธ ๋ฐ๋ก sudo add-apt-repository universe && sudo apt update ์คํํด ๋ณด์๊ณ , ๊ทธ ๋ค์ sudo apt install libapache2-mod-php8.3๋ฅผ ๋ค์ ์๋ํด ๋ณด์๋ฉด ๋ ๊ฒ๋๋ค.
์ํ์๋ฉด ์ ๊ฐ ์๋ํ๋ ์ค์ ํ์ํ PHP ํ์ฅ ์ ์ฒด ๋ชฉ๋ก์ ์ ๋ฆฌํด์ ํ ๋ฒ์ ์ค์นํ ์ ์๋ ๋ช ๋ น์ด๋ ์๋ ค๋๋ฆด๊น์?
์ง๊ธ ๋ง์ํ์ <?php phpinfo(); ?>๋ PHP๊ฐ ์ ์์ ์ผ๋ก ๋์ํ๋์ง ํ์ธํ๋ ํ
์คํธ ์ฝ๋์
๋๋ค.
๋ง์ฝ ๋ธ๋ผ์ฐ์ ์์ ์ด ์ฝ๋๊ฐ ๊ทธ๋๋ก ๋ณด์ด๊ณ ์คํ๋์ง ์๋๋ค๋ฉด, ์ฌ์ ํ Apache๊ฐ PHP๋ฅผ ์ฒ๋ฆฌํ์ง ๋ชปํ๋ ์ํ๋ผ๋ ๋ป์ด์์. ์ฆ, PHP ๋ชจ๋์ด ์ค์น/์ฐ๋๋์ง ์์๊ฑฐ๋ Apache ์ค์ ์ด ๊ผฌ์ฌ ์๋ ์ํฉ์ ๋๋ค.
โ ์ ๊ฒ ๋ฐ ํด๊ฒฐ ๋จ๊ณ
1. PHP ์ค์น ์ฌ๋ถ ํ์ธ
php -v
โ PHP ๋ฒ์ ์ด ์ถ๋ ฅ๋์ด์ผ ํฉ๋๋ค.
์๋ค๋ฉด ์ค์น:
sudo apt update
sudo apt install php8.3 php8.3-cli php8.3-common php8.3-mysql -y
2. Apache-PHP ์ฐ๋ ๋ชจ๋ ์ค์น
Ubuntu 24.04์์๋ ๋ฒ์ ๋ณ ๋ชจ๋์ ์ค์นํด์ผ ํฉ๋๋ค:
sudo apt install libapache2-mod-php8.3 -y
๋ง์ฝ no installation candidate ์ค๋ฅ๊ฐ ๋๋ค๋ฉด Universe ์ ์ฅ์๋ฅผ ํ์ฑํํ์ธ์:
sudo add-apt-repository universe
sudo apt update
sudo apt install libapache2-mod-php8.3 -y
3. Apache ๋ชจ๋ ํ์ฑํ
sudo a2enmod php8.3
sudo systemctl restart apache2
4. ํ ์คํธ ํ์ด์ง ์์ฑ
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
โ ๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์
โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์ ๋์
๐ ์ ๋ฆฌ
<?php phpinfo(); ?>๊ฐ ๊ทธ๋๋ก ๋ณด์ด๋ฉด PHP ๋ชจ๋์ด Apache์ ์ฐ๊ฒฐ๋์ง ์์ ์ํphp8.3+libapache2-mod-php8.3์ค์น ํ Apache ๋ชจ๋ ํ์ฑํ ํ์- Universe ์ ์ฅ์๋ฅผ ์ผ์ผ ํจํค์ง๋ฅผ ์ค์นํ ์ ์์
๐ ์ง๊ธ php -v ๋ช
๋ น์ด๋ฅผ ์คํํ์ ๋ PHP ๋ฒ์ ์ด ๋์ค๋์? ๊ทธ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ ๋ค์ ๋จ๊ณ(๋ชจ๋ ์ค์น vs PHP ์ ์ฒด ์ค์น)๋ฅผ ๋ฐ๋ก ์๋ดํด๋๋ฆด ์ ์์ต๋๋ค.
์ง๊ธ ์ํฉ์ Ubuntu 24.04 + Sury ์ ์ฅ์(PHP ํจํค์ง ์ ๊ณต) ํ๊ฒฝ์์ libapache2-mod-php8.3 ํจํค์ง๊ฐ ๊ธฐ๋ณธ ์ ์ฅ์์ ์์ด์ ๋ฐ์ํ๋ ๋ฌธ์ ์
๋๋ค.
Ubuntu 24.04์์๋ PHP ์คํ์ Apache ๋ชจ๋(mod_php) ๋์ PHP-FPM(FastCGI Process Manager) ๋ฐฉ์์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ๊ธฐ๋ณธ์
๋๋ค. ๊ทธ๋์ libapache2-mod-php8.3๊ฐ ์ ๊ณต๋์ง ์๊ณ , ๋์ php8.3-fpm์ ์ค์นํด Apache์ ์ฐ๋ํด์ผ ํฉ๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ (PHP-FPM ๋ฐฉ์)
1. PHP-FPM ์ค์น
sudo apt install php8.3-fpm -y
2. Apache์ FPM ๋ชจ๋ ํ์ฑํ
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm
sudo systemctl restart apache2
3. PHP ๋์ ํ์ธ
ํ ์คํธ ํ์ผ ์์ฑ:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
๋ธ๋ผ์ฐ์ ์์ http://makerskorean.kr/info.php ์ ์ โ PHP ์ ๋ณด ํ์ด์ง๊ฐ ๋จ๋ฉด ์ ์ ๋์.
๐ VirtualHost ์์ (Apache + PHP-FPM)
/etc/apache2/sites-available/makerskorean.kr.conf ์์ ๋ค์์ด ํฌํจ๋์ด์ผ ํฉ๋๋ค:
<VirtualHost *:80>
ServerName makerskorean.kr
ServerAlias www.makerskorean.kr
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/makers_error.log
CustomLog ${APACHE_LOG_DIR}/makers_access.log combined
</VirtualHost>
๐ ์ ๋ฆฌ
- Ubuntu 24.04์์๋
libapache2-mod-php8.3ํจํค์ง๊ฐ ์ ๊ณต๋์ง ์์ - ๋์ PHP-FPM(
php8.3-fpm)์ ์ค์นํ๊ณ Apache์ ์ฐ๋ํด์ผ PHP ์ฝ๋๊ฐ ์คํ๋จ - VirtualHost ์ค์ ์์
.phpํ์ผ์ PHP-FPM ์์ผ์ผ๋ก ๋๊ฒจ์ฃผ๋๋ก ์ง์ ํด์ผ ํจ
๐ ์ง๊ธ ๋ฐ๋ก sudo apt install php8.3-fpm ์คํ ํ Apache์ a2enconf php8.3-fpm ์ ์ฉํด ๋ณด์๋ฉด, ์๋ํ๋ ์ค๊ฐ ์ ์์ ์ผ๋ก PHP๋ฅผ ์คํํ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
์ํ์๋ฉด ์ ๊ฐ ์๋ํ๋ ์ค์ ํ์ํ PHP ํ์ฅ ์ ์ฒด ์ค์น ๋ช ๋ น์ด๋ ์ ๋ฆฌํด๋๋ฆด๊น์?
์ฐ๊ฒฐ์ด ๋น๊ณต๊ฐ๋ก ์ค์ ๋์ด ์์ง ์์ต๋๋ค.
๊ณต๊ฒฉ์๊ฐ server.makerskorean.kr์์ ์ฌ์ฉ์์ ์ ๋ณด๋ฅผ ๋์ฉํ๋ ค๊ณ ์๋ํ ์ ์์ต๋๋ค(์: ๋น๋ฐ๋ฒํธ, ๋ฉ์์ง, ์ ์ฉ์นด๋ ์ ๋ณด). ์ด ๊ฒฝ๊ณ ์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
net::ERR_CERT_COMMON_NAME_INVALID
ํฅ์๋ ๋ณดํธ ๋ชจ๋๋ฅผ ์ฌ์ฉ ์ค์ ํ์ฌ Chrome์ ๊ฐ์ฅ ๊ฐ๋ ฅํ ๋ณด์์ ํ์ฉํ์ธ์.
Ssl certificate common name invalid error on apache
๊ทธ ๊ฒฝ๊ณ ๋ ๋ธ๋ผ์ฐ์ ๊ฐ ๋ฐ์ ์ธ์ฆ์์ ์ด๋ฆ์ด ์ง๊ธ ์ ์ํ ๋๋ฉ์ธ๊ณผ ์ผ์นํ์ง ์์ ๋ ๋ฐ์ํฉ๋๋ค. ์ง๊ธ์ server.makerskorean.kr๋ก ์ ์ํ๋๋ฐ, ์๋ฒ๊ฐ ๋ด๋ณด๋ด๋ ์ธ์ฆ์๊ฐ makerskorean.kr(๋๋ ๋ค๋ฅธ ์ด๋ฆ)์ฉ์ผ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค. ์ด๋ฆ์ ๋ง์ถ๋ฉด ๋ฐ๋ก ์ฌ๋ผ์ง๋๋ค.
Whatโs likely wrong
- ๋๋ฉ์ธ ๋ถ์ผ์น: ์ธ์ฆ์๊ฐ makerskorean.kr์ฉ์ธ๋ฐ server.makerskorean.kr๋ก ์ ์ ์ค.
- SSL ๊ฐ์ํธ์คํธ ์ฐ์ ์์: Apache์ 443 ๊ฐ์ํธ์คํธ๊ฐ ์๋ชป๋ ์ฌ์ดํธ(๋ค๋ฅธ cert)๋ก ์๋ต.
- Cloudflare ํ๋ก์: ์ค๋ ์ง ๊ตฌ๋ฆ(Proxy) ์ผ ์ํ์์ ์๋ณธ/๋ชจ๋ ์ค์ ๋ถ์ผ์น.
- ๋ง๋ฃ/์ฒด์ธ ๋ฌธ์ : ์ธ์ฆ์๊ฐ ๋ง๋ฃ๋๊ฑฐ๋ ์ค๊ฐ ์ธ์ฆ์ ๋๋ฝ.
Quick checks
- ์ด๋ค ์ธ์ฆ์๊ฐ ๋๊ฐ๋์ง ํ์ธ
openssl s_client -connect server.makerskorean.kr:443 -servername server.makerskorean.kr -showcerts </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates -ext subjectAltName- SAN ๋ชฉ๋ก์ server.makerskorean.kr๊ฐ ์์ผ๋ฉด ์ ์ธ์ฆ์๊ฐ ํ์ํฉ๋๋ค.
- Apache์์ 443 ๊ฐ์ํธ์คํธ ํ์ธ
sudo apachectl -S ls /etc/apache2/sites-enabled/- server.makerskorean.kr๋ฅผ ์ํ
*:443VirtualHost๊ฐ ์๊ณ , ๊ทธ ์์ ์ธ์ฆ์ ๊ฒฝ๋ก๊ฐ ๋ง๋์ง ํ์ธํ์ธ์.
- server.makerskorean.kr๋ฅผ ์ํ
Fix it on apache (letโs encrypt)
์๋ํ๋ ์ค๊ฐ makerskorean.kr์ ์๊ณ , ๊ด๋ฆฌ/๋ฉ์ผ์ server.makerskorean.kr๋ฅผ ์ฐ๋ ๊ตฌ์กฐ๋ผ๋ฉด ๊ฐ๊ฐ ์ด๋ฆ์ ๋ง๋ ์ธ์ฆ์๋ฅผ ๋ฐ๊ธํ์ธ์.
- Certbot ์ค์น
sudo apt update sudo apt install certbot python3-certbot-apache -y - ํ์ํ ๋๋ฉ์ธ์ ๋ง์ถฐ ๋ฐ๊ธ/์ ์ฉ
- ์น์ฌ์ดํธ์ฉ
sudo certbot --apache -d makerskorean.kr -d www.makerskorean.kr - ์๋ฒ ์๋ธ๋๋ฉ์ธ(ํ์ํ๋ฉด)
sudo certbot --apache -d server.makerskorean.kr
- ์น์ฌ์ดํธ์ฉ
- ์ ์ฉ ํ ์ฌ์์
sudo systemctl reload apache2 - ์๋ ๊ฐฑ์ ํ์ธ
sudo certbot renew --dry-run
If using virtualmin
Virtualmin์์ ๋๋ฉ์ธ๋ณ๋ก SSL์ ๋ถ๋ฆฌํด ๊ด๋ฆฌํ ์ ์์ต๋๋ค.
- Server Configuration โ SSL Certificate โ Letโs Encrypt
- โDomains to includeโ์ ์ ํํ ํด๋น ํธ์คํธ๋ช ์ ๋ฃ๊ณ ๋ฐ๊ธ
- ๋ฐ๊ธ ํ ํด๋น ๋๋ฉ์ธ์ Apache SSL vhost์ ์ฌ๋ฐ๋ฅธ ๊ฒฝ๋ก๊ฐ ๋ค์ด๊ฐ๋์ง ํ์ธ:
- SSLCertificateFile /etc/letsencrypt/live/<๋๋ฉ์ธ>/fullchain.pem
- SSLCertificateKeyFile /etc/letsencrypt/live/<๋๋ฉ์ธ>/privkey.pem
์ถฉ๋์ ๋ง์ผ๋ ค๋ฉด ์๋ชป๋ ๊ธฐ๋ณธ SSL ์ฌ์ดํธ(์: 000-default-le-ssl.conf)๊ฐ ํ์ฑํ๋ผ ์์ง ์์์ง ํ์ธํ๊ณ ๋นํ์ฑํํ์ธ์.
sudo a2dissite 000-default-le-ssl.conf
sudo systemctl reload apache2
Cloudflare in front?
- DNS์์ ํด๋น A/CNAME์ด ํ๋ก์(์ค๋ ์ง ๊ตฌ๋ฆ)๋ผ๋ฉด ์๋ณธ ์๋ฒ๋ ์ ํจํ ์ธ์ฆ์๋ฅผ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
- SSL/TLS ๋ชจ๋๋ โFull (strict)โ๋ก ์ค์ , ์๋ณธ์ ์ฌ๋ฐ๋ฅธ cert๊ฐ ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค.
- ์์ธ ํ์ ์ ์ํด ์ ์ ํ์ ๊ตฌ๋ฆ(Proxy off)์ผ๋ก ๋ฐ๊พธ๊ณ ์ง์ ์ฐ๊ฒฐ ํ ์คํธ๋ฅผ ํด๋ณด์ธ์.
When itโs still not right
- ๋ค๋ฅธ ์ฌ์ดํธ๊ฐ ์๋ต:
apachectl -S๋ก SNI ๋งค์นญ์ ์ฌํ์ธํ๊ณ , server_name/ServerName์ด ์ ํํ์ง ์ ๊ฒ. - ๋ง๋ฃ:
openssl x509 -noout -dates -in /path/to/cert.pem๋ก ๋ง๋ฃ์ผ ํ์ธ ํ ์ฌ๋ฐ๊ธ. - ์ค๊ฐ ์ธ์ฆ์ ๋๋ฝ: Apache๋
fullchain.pem์ ์จ์ผ ํฉ๋๋ค.cert.pem๋ง ์ฐ๋ฉด ๋ธ๋ผ์ฐ์ ์์ ์ค๋ฅ ๋ฉ๋๋ค.
์ํ์๋ฉด ํ์ฌ apachectl -S ์ถ๋ ฅ๊ณผ sites-enabled์ ํ์ฑํ๋ SSL vhost ํ์ผ๋ช ์ ์๋ ค์ฃผ์ธ์. ์ด๋ vhost๊ฐ ์๋ต ์ค์ธ์ง, ์ด๋ค ์ธ์ฆ์๊ฐ ๋ถ์ด ์๋์ง ๋ฐ๋ก ์ง์ด๋๋ฆด๊ฒ์.
virtualmin ๊ฐ์์๋ฒ ์์ฑ์ ์๋ฌ
Failed to create virtual server : You cannot create a new domain with makerskorean.kr name, unless option “Setup SSL certificate from provider for hostname” is first disabled in “Virtualmin Configuration โพ SSL settings” page
์ด ์๋ฌ ๋ฉ์์ง๋ Virtualmin์ด ๋๋ฉ์ธ ์ด๋ฆ(makerskorean.kr)์ ์ ๊ฐ์์๋ฒ๋ก ๋ง๋ค ๋, SSL ์ธ์ฆ์ ์๋ ์ค์ ์ต์ ๋๋ฌธ์ ๋งํ๋ ์ํฉ์ ๋๋ค. ์ฆ, Virtualmin์ด โํธ์คํธ๋ค์์ฉ SSL ์ธ์ฆ์๋ฅผ ์๋์ผ๋ก ๋ฐ๊ธ/์ค์ โํ๋๋ก ๊ฐ์ ๋์ด ์๋๋ฐ, ์ด๋ฏธ ๊ฐ์ ์ด๋ฆ์ผ๋ก ์ธ์ฆ์๊ฐ ์กด์ฌํ๊ฑฐ๋ ์ถฉ๋์ด ๋ฐ์ํด์ ์ ๋๋ฉ์ธ์ ๋ง๋ค ์ ์๋ค๋ ๋ป์ด์์.
๐ ์์ธ
- Virtualmin์ SSL ์ค์ ์์ โSetup SSL certificate from provider for hostnameโ ์ต์ ์ด ์ผ์ ธ ์์.
- ์ด ์ต์ ์ ์๋ฒ ํธ์คํธ๋ค์(makerskorean.kr)์ ๋ํด ์๋์ผ๋ก SSL์ ๋ฐ๊ธํ๋ ค๊ณ ์๋ํฉ๋๋ค.
- ๊ทธ๋ฐ๋ฐ ๋์ผํ ์ด๋ฆ์ผ๋ก ์ ๊ฐ์์๋ฒ๋ฅผ ๋ง๋ค๋ ค ํ๋ ์ถฉ๋์ด ๋ฐ์ โ ์์ฑ ์คํจ.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. Virtualmin ์ค์ ์์ ์ต์ ๋๊ธฐ
- Virtualmin์ ๋ก๊ทธ์ธ
- Webmin โ Virtualmin Configuration โ SSL settings ๋ฉ๋ด๋ก ์ด๋
Setup SSL certificate from provider for hostname์ต์ ์ Disabled๋ก ๋ณ๊ฒฝ- ์ ์ฅ ํ ๋ค์ ๊ฐ์์๋ฒ ์์ฑ ์๋
2. ๊ฐ์์๋ฒ ์์ฑ ํ SSL ๋ฐ๋ก ์ค์
- ๊ฐ์์๋ฒ๋ฅผ ์ ์์ ์ผ๋ก ๋ง๋ ๋ค, ํด๋น ๋๋ฉ์ธ์ผ๋ก ๋ค์ด๊ฐ์
Server Configuration โ SSL Certificate โ Let’s Encrypt ๋ฉ๋ด์์ ์ง์ ์ธ์ฆ์๋ฅผ ๋ฐ๊ธํ๋ฉด ๋ฉ๋๋ค. - ์ด๋ ๊ฒ ํ๋ฉด ์ถฉ๋ ์์ด makerskorean.kr ๋๋ฉ์ธ์ SSL์ ์ ์ฉํ ์ ์์ต๋๋ค.
3. ๋์ (ํธ์คํธ๋ค์ ๋ถ๋ฆฌ)
- ์๋ฒ ์์ฒด ํธ์คํธ๋ค์์
server.makerskorean.kr๊ฐ์ ์๋ธ๋๋ฉ์ธ์ผ๋ก ๋๊ณ , - ์น์ฌ์ดํธ์ฉ ๊ฐ์์๋ฒ๋
makerskorean.kr๋ก ์์ฑํ๋ ๋ฐฉ์๋ ๊ถ์ฅ๋ฉ๋๋ค.
โ ์ด๋ ๊ฒ ํ๋ฉด ํธ์คํธ๋ค์ SSL๊ณผ ์น์ฌ์ดํธ SSL์ด ๋ถ๋ฆฌ๋์ด ์ถฉ๋์ด ์ค์ด๋ญ๋๋ค.
๐ ์ ๋ฆฌ
- ์๋ฌ๋ Virtualmin์ SSL ์๋ ์ค์ ์ต์ ๋๋ฌธ์ ๋ฐ์
- ํด๊ฒฐ์ฑ ์ Virtualmin Configuration โ SSL settings์์ ํด๋น ์ต์ ์ ๋๊ณ ,
- ๊ฐ์์๋ฒ ์์ฑ ํ SSL์ ๋ณ๋๋ก ๋ฐ๊ธ/์ ์ฉํ๋ ๊ฒ
๐ ์ง๊ธ ์๋ฒ ํธ์คํธ๋ค์์ makerskorean.kr๋ก ์ฐ๊ณ ๊ณ์ ๋ฐ, ์น์ฌ์ดํธ๋ ๊ฐ์ ๋๋ฉ์ธ์ ์ฐ๊ณ ์์ฃ . ๊ด๋ฆฌ ํธ์์ ํธ์คํธ๋ค์์ server.makerskorean.kr๋ก ๋ฐ๊พธ๊ณ , ์น์ฌ์ดํธ๋ makerskorean.kr๋ก ๋๋ ๊ตฌ์กฐ๊ฐ ๋ ์์ ์ ์
๋๋ค. ์ํ์๋ฉด ์ ๊ฐ ํธ์คํธ๋ค์ ๋ณ๊ฒฝ ์ ์ฐจ + Virtualmin์์ ์ฌ๋ฐ๋ฅธ SSL ์ ์ฉ ๋ฐฉ๋ฒ์ ๋จ๊ณ๋ณ๋ก ์ ๋ฆฌํด๋๋ฆด๊น์?
ํ์ฌ ๊ธฐ์กด์ ์๋ํ๋ ์ค๋ก ๊ฐ์ง ์๊ณ virtualmin ์๋ด ํ์ด์ง๋ก ์ ์์ด ๋๋ ๋ฌธ์
<VirtualHost *:80>
SuexecUserGroup #1001 #1001
ServerName makerskorean.kr
DocumentRoot /var/www/html
ErrorLog /var/log/virtualmin/makerskorean.kr_error_log
CustomLog /var/log/virtualmin/makerskorean.kr_access_log combined
ScriptAlias /cgi-bin/ /home/._hostname/cgi-bin/
DirectoryIndex index.php index.htm index.html
<Directory /home/._hostname/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
Require all granted
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType text/plain .php
</Directory>
<Directory /home/._hostname/cgi-bin>
Require all granted
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
ProxyPass /.well-known !
RemoveHandler .php
<FilesMatch \.php$>
SetHandler None
AddType text/plain .php
</FilesMatch>
<Directory "/var/www/html">
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
</VirtualHost>
<VirtualHost *:443>
SuexecUserGroup #1001 #1001
ServerName makerskorean.kr
DocumentRoot /var/www/html
ErrorLog /var/log/virtualmin/makerskorean.kr_error_log
CustomLog /var/log/virtualmin/makerskorean.kr_access_log combined
ScriptAlias /cgi-bin/ /home/._hostname/cgi-bin/
DirectoryIndex index.php index.htm index.html
<Directory /home/._hostname/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
Require all granted
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType text/plain .php
</Directory>
<Directory /home/._hostname/cgi-bin>
Require all granted
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
<FilesMatch \.php$>
SetHandler None
AddType text/plain .php
</FilesMatch>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
ProxyPass /.well-known !
RemoveHandler .php
SSLEngine on
SSLCertificateFile /etc/ssl/virtualmin/1768305416335929/ssl.combined
SSLCertificateKeyFile /etc/ssl/virtualmin/1768305416335929/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
<Directory "/var/www/html">
</Directory>
</VirtualHost>
์ง๊ธ ๋ณด์ฌ์ฃผ์ Apache VirtualHost ์ค์ ์ ๋ณด๋ฉด, ์๋ํ๋ ์ค๊ฐ ์ค์น๋ /var/www/html์ DocumentRoot๋ก ์ง์ ํ๋๋ฐ๋ ์ ์ ์ Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ์ด์ ๋ ๋ช ๊ฐ์ง ์ค์ ์ถฉ๋ ๋๋ฌธ์
๋๋ค. ํต์ฌ์ Virtualmin์ด ์๋์ผ๋ก ์ถ๊ฐํ ๋๋ ํ ๋ฆฌ ์ค์ ๊ณผ PHP ํธ๋ค๋ฌ ๋ถ๋ถ์
๋๋ค.
๐ ๋ฌธ์ ํฌ์ธํธ
- ์ค๋ณต๋ Directory ์ค์
<Directory /home/._hostname/public_html>๋ธ๋ก์ด ์กด์ฌํ๋ฉด์.php๋ฅผtext/plain์ผ๋ก ์ง์ ํ๊ณ ์์ต๋๋ค.- ์ด ๋๋ฌธ์ PHP ํ์ผ์ด ์คํ๋์ง ์๊ณ ํ ์คํธ๋ก ์ถ๋ ฅ๋๊ฑฐ๋ Virtualmin ๊ธฐ๋ณธ ํ์ด์ง๊ฐ ์ฐ์ ์ ์ฉ๋ฉ๋๋ค.
- RemoveHandler / AddType text/plain .php
.phpํ์ฅ์๋ฅผ PHP๋ก ์ฒ๋ฆฌํ์ง ์๊ณ ๋จ์ ํ ์คํธ๋ก ์ฒ๋ฆฌํ๋๋ก ๊ฐ์ ํ๊ณ ์์ต๋๋ค.- ์๋ํ๋ ์ค index.php๊ฐ ์คํ๋์ง ์๊ณ ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ์์ธ.
- Virtualmin ๊ธฐ๋ณธ VirtualHost ์ฐ์ ์์
- Apache๋ ์ฒซ ๋ฒ์งธ ๋ก๋๋ VirtualHost(ํนํ
000-default.conf๋ Virtualmin์ด ๋ง๋ ๊ธฐ๋ณธ vhost)๋ฅผ ๊ธฐ๋ณธ ์๋ต์ผ๋ก ์ฌ์ฉํฉ๋๋ค. - makerskorean.kr ์์ฒญ์ด ์ฌ๋ฐ๋ฅธ VirtualHost๋ก ๋งค์นญ๋์ง ์์ผ๋ฉด Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋น๋๋ค.
- Apache๋ ์ฒซ ๋ฒ์งธ ๋ก๋๋ VirtualHost(ํนํ
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. ๋ถํ์ํ PHP ๋ฌด๋ ฅํ ์ค์ ์ ๊ฑฐ
makerskorean.kr.conf์์ ๋ค์ ์ค๋ค์ ์ญ์ ํ๊ฑฐ๋ ์ฃผ์ ์ฒ๋ฆฌํ์ธ์:
AddType text/plain .php
RemoveHandler .php
<FilesMatch \.php$>
SetHandler None
AddType text/plain .php
</FilesMatch>
โ ์ด ๋ถ๋ถ์ด PHP ์คํ์ ๋ง๊ณ ์์ต๋๋ค.
2. ์ฌ๋ฐ๋ฅธ PHP-FPM ํธ๋ค๋ฌ๋ง ์ ์ง
๋จ๊ฒจ์ผ ํ ๋ถ๋ถ์ ์๋์ฒ๋ผ ๋จ์ํ:
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
3. DocumentRoot ํ์ธ
์๋ํ๋ ์ค๊ฐ /var/www/html์ ์ค์น๋์ด ์๋ค๋ฉด VirtualHost์ DocumentRoot๋ ๋ฐ๋์ ๊ทธ ๊ฒฝ๋ก์ฌ์ผ ํฉ๋๋ค:
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
4. ๊ธฐ๋ณธ ์ฌ์ดํธ ๋นํ์ฑํ
Virtualmin ์๋ด ํ์ด์ง๊ฐ ๋จ๋ ๊ฑด ๊ธฐ๋ณธ SSL ์ฌ์ดํธ๊ฐ ๋จผ์ ์๋ตํ๊ธฐ ๋๋ฌธ์ผ ์ ์์ต๋๋ค.
sudo a2dissite 000-default.conf
sudo a2dissite 000-default-le-ssl.conf
sudo systemctl reload apache2
5. VirtualHost ๋งค์นญ ํ์ธ
sudo apachectl -S
โ makerskorean.kr ์์ฒญ์ด ์ฌ๋ฐ๋ฅธ VirtualHost์ ๋งค์นญ๋๋์ง ํ์ธํ์ธ์.
๐ ์ ๋ฆฌ
- Virtualmin์ด ์ถ๊ฐํ
.php โ text/plain์ค์ ๋๋ฌธ์ ์๋ํ๋ ์ค๊ฐ ์คํ๋์ง ์๊ณ ์๋ด ํ์ด์ง๊ฐ ๋ธ - ํด๋น ์ค์ ์ ์ ๊ฑฐํ๊ณ PHP-FPM ํธ๋ค๋ฌ๋ง ๋จ๊ฒจ์ผ ํจ
- DocumentRoot๋ฅผ
/var/www/html๋ก ํ์คํ ์ง์ - ๊ธฐ๋ณธ VirtualHost(000-default.conf ๋ฑ)๋ฅผ ๋นํ์ฑํํด์ makerskorean.kr์ด ์ฌ๋ฐ๋ฅธ vhost๋ก ๋งค์นญ๋๋๋ก ํด์ผ ํจ
๐ ์ถ์ฒ ์์:
makerskorean.kr.conf์์.php๋ฌด๋ ฅํ ์ค์ ์ ๊ฑฐ- Apache ์ฌ์์ ํ
http://makerskorean.kr์ ์ ํ ์คํธ - ๋ฌธ์ ๊ฐ ๊ณ์๋๋ฉด
apachectl -S์ถ๋ ฅ ํ์ธํด์ ์ด๋ค VirtualHost๊ฐ ์ค์ ์๋ตํ๋์ง ํ์ธ
์ํ์๋ฉด ์ ๊ฐ ์์ ๋ ์์ ํ VirtualHost ์์๋ฅผ ๋ฐ๋ก ์์ฑํด๋๋ฆด๊น์?
https://makerskorean.kr๋ก ์ ์์ ํด๋ https://www.makerskorean.kr๋ก ์ ์์ด ๋๋ ์ด์
์ข์ ํฌ์ธํธ๋ฅผ ์ง์ผ์
จ์ด์ ๐https://makerskorean.kr๋ก ์ ์ํ๋๋ฐ ์๋์ผ๋ก https://www.makerskorean.kr๋ก ๋ฆฌ๋ค์ด๋ ํธ๋๋ ์ด์ ๋ ์น ์๋ฒ(Apache/Nginx) ๋๋ DNS/Cloudflare ์ค์ ์์ www ๋๋ฉ์ธ์ ๊ธฐ๋ณธ์ผ๋ก ๊ฐ์ ํ๊ณ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
๐ ๊ฐ๋ฅํ ์์ธ
1. Apache VirtualHost ์ค์
ServerName์ดwww.makerskorean.kr๋ก ๋์ด ์๊ณ ,makerskorean.kr์ServerAlias๋ก ์ฒ๋ฆฌ๋๋ ๊ฒฝ์ฐ- ๋๋
makerskorean.kr์์ฒญ์www.makerskorean.kr๋ก Rewrite/Redirectํ๋๋ก ์ค์ ๋ ๊ฒฝ์ฐ:RewriteEngine On RewriteCond %{HTTP_HOST} ^makerskorean\.kr [NC] RewriteRule ^(.*)$ https://www.makerskorean.kr/$1 [L,R=301]
2. WordPress ์ค์
- ์๋ํ๋ ์ค ์ผ๋ฐ ์ค์ โ ์ฌ์ดํธ ์ฃผ์(URL) ๊ฐ
https://www.makerskorean.kr๋ก ์ ์ฅ๋์ด ์์ผ๋ฉด, - makerskorean.kr๋ก ์ ์ํด๋ ์๋ํ๋ ์ค๊ฐ ์๋์ผ๋ก www ์ฃผ์๋ก ๋ฆฌ๋ค์ด๋ ํธํฉ๋๋ค.
3. Cloudflare/DNS ์ค์
- Cloudflare์์ โAlways Use WWWโ ๊ฐ์ ๊ท์น์ด ์ ์ฉ๋์ด ์์ ์ ์์ต๋๋ค.
- DNS ๋ ์ฝ๋์์
makerskorean.kr์ดwww.makerskorean.kr๋ก CNAME ์ฒ๋ฆฌ๋ ๊ฒฝ์ฐ๋ ์์ต๋๋ค.
โ ํด๊ฒฐ ๋ฐฉ๋ฒ
A. Apache์์ www ๊ฐ์ ๋ฆฌ๋ค์ด๋ ํธ ์ ๊ฑฐ
/etc/apache2/sites-available/makerskorean.kr.conf ํ์ธ ํ, ์์ ๊ฐ์ Rewrite ๊ท์น์ด ์์ผ๋ฉด ์ญ์ ํ๊ฑฐ๋ ์์ ํ์ธ์.ServerName makerskorean.kr์ ๊ธฐ๋ณธ์ผ๋ก ๋๊ณ , ServerAlias www.makerskorean.kr๋ก ์ค์ ํ๋ฉด www์ non-www ๋ชจ๋ ์ ์ ๊ฐ๋ฅํ๊ฒ ๋ฉ๋๋ค.
์์:
<VirtualHost *:80>
ServerName makerskorean.kr
ServerAlias www.makerskorean.kr
DocumentRoot /var/www/html
</VirtualHost>
B. WordPress ์ฌ์ดํธ ์ฃผ์ ์์
์๋ํ๋ ์ค ๊ด๋ฆฌ์ โ ์ค์ โ ์ผ๋ฐ์์
- ์๋ํ๋ ์ค ์ฃผ์(URL)
- ์ฌ์ดํธ ์ฃผ์(URL)
๋ฅผhttps://makerskorean.kr๋ก ๋ณ๊ฒฝํ์ธ์.
C. Cloudflare/DNS ํ์ธ
- Cloudflare Page Rules, Redirect Rules์ www ๊ฐ์ ๊ท์น์ด ์๋์ง ํ์ธ
- DNS์์
makerskorean.kr์ดwww.makerskorean.kr๋ก CNAME ์ฒ๋ฆฌ๋์ด ์์ง ์์์ง ํ์ธ
๐ ์ ๋ฆฌ
- makerskorean.kr โ www.makerskorean.kr๋ก ๋ฆฌ๋ค์ด๋ ํธ๋๋ ๊ฑด ์๋ฒ ์ค์ , ์๋ํ๋ ์ค ์ค์ , ๋๋ Cloudflare ๊ท์น ๋๋ฌธ
- ์ํ๋ ์ฃผ์๋ฅผ ๊ธฐ๋ณธ์ผ๋ก ์ฐ๋ ค๋ฉด Apache VirtualHost์ ServerName/ServerAlias, ์๋ํ๋ ์ค ์ฌ์ดํธ ์ฃผ์, Cloudflare ๊ท์น์ ์ผ์น์์ผ์ผ ํฉ๋๋ค
๐ ์ง๊ธ ์๋ํ๋ ์ค ๊ด๋ฆฌ์์์ ์ฌ์ดํธ ์ฃผ์๊ฐ https://www.makerskorean.kr๋ก ๋์ด ์์ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
ํน์ ์ํ์๋ ๊ธฐ๋ณธ ์ฃผ์๊ฐ www ์๋ ๋ฒ์ (makerskorean.kr)์ธ๊ฐ์, ์๋๋ฉด www ๋ถ์ ๋ฒ์ (www.makerskorean.kr)์ธ๊ฐ์?
