sudo apt-get install curl wget gnupg2 ca-certificates lsb-release apt-transport-https -y
wget https://packages.sury.org/php/apt.gpg
sudo apt-key add apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update -y
sudo apt-get install php7.4 php7.4-fpm php7.4-mysql libapache2-mod-php7.4 libapache2-mod-fcgid -y
sudo apt-get install php8.2 php8.2-fpm php8.2-mysql libapache2-mod-php8.2 -y
sudo service php7.4-fpm start
sudo service php7.4-fpm status
sudo service php8.2-fpm start
sudo service php8.2-fpm status
sudo a2enmod actions fcgid alias proxy_fcgi
sudo service apache2 restart
sudo mkdir /var/www/site1
sudo mkdir /var/www/site2
sudo chown -R www-data:www-data /var/www/site1
sudo chown -R www-data:www-data /var/www/site2
sudo chmod -R 755 /var/www/site1
sudo chmod -R 755 /var/www/site2
sudo nano /var/www/site1/info.php
<?php phpinfo(); ?>
sudo cp /var/www/site1/info.php /var/www/site2/info.php
sudo nano /etc/apache2/sites-available/site1.conf
<VirtualHost *:80>
DocumentRoot /var/www/site1
DirectoryIndex info.php
<Directory /var/www/site1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/site1_error.log
CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
sudo nano /etc/apache2/sites-available/site2.conf
<VirtualHost *:80>
DocumentRoot /var/www/site2
DirectoryIndex info.php
<Directory /var/www/site2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/site2_error.log
CustomLog ${APACHE_LOG_DIR}/site2_access.log combined
</VirtualHost>
sudo apachectl configtest
sudo a2ensite site1.conf
sudo a2dissite 000-default.conf
sudo service apache2 restart
sudo a2ensite site2.conf
sudo a2dissite site1.conf
sudo service apache2 restart
# Uninstall #
sudo apt-get autoremove curl wget gnupg2 ca-certificates lsb-release apt-transport-https php7.4 php7.4-fpm php7.4-mysql libapache2-mod-php7.4 libapache2-mod-fcgid php8.2 php8.2-fpm php8.2-mysql libapache2-mod-php8.2 -y
sudo rm -rf /etc/apache2/sites-available/site*
sudo rm -rf /var/www/site*
sudo rm -rf /etc/apt/sources.list.d/php.list
sudo apt-key list
sudo apt-key del "1505 8500 A023 5D97 F5D1 0063 B188 E2B6 95BD 4743"