0

First a note: Yes, I'm well aware this extension in deprecated and has a ton of security flaws, I'm duplicating a clients active server in docker for recovery and migration (after client's server was compromised).

Clients server is Centos6 based with php 5.6 and uses the original php mysql module (they just call it the original module) https://www.php.net/manual/en/book.mysql.php

I've tried a few of the original mysql repos (remi, webtatic) and they install PDO (the new mysql module).

I'm looking for a way to add the (insecure) original module to my docker container for working locally to recover assets and modernize the project, however it seems most of the repo's are using security best practices to remove the flawed software (or I'm not correctly understanding how to enable it).

I'm willing to build it myself if theres a repo of the original source, or if theres prebuilt somewhere I'm not aware of I'd be grateful.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
Philippe
  • 109
  • 5
  • check PHP's [php-src Github page](https://github.com/php/php-src) for old releases. here's [PHP 5.6.40](https://github.com/php/php-src/releases/tag/php-5.6.40), latest PHP 5.6.x release. please do not use it for production server. – mforsetti Nov 18 '20 at 17:17
  • @mforsetti the MySQL module is not in php core, but is a PECL extension library. The link you gave me is to build core. – Philippe Nov 18 '20 at 18:15
  • `mysql` extension in PECL was [superseeded](https://web.archive.org/web/20081217163523/https://pecl.php.net/package/mysql) by `ext/mysql` in PHP source since 2008 -- PHP 4.x. see [ext/mysql](https://github.com/php/php-src/tree/PHP-5.6.40/ext/mysql). – mforsetti Nov 18 '20 at 18:37
  • @mforsetti oh, thats interesting - if its in the core how do I go about enabling it? the mysql functions are throwing undefined errors in my code. – Philippe Nov 18 '20 at 19:23
  • you can't enable non-compiled and non-installed extensions. install `php5-devel`, `gcc`, and `mysql-devel`, check your php versions by running `php --version`, then download matching PHP source from php-src Github. Extract PHP source files, `cd` to `ext/mysql`, and [build the extension](https://www.php.net/manual/en/install.pecl.phpize.php). – mforsetti Nov 18 '20 at 19:41
  • It took me about 20 seconds to find https://vault.centos.org/6.6/os/x86_64/Packages/ where I learnt that Centos 6 was distributed with PHP 5.3, not 5.6. So you need to install the entire outdated stack. Or you could try a more sensible approach and use PHP 7.x on an up to date distro with https://github.com/dotpointer/mysql-shim/ (indeed, reading further, the mysql extension was dropped in v 5.5 - so you are using some home-brewed frankinstall. – symcbean Nov 19 '20 at 01:22

1 Answers1

2

I've tried a few of the original mysql repos (remi, webtatic) and they install PDO (the new mysql module).

Looks like you have not checked properly.

With a proper configuration, following the Wizard you can install the mysql extension, and most existing extensions:

yum install php-mysql

The package name is php-mysqlnd and provides

You can check using:

$ php --modules | grep -i mysql
mysql
mysqli
mysqlnd
pdo_mysql

Of course I recommend to switch as soon as possible to mysqli to avoid being blocked to 5.6 which have reached its end of life, even if "remi" repository have some security backports.

Remi Collet
  • 2,111
  • 1
  • 12
  • 12
  • "yum install php-mysql" will also work on PHP 7.x and will pull the php-pecl-mysql package provided for legacy application, but this can only be used as a temporary workaround. – Remi Collet Nov 19 '20 at 06:37