#!/bin/bash

#Update Ubuntu
apt-get update -y

#Install Apache
apt-get install apache2 -y

#Start Apache
systemctl start apache2

#Enable Apache to start on boot
systemctl enable apache2

#Install WGET
apt-get install wget -y

#Install PHP 8.0 and required modules
apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php -y
apt-get update -y
apt-get install php8.0 php8.0-common php8.0-fpm php8.0-gd php8.0-intl php8.0-json php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-imagick php8.0-redis php8.0-zip php8.0-xml -y

#Restart Apache
systemctl restart apache2

#Install MySQL 8.0
cd /tmp/

wget https://dev.mysql.com/get/mysql-apt-config_0.8.18-1_all.deb
dpkg -i mysql-apt-config_0.8.18-1_all.deb
apt-get update -y
apt-get install -y mysql-server mysql-client

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

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

#Restart Apache
systemctl restart apache2

This is a Bash script that automates the process of setting up a LAMP (Linux, Apache, MySQL, PHP) stack on an Ubuntu operating system. It updates Ubuntu, installs Apache web server, WGET utility, PHP 8.0 and required modules, and MySQL 8.0. It also starts and enables Apache and MySQL to start on boot, and retrieves a temporary MySQL root password. Finally, it restarts Apache web server. This script is useful for quickly setting up a web server with a LAMP stack for development or production purposes.