Skip to content

Instantly share code, notes, and snippets.

@ajayfroiden
Last active April 3, 2024 09:25
Show Gist options
  • Save ajayfroiden/9e5fbb54b12b65bef63c457336875d2a to your computer and use it in GitHub Desktop.
Save ajayfroiden/9e5fbb54b12b65bef63c457336875d2a to your computer and use it in GitHub Desktop.
Install LAMP stack on ubuntu
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 18.04 dev Server
# Run like - bash install_lamp.sh
# Script should auto terminate on errors
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/apache2
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
echo -e "\e[96m Installing apache \e[39m"
sudo apt-get -y install apache2
echo -e "\e[96m Installing php \e[39m"
sudo apt-get -y install php7.3 libapache2-mod-php7.3
# Install some php exts
sudo apt-get -y install curl zip unzip php7.3-mysql php7.3-curl php7.3-ctype php7.3-uuid php7.3-iconv php7.3-json php7.3-mbstring php7.3-gd php7.3-intl php7.3-xml php7.3-zip php-gettext php7.3-pgsql php7.3-bcmath php7.3-redis
#sudo apt-get -y install php-xdebug
sudo phpenmod curl
# Enable some apache modules
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2enmod headers
echo -e "\e[96m Restart apache server to reflect changes \e[39m"
sudo service apache2 restart
echo -e "\e[96m Installing mysql server \e[39m"
echo -e "\e[93m User: root, Password: root \e[39m"
# Install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server-5.7 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.7 mysql-server/root_password_again password root" | sudo debconf-set-selections
sudo apt-get -y install mysql-server-5.7
### Run next command on production server
#sudo mysql_secure_installation
# Download and install composer
echo -e "\e[96m Installing composer \e[39m"
# Notice: Still using the good old way
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
# Add this line to your .bash_profile
# export PATH=~/.composer/vendor/bin:$PATH
# Check php version
php -v
# Check apache version
apachectl -v
# Check mysql version
mysql --version
# Check if php is working or not
php -r 'echo "\nYour PHP installation is working fine.\n";'
# Fix composer folder permissions
sudo chown -R $USER $HOME/.config/composer
# Check composer version
composer --version
echo -e "\e[92m Open http://localhost/ to check if apache is working or not. \e[39m"
# Clean up cache
sudo apt-get clean
@ajayfroiden
Copy link
Author

ajayfroiden commented Aug 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment