-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_apache.sh
40 lines (33 loc) · 1.04 KB
/
setup_apache.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Variables
APP_PATH="$HOME/stream"
WEB_DIR="/var/www/html"
APACHE_CONFIG_FILE="/etc/apache2/sites-available/000-default.conf"
# Move the application to the web directory
if [ -d "$APP_PATH" ]; then
sudo mv "$APP_PATH" "$WEB_DIR/stream"
else
echo "Application directory $APP_PATH does not exist."
exit 1
fi
# Set permissions
sudo chown -R www-data:www-data "$WEB_DIR/stream"
sudo find "$WEB_DIR/stream" -type d -exec chmod 755 {} \;
sudo find "$WEB_DIR/stream" -type f -exec chmod 644 {} \;
# Create Apache Virtual Host configuration
sudo bash -c "cat > $APACHE_CONFIG_FILE <<'EOL'
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot $WEB_DIR/stream
<Directory $WEB_DIR/stream>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/error.log
CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOL"
# Enable necessary Apache modules
sudo a2enmod rewrite
# Restart Apache to apply changes
sudo systemctl restart apache2