Skip to content

Instantly share code, notes, and snippets.

@cse031sust02
Created March 12, 2018 04:27
Show Gist options
  • Save cse031sust02/ff43eae6a66f1e5685129a54223ffa59 to your computer and use it in GitHub Desktop.
Save cse031sust02/ff43eae6a66f1e5685129a54223ffa59 to your computer and use it in GitHub Desktop.
Bash Script to install LEMP stack on Ubuntu 16.04
#!/bin/sh
#############################################################
# Bash script to install LEMP Stack (+ some other tools)
# Target Machine : Ubuntu 16.04 @ AWS EC2
# Written by Talha Ibne Imam (@cse031sust02)
#############################################################
HC='\033[0;32m' # Heading Color
WC='\033[0;33m' # Warning Color
NC='\033[0m' # No Color
# update the sources
echo -e "${HC}:::::::::::::Updating The Package Database:::::::::::::${NC}"
sudo apt-get update
sudo apt-get upgrade
echo -e "${HC}:::::::::::::Installing Some Common Packages:::::::::::::${NC}"
sudo apt-get install zip build-essential
echo -e "${HC}:::::::::::::Installing nginx:::::::::::::${NC}"
sudo apt-get install nginx
echo -e "${HC}:::::::::::::Changing User Group Of 'var/wwww' Directory:::::::::::::${NC}"
sudo chown -R ubuntu:ubuntu /var/www
#sudo chmod -R 0755 /var/www
echo -e "${HC}:::::::::::::Installing MySQL:::::::::::::${NC}"
sudo apt-get install mysql-server
mysql_secure_installation
echo -e "${HC}:::::::::::::Installing PHP With Necessary Extensions:::::::::::::${NC}"
sudo apt-get install php7.0 php7.0-mbstring php7.0-xml php7.0-mysql -y
echo -e "${HC}:::::::::::::Installing PhpMyadmin:::::::::::::${NC}"
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html
echo -e "${HC}::::::::::::::::::::::::::Configuring Nginx::::::::::::::::::::::::::${NC}"
sudo touch /etc/nginx/sites-available/phpmyadmin
sudo chown -R ubuntu:ubuntu /etc/nginx/sites-available/phpmyadmin
sudo cat > /etc/nginx/sites-available/phpmyadmin <<\EOF
server {
listen 70;
root /var/www/html/phpmyadmin;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
sudo service nginx restart
echo "${HC}:::::::::::::Installing Composer:::::::::::::${NC}"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
php -r "unlink('composer-setup.php');"
echo "${HC}:::::::::::::Installing NodeJS:::::::::::::${NC}"
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
echo "${HC}:::::::::::::Installing Redis:::::::::::::${NC}"
sudo apt-get install redis-server
echo "${HC}:::::::::::::Installing Redis Commander:::::::::::::${NC}"
sudo npm install -g redis-commander
echo "${HC}:::::::::::::Installing Supervisor:::::::::::::${NC}"
sudo apt-get install supervisor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment