Search This Blog

Labels

adobe (1) android (3) apache (3) aviation (1) bash (2) chrome (2) composer (1) cookery (3) dev (2) dodanperks (1) extensions (1) facebook (2) firefox (1) git (2) grafana (1) guzzle (1) headaches (11) htaccess (1) html5 (2) jquery (2) lamp (1) life hacks (10) linux (28) mysqli (2) native (1) opera (2) php (10) railfanning (1) reactjs (3) reactnative (1) servers (11) sinhala (1) smartphones (2) snap (1) sound (1) tech (22) troubleshoots (4) ubuntu (29) unicode (4) virtualbox (1) wamp (2) web (11) windows (4) wordpress (3) youtube (2) කෑම (3)

Saturday, 10 September 2022

Install PHP 7.4 along side PHP 8.1

Assuming you already have PHP 8.1 installed,
sudo apt-get update
sudo apt install php7.4 php7.4-common php7.4-cli
sudo apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-mysql php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-readline php7.4-zip
sudo apt install php7.4-fpm

You can either switch completely to PHP 7.4 by

sudo a2dismod php8.1
sudo a2enmod php7.4sudo a2enmod php7.4
sudo service apache2 restart

Or, switch one particular folder to PHP 7.4 by adding the following to apache2.conf file. (Tried adding these as a separate site in sites-available, didn't work)

<Directory /home/my_user/environment/site2>
    <FilesMatch ".+\.ph(ar|p|tml)$">
        SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
    </FilesMatch>
</Directory>
sudo service apache2 restart

 More info: https://stackoverflow.com/a/65974193/3475839

No comments:

Post a Comment