MULTIVERSIONS ON UBUNTU BOX sudo apt install apache2 libapache2-mod-fastcgi sudo apt-get install mysql-server sudo mysql_secure_installation sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update Use this command to install different versions of php just changing the string 7.1 to the required version sudo apt install php7.1 php7.1-fpm libapache2-mod-php7.1 NOW ALL SET LAMP is installed and working Now while u will require to change the php version This command will change the php version on system sudo update-alternatives --config php Disable all version apached modules of php installed, just replace the 7.4 in below command sudo a2dismod php7.4 Enable the version u need to use with apache, just replace the 8.0 in below command sudo a2enmod php8.0 Restart the apache sudo service apache2 restart