-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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" |
This file contains 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
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 |