Skip to content

Commit

Permalink
LAMP & Apache2 Vhosts creator .sh
Browse files Browse the repository at this point in the history
  • Loading branch information
vpiskunov committed Apr 19, 2015
1 parent 96cc6c9 commit 30ac8b9
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

#Instructions to use this script
#
#chmod +x SCRIPTNAME.sh
#
#sudo ./SCRIPTNAME.sh

echo "###################################################################################"
echo "Please be Patient: Installation will start now.......and it will take some time :)"
echo "###################################################################################"

#Update the repositories

sudo apt-get update

#Apache, Php, MySQL and required packages installation

sudo apt-get -y install apache2 php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-mysql php5-gd php5-cli php5-dev mysql-client
php5enmod mcrypt

sudo apt-get -y install mysql-server

#Restart all the installed services to verify that everything is installed properly

echo -e "\n"

service apache2 restart && service mysql restart > /dev/null

echo -e "\n"

if [ $? -ne 0 ]; then
echo "Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)
else
echo "Installed Services run $(tput bold)$(tput setaf 2)Sucessfully$(tput sgr0)"
fi
echo -e "\n"
88 changes: 88 additions & 0 deletions vhost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash
clear
echo 'Welcome to Apache2 Virtual Host Creator!'
echo ''
echo 'Hosts will be created in:'
echo '/etc/apache2/sites-available'
echo '/etc/apache2/sites-enabled'
echo ''
echo ''

echo 'Please enter domain name:'
read domainName
if [ $domainName ]; then
echo " ### Set domain name to: $domainName"
else
echo ' ### ERROR: no Domain Name given! Exiting...'
echo ''
echo ''
exit 0
fi


echo ''
echo 'Please enter which IP to listen at:[*]'
read ipaddress
if [ $ipaddress ]; then
echo -e " ### Setting IP address to $ipaddress"
else
echo " ### Setting IP adress to '*' (all IPs, default)"
ipaddress='*'
fi

echo ''
echo 'Please enter which Port to listen at:[80]'
read port

if [ $port ]; then
echo -e " ### Setting port to $port"
else
echo " ### Setting port to 80 (default)"
port='80'
fi

echo ''
echo ''

echo 'Please enter host root directory name(without /var/www/):'
read dirName
if [ $dirName ]; then
echo ''
else
echo ' ### ERROR: no ROOT Directory Name given! Exiting...'
echo ''
echo ''
exit 0
fi

vhost="<VirtualHost $ipaddress:$port>
ServerName $domainName
ServerAlias www.$domainName
DocumentRoot '/var/www/$dirName'
<Directory />
Require all granted
Options -Indexes +FollowSymLinks +Includes +ExecCGI
IndexIgnore css js fonts images
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>"



if [ ! -e "/etc/apache2/sites-available/generated-$domainName.conf" ]; then
echo "$vhost" > /etc/apache2/sites-available/generated-$domainName.conf
else
echo ' ### ERROR: sites-available => file exists already!'
exit 0
fi
if [ ! -e "/etc/apache2/sites-enabled/generated-$domainName.conf" ]; then
echo "$vhost" > /etc/apache2/sites-enabled/generated-$domainName.conf
else
echo ' ### ERROR: sites-enabled => file exists already!'
exit 0
fi

echo 'Restarting apache... Please wait...'
service apache2 restart

0 comments on commit 30ac8b9

Please sign in to comment.