#!/bin/bash

# Update CentOS
yum update -y

# Install Apache
yum install httpd -y

# Start Apache
systemctl start httpd

# Enable Apache to start on boot
systemctl enable httpd

# Install WGET
yum install wget -y

# Install PHP 8.0 and required modules
yum install epel-release -y
yum install http://rpms.remirepo.net/enterprise/remi-release-$(rpm -E '%{rhel}').rpm -y
yum-config-manager --enable remi-php80
yum install php php-common php-fpm php-gd php-intl php-json php-mbstring php-mysqlnd php-opcache php-pecl-imagick php-pecl-redis php-pecl-zip php-process php-xml -y


# Restart Apache
systemctl restart httpd

# Install MySQL 8.0
cd /tmp/

wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm

yum -y localinstall mysql80-community-release-el7-7.noarch.rpm 

yum-config-manager --enable mysql80-community

yum install -y mysql-community-server mysql-community-libs-compat mysql-community-client

# Start MySQL and enable it to start on boot
systemctl start mysqld
systemctl enable mysqld

# Get temporary MySQL root password
grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}' > /tmp/mysql-root-pw

# Restart Apache
systemctl restart httpd

This Bash script automates the installation of the LAMP (Linux, Apache, MySQL, PHP) stack on CentOS 7. It does the following:

#Updates CentOS to the latest version using yum update.

#Installs Apache using yum install httpd.

#Starts Apache and enables it to start automatically at boot using systemctl start httpd and systemctl enable httpd.

#Installs wget using yum install wget.

#Installs PHP 8.0 and required modules using the Remi repository and the yum install command with a list of packages.

#Restarts Apache to make sure it is using the updated PHP version using systemctl restart httpd.

#Installs MySQL 8.0 using the MySQL repository and yum install command with a list of packages.

#Starts MySQL and enables it to start automatically at boot using systemctl start mysqld and systemctl enable mysqld.

#Gets the temporary MySQL root password from the log file and saves it to /tmp/mysql-root-pw.

#Restarts Apache again to make sure everything is working correctly.

Overall, this script automates the installation of a basic LAMP stack on CentOS 7, which can be useful for setting up a web server or a development environment.