Created
August 12, 2011 03:38
-
-
Save ramimassoud/1141387 to your computer and use it in GitHub Desktop.
Script to automatically configure the web stack and setup one or more websites. Part of https://github.com/ramimassoud/New-Server-Rollout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASEDIR=$(dirname $0) | |
# Get the ip address for the virtual host declaration | |
IP=$(ifconfig eth0 | grep -Po "inet addr:\d+\.\d+\.\d+\.\d+" | grep -Po "\d+\.\d+\.\d+\.\d+") | |
apt-get install apache2 php5 php5-mcrypt php-pear libapache2-mod-php5 \ | |
mysql-server php5-mysql postgresql php5-pgsql | |
echo "Sites to configure (space delimited)" | |
read SITES | |
for SITE in $SITES; do | |
cp $BASEDIR/site_template /etc/apache2/sites-available/$SITE | |
if [ -f /etc/apache2/sites-available/$SITE ]; then | |
sed -i "s/example\.com/$SITE/g;s/IPADDRESS/$IP/g" /etc/apache2/sites-available/$SITE | |
a2ensite $SITE | |
else | |
echo "Apache configuration for $SITE failed" | |
fi | |
mkdir -p /var/www/$SITE/logs /var/www/$SITE/public_html | |
if [ -e /var/www/$SITE/public_html ]; then | |
cp $BASEDIR/index.html /var/www/$SITE/public_html/index.html | |
else | |
echo "Directory configuration for $SITE failed" | |
fi | |
done | |
/etc/init.d/apache2 reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment