Jump to content

LAMP:Shell Script Install LAMP

From Wiki

This script will update the system, install Apache, MariaDB, PHP 8.1 and all necessary dependencies. And enable PHP module for Apache and restart both Apache and MariaDB. At the end it will run command php -v to verify the installation.

Please note that PHP 8.1 is currently not available in the default Ubuntu repository, so you will have to add the PPA repository from Ondřej Surý.

Also, you might have to check the version of PHP 8.1 available for your specific version of Ubuntu.

#!/bin/bash

# Update system
sudo apt-get update

# Install Apache
sudo apt-get install apache2 -y

# Install MariaDB
sudo apt-get install mariadb-server mariadb-client -y

# Install PHP 8.1 and dependencies
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php8.1 php8.1-common php8.1-cli php8.1-fpm php8.1-mysql -y

# Enable PHP module for Apache
sudo a2enmod php8.1

# Restart Apache and MariaDB
sudo service apache2 restart
sudo service mariadb restart

# Verify installation
php -v

This script will update the system, install Apache, MariaDB, PHP 7.4 and all necessary dependencies. And enable PHP module for Apache and restart both Apache and MariaDB. At the end it will run command php -v to verify the installation.

Please note that this script is for Ubuntu specifically. If you use other distribution of Linux, it may require some modification.

#!/bin/bash

# Update system
sudo apt-get update

# Install Apache
sudo apt-get install apache2 -y

# Install MariaDB
sudo apt-get install mariadb-server mariadb-client -y

# Install PHP 7.4 and dependencies
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql -y

# Enable PHP module for Apache
sudo a2enmod php7.4

# Restart Apache and MariaDB
sudo service apache2 restart
sudo service mariadb restart

# Verify installation
php -v