μ€μ΅ λͺ©ν
Apache μΉ μλ²λ₯Ό μ΄μ©νμ¬ νλμ μλ²μμ μ¬λ¬ κ°μ λλ©μΈμ μ΄μνλ λ°©λ²μ μ΅νκ³ , μ¬μ©μλ³ ννμ΄μ§λ₯Ό ꡬμΆνμλ€. λν HTMLμ μ΄μ©νμ¬ μΉ νμ΄μ§λ₯Ό μ μνκ³ , λ°±μ μ€ν¬λ¦½νΈμ Cronμ μ΄μ©ν μλ λ°±μ λ°©λ²μ μ€μ΅νμλ€.
1. νΈμ€νΈ μ΄λ¦ λ³κ²½
hostnameμ μ¬μ©νμ¬ νΈμ€νΈ μ΄λ¦μ νμΈ ν μ μμ.
sudo hostnamectl set-hostname IP024μΌλ‘ λ³κ²½.
sudo rebootμΌλ‘ hostname λ³κ²½ μ μ©νκΈ°.
2. μ¬μ©μ κ³μ λ° ννμ΄μ§ λλ ν°λ¦¬ μμ±
sudo adduser [μ¬μ©μμ΄λ¦]μ¬μ©μ κ³μ μμ±.
cd /home/[μ¬μ©μμ΄λ¦]κΈ°λ³Έμ μΌλ‘ /home κ²½λ‘μ μμ±μ΄ λ¨
/etc/skel λλ ν°λ¦¬μ
public_html, logs, index.html, access.log, error.logλ₯Ό μμ±νλ©΄
μλ‘μ΄ μ¬μ©μκ° λ§λ€μ΄μ§ λ κΈ°λ³Έ ννμ΄μ§ κ΅¬μ‘°κ° μλμΌλ‘ μμ±λλλ‘ μ€μ ν μ μμ.
μ΄ν st1λΆν° st6κΉμ§μ μ¬μ©μ κ³μ μ μμ±νμ¬
κ° μ¬μ©μμ ννμ΄μ§κ° /home/st[μ«μ]/public_html λλ ν°λ¦¬μ μμ±λλλ‘ κ΅¬μ±νμλ€.
3. Apache VirtualHost μ€μ
/etc/apache2/sites-available/hosting.confνμΌ μμ± ν VirtualHost μ€μ .
κ° λλ©μΈμ΄ μλ‘ λ€λ₯Έ μ¬μ©μμ ννμ΄μ§λ₯Ό λ°λΌλ³΄λλ‘
DocumentRoot, ServerName, ErrorLog, CustomLogλ₯Ό μ€μ .
<VirtualHost *:80>
DocumentRoot /home/master/public_html
ServerName jjh.kr
ServerAdmin webmaster/@jjh.kr
ErrorLog /home/master/public_html/logs/erroe.log
CustomLog /home/master/public_html/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/st1/public_html
ServerName st1.jjh.kr
ServerAdmin webmaster/@st1.jjh.kr
ErrorLog /home/st1/public_html/logs/erroe.log
CustomLog /home/st1/public_html/logs/access.log combined
</VirtualHost>
4. Apache μ¬μ΄νΈ νμ±ν λ° κ΄λ¦¬
sudo a2ensite hosting : λ΄κ° μμ±ν hosing.conf νμ±ν νκ² λ€.
sudo a2dissite 000-default : Apache κΈ°λ³Έ μ¬μ΄νΈλ₯Ό λΉνμ±ν
λ€μ, λͺ λ Ήμ΄λ₯Ό μ¬μ©νμ¬ Apache μλΉμ€λ₯Ό κ΄λ¦¬νλ λ°©λ².
sudo systemctl start apache2: μλΉμ€ μμsudo systemctl stop apache2: μλΉμ€ μ’ λ£sudo systemctl restart apache2: μλΉμ€ μ¬μμsudo systemctl reload apache2: μ€μ λ§ λ€μ λΆλ¬μ€κΈ°
5. UserDir λ° μ κ·Ό κΆν μ€μ
sudo a2enmod userdir : μ¬μ©μ ν λλ ν°λ¦¬μμ μΉ νμ΄μ§λ₯Ό μ 곡ν μ μλλ‘ UserDir λͺ¨λμ νμ±ν.
chmodλ₯Ό μ΄μ©νμ¬ μ¬μ©μ ν λλ ν°λ¦¬μ public_html λλ ν°λ¦¬μ μ κ·Ό κΆνμ μ€μ νμ.
chmod 711 /home/masterchmod 755 /home/master/public_htmlchmod 711 /home/st1chmod 755 /home/st1/public_html
6. HTML μΉ νμ΄μ§ μ μ
FTPλ₯Ό μ΄μ©νμ¬ μΉ μλ²μ νμΌμ μ λ‘λνκ³ , Visual Studio Codeλ₯Ό μ΄μ©νμ¬ HTML νμΌμ μμ±νμλ€.
nano index.html λͺ
λ Ήμ΄λ₯Ό μ΄μ©νμ¬ μλ²μμ μ§μ HTML νμΌμ μμ νλ λ°©λ²λ μ€μ΅νμλ€.
λ©μΈ ννμ΄μ§λ /home/master/public_htmlμ μμ±νμμΌλ©°,
μ€μ΅ λ΄μ©μ μ 리νλ νμ΄μ§λ ν¨κ» μ μνμλ€.
7. λ°±μ μ€ν¬λ¦½νΈ μμ±
Bash Shell Scriptλ₯Ό μ΄μ©νμ¬ ννμ΄μ§λ₯Ό μλμΌλ‘ λ°±μ νλ μ€ν¬λ¦½νΈλ₯Ό μμ±νμλ€.
backup.sh νμΌμ μμ±ν ν chmod 777 backup.sh λͺ
λ Ήμ΄λ₯Ό μ¬μ©νμ¬ μ€ν κΆνμ λΆμ¬νμλ€.
μ€ν¬λ¦½νΈμμλ tar λͺ
λ Ήμ΄λ₯Ό μ΄μ©νμ¬ /home/master/public_html λλ ν°λ¦¬λ₯Ό μμΆνκ³ ,
λ°±μ
νμΌμ /backup ν΄λμ μ μ₯νλλ‘ μμ±νμλ€.
λν μ€λλ λ°±μ νμΌμ μλμΌλ‘ μμ νλλ‘ μ€μ νμλ€.
8. Cronμ μ΄μ©ν μλ λ°±μ
Cron μλΉμ€λ₯Ό μ΄μ©νμ¬ λ°±μ μ΄ μλμΌλ‘ μ€νλλλ‘ μ€μ νμλ€.
sudo systemctl restart cron λͺ
λ Ήμ΄λ₯Ό μ€ννμ¬ Cron μλΉμ€λ₯Ό μ¬μμνμλ€.
Cron ννμμ μ΄μ©νμ¬ λ§€μΌ μλ²½ 2μ, λ§€μΌ μ€μ 1μ 30λΆ, λ§€μ£Ό μΌμμΌ μλ²½ 3μ, λ§€μκ° μ€ννλ λ°©λ²μ μ€μ΅νμλ€.
λν λ°±μ μ€ν κ²°κ³Όλ₯Ό λ‘κ·Έ νμΌμ μ μ₯νλ λ°©λ²λ ν¨κ» νμ΅νμλ€.
μ€μ΅ κ²°κ³Ό
Apache VirtualHostλ₯Ό μ΄μ©νμ¬ νλμ μλ²μμ μ¬λ¬ κ°μ λλ©μΈμ μ΄μν μ μλλ‘ μ€μ νμλ€. λν μ¬μ©μλ³ ννμ΄μ§λ₯Ό ꡬμΆνκ³ HTMLμ μ΄μ©νμ¬ μΉ νμ΄μ§λ₯Ό μ μνμλ€. λ§μ§λ§μΌλ‘ Bash Shell Scriptμ Cronμ μ΄μ©νμ¬ ννμ΄μ§λ₯Ό μλμΌλ‘ λ°±μ νλ μμ€ν μ ꡬμΆνμλ€.
λ°°μ΄ μ
μ΄λ² μ€μ΅μ ν΅ν΄ Apache VirtualHostμ λμ μ리μ μ¬μ©μλ³ ννμ΄μ§ μ΄μ λ°©λ²μ μ΄ν΄νμλ€. λν HTMLμ μ΄μ©ν μΉ νμ΄μ§ μ μκ³Ό Bash Shell Scriptλ₯Ό νμ©ν μλ λ°±μ , Cronμ μ΄μ©ν μμ μλν λ°©λ²μ μ΅νλ©΄μ μ€μ μλ² μ΄μμ νμν κΈ°μ΄ κΈ°μ μ νμ΅ν μ μμλ€.