Page MenuHomePhabricator

Apache Deployment Script
ActivePublic

Authored by sebastian on Wed, Mar 18, 11:59 AM.
#!/bin/bash
echo ""
echo "###########################"
echo " Magic3W Deployment-Script"
echo "###########################"
echo ""
echo "This script automatically installs a LAMP-stack."
echo ""
if [ -n "$1" ]; then
echo "Deploying $1..."
else
echo "insufficient arguments!"
exit 1
fi
echo ""
echo -e ">> Do you want to start the installation process for $1? yes|no"
read option
if [ "$option" = "yes" ]; then
echo ""
else
exit 0
fi
echo ">> Updating the system"
sudo apt-get update && sudo apt-get upgrade -y
echo ">> Installing Apache2"
sudo apt-get install apache2 -y
echo ">> Installing MySQL"
sudo apt-get install mariadb-server -y
echo ">> Installing PHP"
sudo apt-get install php-fpm php-bcmath php-cli php-common php-json php-mbstring php-memcache php-mysql php-curl php-zip libapache2-mod-php -y
a2dismod php mpm_prefork
a2enmod mpm_event proxy_fcgi
echo ">> Installing Certbot"
sudo apt-get install software-properties-common -y
sudo apt-get update
sudo apt-get install certbot python-certbot-apache -y
echo ">> Setting up the folders"
sudo mkdir -p /var/www/$1/public
echo ">> Creating the apache vhost-file"
# https://stackoverflow.com/questions/6214743/create-new-file-from-templates-with-bash-script
# https://phabricator.magic3w.com/P5
wget https://phabricator.magic3w.com/file/data/zhma26cqy3si7h2g7nji/PHID-FILE-obm2g7gfrrdu3jad2cfc/raw.txt -O /tmp/vhost.conf
sed -e "s;%HOST%;$1;g" /tmp/vhost.conf > /etc/apache2/sites-available/$1.conf
rm /tmp/vhost.conf
echo ">> Enabling the apache vhost-file"
sudo ln -s /etc/apache2/sites-available/$1.conf /etc/apache2/sites-enabled
echo -e ">> Do you want to set up a SSL-certificate? yes|no"
read option
if [ "$option" = "yes" ]; then
sudo certbot --apache -d "$1"
fi
echo ">> Restarting apache2"
sudo systemctl restart apache2
echo ""
echo "## Installation is completed! ##"
echo ""
echo -e ">> Do you want to restart the system now? yes|no"
read option
if [ "$option" = "yes" ]; then
sudo reboot now
fi
exit 0

Event Timeline

sebastian created this paste.Wed, Mar 18, 11:59 AM
sebastian changed the visibility from "All Users" to "Public (No Login Required)".Fri, Mar 20, 10:04 AM
sebastian changed the edit policy from "All Users" to "Administrators".