Add setup_common.sh
This commit is contained in:
50
setup_common.sh
Normal file
50
setup_common.sh
Normal file
@ -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" <<EOF
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot $WEB_ROOT
|
||||
<Directory $WEB_ROOT>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
ErrorLog logs/${WEB_USER}-error.log
|
||||
CustomLog logs/${WEB_USER}-access.log combined
|
||||
</VirtualHost>
|
||||
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 준비됨."
|
||||
Reference in New Issue
Block a user