Skip to content

Instantly share code, notes, and snippets.

@tinker1987
Last active September 6, 2017 15:06
Show Gist options
  • Save tinker1987/cb4207b30e9cebd82234ade594cf61a4 to your computer and use it in GitHub Desktop.
Save tinker1987/cb4207b30e9cebd82234ade594cf61a4 to your computer and use it in GitHub Desktop.
#!/bin/bash
PHP_V="$2";
if [ $PHP_V == "" ]; then
PHP_V=1
fi
__done(){
echo -e "Done\n";
}
__setup_php(){
echo "Installing PHP...";
add-apt-repository ppa:ondrej/php
sudo apt-get update
apt install -y php-pear php7.$PHP_V php7.$PHP_V-bcmath php7.$PHP_V-bz2 php7.$PHP_V-common php7.$PHP_V-curl php7.$PHP_V-dev php7.$PHP_V-fpm php7.$PHP_V-gd php7.$PHP_V-mbstring php7.$PHP_V-mcrypt php7.$PHP_V-mysql php7.$PHP_V-pgsql php7.$PHP_V-opcache php7.$PHP_V-xml php7.$PHP_V-xsl
__done;
echo "Installing Composer...";
curl -sS https://getcomposer.org/installer | php
mv ./composer.phar /usr/local/bin/composer
__done;
pecl install xdebug
# config xdebug
xdbg='zend_extension=/usr/lib/php/20160303/xdebug.so\n'
xdbg+='xdebug.remote_handler = dbgp\n'
xdbg+='xdebug.remote_host = localhost\n'
xdbg+='xdebug.remote_log = /var/log/xdebug.log\n'
xdbg+='xdebug.remote_mode = req\n'
xdbg+='xdebug.remote_port = 9000\n'
xdbg+='xdebug.remote_connect_back=1\n'
echo -e $xdbg >> /etc/php/7.$PHP_V/mods-available/xdebug.ini
phpenmod xdebug
}
__setup_mysql(){
echo "Installing MySQL...";
apt install -y mysql-server mysql-client
__done;
}
__setup_java(){
echo "Installing Java...";
add-apt-repository ppa:webupd8team/java
apt update
apt install -y oracle-java8-installer
__done;
}
__setup_utils(){
echo "Installing utils...";
apt install -y curl terminator git-core git-gui mc build-essential libssl-dev krusader shutter libgoo-canvas-perl vim vim-common vim-scripts vim-youcompleteme
__done;
}
__setup_apache(){
echo "Installing Apache...";
apt install -y apache2 libapache2-mod-php7.$PHP_V
touch /etc/apache2/sites-available/vhosts.conf
a2enmod rewrite
a2ensite vhosts.conf
service apache2 restart
__done;
}
__setup_nginx(){
echo "Installing Nginx...";
apt install -y nginx
__done;
}
__setup_sublime(){
echo "Installing Sublime Text...";
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
__done;
}
__help(){
TEXT="\e[36m\n\e[1m\tHow to use:\e[21m\n\n";
TEXT+="========================================================================================\n\n";
TEXT+="\e[92m\tsudo ${0} [options]\n\n";
TEXT+="\e[36m----------------------------------------------------------------------------------------\n\n";
TEXT+="\tOptions:\n";
TEXT+="\t\e[92m-a\t\e[36mInstall apache2\n";
TEXT+="\t\e[92m-m\t\e[36mInstall MySQL\n";
TEXT+="\t\e[92m-p\t\e[36mInstall PHP7\n";
TEXT+="\t\e[92m-n\t\e[36mInstall Nginx\n";
TEXT+="\t\e[92m-j\t\e[36mInstall Java\n";
TEXT+="\t\e[92m-u\t\e[36mInstall utils\n\n";
TEXT+="========================================================================================\n";
echo -e $TEXT;
}
while getopts "hampnjus" OPTION
do
case ${OPTION} in
a) APACHE=Y
;;
m) MYSQL=Y
;;
p) PHP=Y
;;
n) NGINX=Y
;;
j) JAVA=Y
;;
u) UTILS=Y
;;
s) SUBLIME=Y
;;
h) EXIT=Y
;;
*) EXIT=Y
;;
esac
done
if [ "${EXIT}" == "Y" ]; then
__help;
exit;
fi
# Updating packages cache
apt update
if [ "${MYSQL}" == "Y" ]; then
__setup_mysql;
fi
if [ "${PHP}" == "Y" ]; then
__setup_php;
fi
if [ "${APACHE}" == "Y" ]; then
__setup_apache;
fi
if [ "${NGINX}" == "Y" ]; then
__setup_nginx;
fi
if [ "${JAVA}" == "Y" ]; then
__setup_java;
fi
if [ "${UTILS}" == "Y" ]; then
__setup_utils;
fi
if [ "${SUBLIME}" == "Y" ]; then
__setup_sublime;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment