Drenyl
Drenyl

Reputation: 934

Change my PHP version on my Ubuntu server

Currently using PHP version is 5.6.36 and I need to go down on version 5.3.29.

Running phpinfo()on my script giving me this

enter image description here

While on my cli

enter image description here

For what I understand, I'm still using the version 5.6.36.

Anyway to point the version to different installed php?

Upvotes: 2

Views: 3995

Answers (2)

Momen
Momen

Reputation: 45

Change your PHP version through the CLI on Ubuntu 22.04

Installed versions list

To list all the installed PHP versions on your local device, use the following command on your terminal :

sudo update-alternatives --config php

You may input the expected version number from the list there.

Change active PHP version

Or else, you can use the following command directly:

sudo update-alternatives --set php /usr/bin/php${version}

Upvotes: -1

srimaln91
srimaln91

Reputation: 1316

Your CLI is referenced to PHP-CLI binaries. But Apache uses its internal module (libapache2-mod-php) to process PHP scripts. You have to downgrade the version of libapache2-mod-php.

Try with below commands

# Install the old version of libapache-php
sudo apt-get install libapache2-mod-php5

# Disable PHP 5.6 module
sudo a2dismod php5.6

# Enable php 5.3 module
sudo a2enmod php5

# Restart Apache
sudo service apache2 restart

Upvotes: 5

Related Questions