Skip to content

Instantly share code, notes, and snippets.

@ajayfroiden
Last active February 4, 2025 09:54
Show Gist options
  • Save ajayfroiden/5ef6c3d8f662bb425fde71d46404de74 to your computer and use it in GitHub Desktop.
Save ajayfroiden/5ef6c3d8f662bb425fde71d46404de74 to your computer and use it in GitHub Desktop.
Install LEMP
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 24.04 dev Server
# Run like (without sudo) - bash install_lamp.sh
# Script should auto terminate on errors
export DEBIAN_FRONTEND=noninteractive
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
echo -e "\e[96m Installing nginx \e[39m"
sudo apt-get -y install nginx
echo -e "\e[96m Installing php - 8.3 \e[39m"
sudo apt-get -y install php8.3-fpm
sudo apt-get -y install curl zip unzip
echo -e "\e[96m Installing supervisor \e[39m"
sudo apt-get -y install supervisor
echo -e "\e[96m Installing php extensions \e[39m"
sudo apt-get -y install php8.3-cli php8.3-curl php8.3-ctype php8.3-uuid \
php8.3-pgsql php8.3-gd \
php8.3-imap php8.3-mysql php8.3-mbstring php8.3-iconv \
php8.3-xml php8.3-zip php8.3-bcmath php8.3-soap php8.3-gettext \
php8.3-intl php8.3-readline \
php8.3-msgpack php8.3-igbinary php8.3-ldap \
php8.3-redis php8.3-grpc
echo -e "\e[96m Restart nginx server to reflect changes \e[39m"
sudo service nginx restart
# 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 --force --filename=composer
# Add this line to your .bash_profile
# export PATH=~/.composer/vendor/bin:$PATH
echo -e "\e[96m Installing mysql client \e[39m"
sudo apt install -y mysql-client
echo -e "\e[96m Installing mysql server \e[39m"
sudo apt install -y mysql-server
# Check php version
php -v
# Check if php is working or not
php -r 'echo "\nYour PHP installation is working fine.\n";'
# Fix composer folder permissions
mkdir -p ~/.composer
sudo chown -R "$USER" "$HOME/.composer"
# Check composer version
composer --version
echo -e "\e[92m Open http://localhost/ to check if nginx is working or not. \e[39m"
# Clean up cache
sudo apt-get clean
@ajayfroiden
Copy link
Author

Symb Link

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/

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