Skip to content

Instantly share code, notes, and snippets.

@Lerie82
Forked from aamnah/lamp.sh
Last active February 10, 2021 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lerie82/f0951a99ec574a3485d2ea50064ffa56 to your computer and use it in GitHub Desktop.
Save Lerie82/f0951a99ec574a3485d2ea50064ffa56 to your computer and use it in GitHub Desktop.
Bash script to install Apache, MySQL, PHP and PHPMyAdmin
#!/bin/bash
#######################################
# Bash script to install an AMP stack and PHPMyAdmin plus tweaks. For Debian based systems.
# Originally written by @AamnahAkram from http://aamnah.com
# 2019-2021: Updates and maintenance by Lerie Taylor https://www.lerietaylor.com/
# uninstall: https://gist.github.com/Lerie82/de06e0f5f03305c6d991c30599b7567e
#######################################
#COLORS
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
# Start fresh
clear
# Update packages and Upgrade system
echo -e "$Cyan \n Updating System.. $Color_Off"
sudo apt-get update -y && sudo apt-get upgrade -y
## Install AMP
echo -e "$Cyan \n Installing Apache2 $Color_Off"
sudo apt-get install apache2 apache2-doc apache2-utils libexpat1 ssl-cert -y
echo -e "$Cyan \n Installing PHP & Requirements $Color_Off"
sudo apt-get install libapache2-mod-php php php-common php-curl php-dev php-gd php-pear php-imagick php-mcrypt php-mysql -y
echo -e "$Cyan \n Installing MySQL $Color_Off"
sudo apt-get install mysql-server mysql-client -y
echo -e "$Cyan \n Installing phpMyAdmin $Color_Off"
sudo apt-get install phpmyadmin -y
echo -e "$Cyan \n Verifying installs$Color_Off"
sudo apt-get install apache2 libapache2-mod-php php mysql-server php-pear php-mysql mysql-client mysql-server php-mysql php-gd -y
## TWEAKS and Settings
# Permissions
echo -e "$Cyan \n Permissions for /var/www $Color_Off"
sudo chown -R www-data:www-data /var/www
echo -e "$Green \n Permissions have been set $Color_Off"
# Enabling Mod Rewrite, required for WordPress permalinks and .htaccess files
echo -e "$Cyan \n Enabling Modules $Color_Off"
sudo a2enmod rewrite
sudo phpenmod mcrypt
# fix: FQDN (AH00558)
sed -i '1i ServerName localhost' /etc/apache2/apache2.conf
# Restart Apache
echo -e "$Cyan \n Restarting Apache $Color_Off"
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment