1

I installed PHP 5.6 with:

apt install php5.6

Then I added a -s link in /etc/apache2/mods-enabled for php5.6.conf and php5.6.load

When I restarted apache2 I got this error that wasn't there before:

Syntax error on line 146 of /etc/apache2/apache2.conf

Line 146 looks like this:

IncludeOptional mods-enabled/*.load

so I looked at php5.6.load and it says:

# Conflicts: php5
# Depends: mpm_prefork
LoadModule php5_module /usr/lib/apache2/modules/libphp5.6.so

Finally I tried to look at /usr/lib/apache2/modules/libphp5.6.so but it wasn't there.

hostnamectl spits this out:

         Icon name: computer-vm
           Chassis: vm
    Virtualization: vmware
  Operating System: Ubuntu 18.04.6 LTS
            Kernel: Linux 4.15.0-213-generic
      Architecture: x86-64

This is a server that was provisioned to me by my hosting provider who said that they tried multiple times and could not install PHP 5.6 as an Apache module. But I suspect it's possible and that they are just lazy. It's already installed as commandline

php -v outputs:

PHP 5.6.1 (cli) (built: Oct 3 2023 04:21:44) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

apache2 -v outputs

Server version: Apache/2.4.29 (Ubuntu) Server built:
2023-03-08T17:34:33

Any ideas how to fix this? I need PHP 5.x because I'm running an old PHP site that was coded in 2006. I believe it was last working on PHP 5.2 or PHP 5.3. I have never tried to run it on PHP 5.6 but I suspect it would still work as long as it isn't PHP 7+. PHP 5.4-5.5 are also not an option because of problems with those versions.

2
  • Isn’t the Apache php module a separate package ? Something like libapache2-mod-php
    – HBruijn
    Oct 5 at 18:27
  • 1
    @HBruijn It is. And Ubuntu 18.04 is end of life.
    – vidarlo
    Oct 5 at 18:35

1 Answer 1

0

It is recommended to use a2enmod to enable an Apache module. In your case:

sudo a2enmod php5.6
sudo service apache2 restart

You didn't mention if you have other PHP versions installed on your machine. If you do, you have to disable them with a2dismod. For example if you also have php7.0 do this:

sudo a2dismod php7.0
sudo service apache2 restart

The command php -v returns the PHP CLI version. You have to use phpinfo() to see what the Apache is using.

Recommendation: As the others said, Ubuntu 18.04 is end of life, so please upgrade to a supported version. You can install php5.6 on new Ubuntu versions from the ppa:ondrej/php repository.

1
  • 1
    Thanks. Kamatera said they had a LAMP image with Ubuntu 18 / PHP 5.6. That's why I went with such an old version of Ubuntu. They dropped the ball though when they provisioned my friend's server with PHP 7.2 instead of PHP 5.6 and that's when I came here to find answers. Ultimately I decided not to go with them because I found a much easier solution using cPanel which originally I had been trying to avoid to save my friend some dough since her web site doesn't make any money but it ended up being the right answer for other reasons. But thanks again. Man PHP sucks for backwards compatibility.
    – PHP Guru
    Oct 30 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .