commit ae03eeef1474ed3d975652d5be90b5313807138a Author: siane Date: Tue Dec 23 10:38:37 2025 +0900 Add setup_common.sh diff --git a/setup_common.sh b/setup_common.sh new file mode 100644 index 0000000..3b0eccb --- /dev/null +++ b/setup_common.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# 공통 설치 스크립트 (Rocky Linux 9) +# 현재 사용자 기준으로 웹 루트 생성 + +WEB_USER=$USER +WEB_HOME=$(eval echo "~$WEB_USER") +WEB_ROOT="$WEB_HOME/www" + +echo "설치 사용자: $WEB_USER" +echo "웹 루트: $WEB_ROOT" + +# 1. 시스템 업데이트 +sudo dnf update -y + +# 2. www 폴더 생성 +mkdir -p "$WEB_ROOT" +chmod 755 "$WEB_ROOT" + +# 3. Apache 설치 및 설정 +sudo dnf install httpd -y +sudo systemctl enable --now httpd + +# Apache DocumentRoot 설정 +APACHE_CONF="/etc/httpd/conf.d/${WEB_USER}.conf" +sudo bash -c "cat > $APACHE_CONF" < + ServerAdmin webmaster@localhost + DocumentRoot $WEB_ROOT + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + ErrorLog logs/${WEB_USER}-error.log + CustomLog logs/${WEB_USER}-access.log combined + +EOF + +sudo systemctl restart httpd + +# 4. FTP 설치 및 설정 (vsftpd) +sudo dnf install vsftpd -y +sudo systemctl enable --now vsftpd + +sudo sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf +sudo sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/' /etc/vsftpd/vsftpd.conf +sudo bash -c "echo 'allow_writeable_chroot=YES' >> /etc/vsftpd/vsftpd.conf" +sudo systemctl restart vsftpd + +echo "공통 설정 완료! Apache + FTP 준비됨."