how i can disable php 8 and enable php7.4 in arch linux

Viewed 8992

when I run the command php -v I have version 8.0 I would like to change the version to 7.4 despite I have installed php7.4 but I don't know how to switch between the two versions

thank you

2 Answers

Let's assume that the location of php7.4 is /usr/bin/php7.4, in which case

/usr/bin/php7.4 -v

will yield something like this:

enter image description here

hence, you can use this method for whatever command that you would like to execute:

/usr/bin/php7.4 <yourcommand>

You can disable PHP 8 via

sudo a2dismod php8.0

if it bothers you. You can do so temporarily as well.

As your question is about the Arch Linux and it doesn't have the a2enmod & a2dismod. I am gonna providing working answer in the arch:

I assume you have installed php7 & php8 and just want to make apache to use the version 7.

first uninstall apache-php module and install the right one.

sudo pacman -R php-apache  
sudo pacman -S php7-apache

then in the /etc/httpd/conf/httpd.conf change the module name:

from :

LoadModule php_module modules/libphp.so
Include conf/extra/php_module.conf
AddHandler php-script php

to:

LoadModule php7_module modules/libphp7.so
Include conf/extra/php7_module.conf
AddHandler php7-script php

after that you can reload the server:

sudo systemctl reload httpd
Related