0

I'm unfortunately having to install php 5.3.29, Apache and MySQL on Ubuntu 14.04, its proving to be much more difficult that I expected to get them working together.

I've tried folllowing this thread and got php 5.3.29 installed.

$ php -v
PHP 5.3.29 (cli) (built: Jun 16 2020 04:00:04) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

I got Apache installed:

$ apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Apr  3 2019 18:04:25

Also got MySQL installed:

$ mysql --version
mysql  Ver 14.14 Distrib 5.5.62, for debian-linux-gnu (x86_64) using readline 6.3

It looks like these are all installed as expected but when I create a phpinfo() script and look at the page it correctly shows the version of php but has no details for MySQL.

When trying to access a page that uses mysql I get the error Fatal error: Call to undefined function mysql_connect()

It seems like Apache doesn't see MySQL for some reason but it does appear to be loading the module.

This is what I see when restarting apache:

* Restarting web server apache2 [Thu Jun 18 05:31:41.808127 2020] [so:warn] [pid 121446] AH01574: module php5_module is already loaded, skipping AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

What do I need to do to get Apache to 'see' mysql?

user1532669
  • 2,288
  • 4
  • 36
  • 72
  • why would apache need to `see` mysql ? you probably why does my php5.3 when called from apache not `see` mysql ? look at the php.ini which apache uses. Different from the cli php.ini. – YvesLeBorg Jun 18 '20 at 12:41
  • 2
    _“Also got MySQL installed:”_ - just because you got the MySQL database itself installed on your system, does not mean PHP automatically knows how to talk to it - you need to install / enable the PHP extension for that as well. https://www.php.net/manual/en/mysql.setup.php – CBroe Jun 18 '20 at 12:42
  • Show us the output of `phpinfo` – Dharman Jun 18 '20 at 12:45

2 Answers2

1

You have to check if the mysql extension is installed in php.

dpkg -l|grep php

then you should get a list of all php packages. Check if there is something with mysql / mysqli. If not you have to install the mysql / PDO package.

apt-get install php5-mysql

You use an extreme old PHP version which is not maintained anymore. So you should really upgrade and use a newer one. Then you should be able to connect with your php script to the database.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • I tried that, got an error, tried php5-mysql and got this: $ sudo apt-get install php5-mysql Reading package lists... Done Building dependency tree Reading state information... Done php5-mysql is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded. – user1532669 Jun 18 '20 at 13:37
  • Then the package is installed and should be visible in your phpinfo. Normally the extensions are automatically enabled. – René Höhle Jun 18 '20 at 13:39
  • Yeah I know, I've installed LAMP loads of times and not had this problem. This is all down to having to use an old version of php. – user1532669 Jun 18 '20 at 13:48
0

I ended up reinstalling Ubuntu 14.04, apache, mysql and php from scratch, not sure what the problem was but after reinstalling it seems to have resolved the problem. I now have a new problem, so I might need post a new question,

user1532669
  • 2,288
  • 4
  • 36
  • 72