• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Enabling php_mysql module

Sanderv

New Pleskian
A good day,

A month ago we upgraded our web server. We made the choice to use the latest Ubuntu 18.04.1, also the server came with Plesk onyx 17.8.11.

We host a few Joomla sites but also a few custom build sites.

The migrations from the old server to the new one wend like a dream, compliments for the build-in “moving manager”.

The sites work and run without any problems except the custom build site. Is build around PHP5 and needs the mysql extensions. Who is removed in PHP7. Because the site developer doesn’t have the time to re write de site right now I wanted to install alternative php version 5.6.38.

I first tried this through “update and upgrades”. But I couldn’t select a php5.x. only php7 versions.

So I tried to install php manual with the help of this guide. After a lot of hassle I managed to get php5.6.38 working for the most part.

Now I get the error “Call to undefined function mysql_connect()”. After a bit of googeling I discover that this problem could happen when mysql isn’t enabled. I confirmed this with the help of a “phpinfo();” web page.

How do I install/enable the php_mysql extensions through terminal?

Thanks for your help everyone!!
Greetings,
Sander
 
Last edited:
I hope that your PHP5.6 is installed to /opt/plesk/php/5.6/ directory, right? In this case, all pre-compiled modules should be located in /opt/plesk/php/5.6/lib64/php/modules/ directory, For example, mysql module /opt/plesk/php/5.6/lib64/php/modules/mysql.so
If it is ok, make sure that you have defined this module in /opt/plesk/php/5.6/etc/php.d/mysql.ini:

# cat /opt/plesk/php/5.6/etc/php.d/mysql.ini
; Enable mysql extension module
extension=mysql.so

Then just run

# plesk bin php_handler --reread

and check, that module is loaded:

# /opt/plesk/php/5.6/bin/php -m | grep mysql
mysql
 
A good day,
......
The sites work and run without any problems except the custom build site. Is build around PHP5 and needs the mysql extensions. Who is removed in PHP7. Because the site developer doesn’t have the time to re write de site right now I wanted to install alternative php version 5.6.38.
.........
Greetings,
Sander

@Sanderv

I would really like to recommend that you adjust the custom site to support PHP 7 versions, since PHP 5.6.x is in the EOL (End Of Life) stage.

Moreover, PHP 5.6.x is a general security risk .... for the entire server.

If the website designer/coder does not want or does not have the time to upgrade the site, you can probably do it yourself with some dirty work-around.

Just follow these steps:

1 - clone the site to a domain or subdomain that is only accessible to you
2 - change the PHP version to version 7.1.x via Plesk Panel
3 - open the site in a browser and just walk through the sites, in order to "activate" the rendering of all PHP scripts
4 - have a look at the PHP logs and find the error and warning messages: a lot of "deprecated" messages will show
5 - try to adjust the code in such a fashion that the error/warning messages are not showing anymore

and, when doing the above, you will have a custom site that has been upgraded to support PHP 7.x.x versions to some extent.

Again, note that it is a dirty work-around, this should never be a long-term solution....... but it is a temporary fix for the problem that you have with PHP 5.6.x related security!

Hope the above helps a bit.

Regards...........
 
I hope that your PHP5.6 is installed to /opt/plesk/php/5.6/ directory, right? In this case, all pre-compiled modules should be located in /opt/plesk/php/5.6/lib64/php/modules/ directory, For example, mysql module /opt/plesk/php/5.6/lib64/php/modules/mysql.so
If it is ok, make sure that you have defined this module in /opt/plesk/php/5.6/etc/php.d/mysql.ini:

# cat /opt/plesk/php/5.6/etc/php.d/mysql.ini
; Enable mysql extension module
extension=mysql.so

Then just run

# plesk bin php_handler --reread

and check, that module is loaded:

# /opt/plesk/php/5.6/bin/php -m | grep mysql
mysql

No, php isn’t installed on that location. If I’m not mistaken it’s installed in “usr/local/php5538/” just like the tutorial said. The extension_dir is located in ">/root/local/lib/php/extensions/no-debug-non-zts-20131226”. I don’t now if that’s the same?
 
Last edited:
@Sanderv

I would really like to recommend that you adjust the custom site to support PHP 7 versions, since PHP 5.6.x is in the EOL (End Of Life) stage.

Moreover, PHP 5.6.x is a general security risk .... for the entire server.

If the website designer/coder does not want or does not have the time to upgrade the site, you can probably do it yourself with some dirty work-around.

Just follow these steps:

1 - clone the site to a domain or subdomain that is only accessible to you
2 - change the PHP version to version 7.1.x via Plesk Panel
3 - open the site in a browser and just walk through the sites, in order to "activate" the rendering of all PHP scripts
4 - have a look at the PHP logs and find the error and warning messages: a lot of "deprecated" messages will show
5 - try to adjust the code in such a fashion that the error/warning messages are not showing anymore

and, when doing the above, you will have a custom site that has been upgraded to support PHP 7.x.x versions to some extent.

Again, note that it is a dirty work-around, this should never be a long-term solution....... but it is a temporary fix for the problem that you have with PHP 5.6.x related security!

Hope the above helps a bit.

Regards...........

I know it is a big securtity risk. And I already tried to do this. But by fixing a few problems and changing some commands the a few other critical parts of the site stopt working. Also I don’t have the time myself to put a lot of time into it. So I stopped these fixing attempts.

Thank you for your warnings and tips.

Greetings Sander
 
No, php isn’t installed on that location. If I’m not mistaken it’s installed in “usr/local/php5538/” just like the tutorial said. The extension_dir is located in ">/root/local/lib/php/extensions/no-debug-non-zts-20131226”. I don’t now if that’s the same?
If you mean this instruction - How to add a custom PHP version? then modules should be located in /usr/local/php5538/ directory after PHP installation. Not sure, but it should be something like /usr/local/php5538/lib/php/extensions/... and corresponding ini file in /usr/local/php5538/etc/....
Just try to find correct paths.
And @trialotto is right, EOL for PHP5.6 in 26 days - PHP: Supported Versions We strongly do not recommend using it.
 
@Sanderv

When disregarding the fact that you use an even older PHP version than version 5.6.x, the answer to your question is:

1 - no, you are not in the wrong directory: I will return to this later,
2 - yes, other extensions should be installed in other directories.

Now, let me explain a bit.

Your (very very) old PHP version is using the opcache extension (let's take this as an example) and puts it in the no-debug-non-zts-20121212 folder.

That name is rather informative and contains three parts:

a - no-debug: debug versus no debug compilation, in your case it is "no debug" - which is not the best idea, certainly not in the case of a very old PHP version or module,
b - non-zts: indicates that the module is not thread safe - again, a bad indication, since opcache is a memory related module and "not thread safe" often means "security risk"
c - 20121212: this is a datestamp that identifies the internal API version - which again is bad, it is very (very) old

The folder name is also an indication of where modules are being put after compilation.

In summary, you have a very (very) old PHP version (not supported anymore!) with very (very) insecure modules (security breaches can even access memory, so this security risk can also affect your entire server in a very severe way: a good hacker can get full control via this security loophole).

Now, let us return to your original thread starter: you were talking about PHP 5.6.x and associated locations, but we should actually look at PHP version 5.5.x!

In short, it is no surprise that you cannot compile and/or install and/or get the mysql module working in PHP 5.6.x - it simply is another PHP version that you should focus on!

Nevertheless, you should stop hosting this custom site immediately - there is no reason to put a lot of work into getting a mysql module working in a PHP version that is very old and/or that is unsupported, certainly not when this effort to get the module working is increasing the vulnerability of your server(s) to a very high degree.

In conclusion, I am not sure what to say if you decide to continue hosting this ridiculous custom site with a state-of-the-art Ubuntu server and Plesk instance!

I hope that all of the information above helps you decide on what to do next, since there is no way of actually helping you out: after all, helping you finding a method to add the mysql module to the (very) very old version of PHP would be equivalent to helping you to open your server(s) for hacks ......... nobody wants to do that, honestly.

Regards.........
 
When disregarding the fact that you use an even older PHP version than version 5.6.x, the answer to your question is:

Now, let us return to your original thread starter: you were talking about PHP 5.6.x and associated locations, but we should actually look at PHP version 5.5.x!

I am trying to install 5.6.38 but I posted the wrong screenshot. If I can’t figure it out I try different things. So I also did an attempt with 5.5X to have a look if that would work bud that didn’t. like you would expect. I’m sorry for my mistake.

Nevertheless we just have to keep this site in the air until the developer finish rebuilding the site. I now it is a security risk but I also think it is a little bit frustrating that a upgrade from CentOS 7.5 to the newest Ubuntu 18.04 gives us so much trouble. Right on this moment the old server is still hosting this site and we can’t copy it over because of this PHP problem.

I thank you for your help, tips and knowledge.

Greetings Sander
 
Could u please help me to get 5.6.38 running again?

First so we have a month extra to rebuild the site.

But also, I really want to know where I went wrong so I know how these things work and I can use this knowledge to beter understand how these things work and use it in the future newer versions.

I thank you in advance,

greetings,
Sander
 
My phpinfo(); says:


upload_2018-12-5_11-17-52.png

But this folder also looks a bit empty, I’m in the right folder now for 5.6.38.

Do you know how I could install/enable/recompile php5.6.38.

I can select the right php version in plesk but I can’t use the modules that I need

upload_2018-12-5_11-19-9.png
Thank you for you're help.
greetings,
Sander
 
I'd suggest you install PHP according to mentioned above KB article. Looks like your current installation is incorrect.
 
Well, I think I got it.

I removed all of the old installs and compiled files and tried again.


With this commands I installed php5.6:

Code:
# sudo apt-get install python-software-properties

# sudo add-apt-repository ppa:ondrej/php

# sudo apt-get update

# sudo apt-get install -y php5.6

bron: How To Install PHP 5.6 or 7.2 on Ubuntu 18.04 & 16.04 via PPA


I installed php5.6-cgi

Code:
# sudo apt-get install php5.6-cgi

And php5.6-cli

Code:
# sudo apt-get install php5.6-cli


After a lot of searching I managed to find the right files. And with:

Code:
# /usr/local/psa/bin/php_handler --add -displayname "php 5.6" -path /usr/bin/php-cgi5.6 -phpini /etc/php/5.6/apache2/php.ini -type cgi -id 01 -clipath /usr/bin/php5.6
bron: How to add a custom PHP version?
I could add the new php version to Plesk.

After selecting php5.6 in plesk:
upload_2018-12-7_1-23-49.png

Now if I have a look at my phpinfo() page:

upload_2018-12-7_1-24-28.png

It is the right PHP version, with:
upload_2018-12-7_1-2-16.png

mysql enabled.
The site is now working again on the new server.

Now, the next thing: Give our developer a kick to the butt to get him working faster to code the site to PHP7.2.

Thank you all for your help and tips.
And in advance: have a nice Christmas and a happy new year!

Greetings,
Sander
 

Attachments

  • upload_2018-12-7_1-0-45.png
    upload_2018-12-7_1-0-45.png
    18.3 KB · Views: 4
  • upload_2018-12-7_1-19-27.png
    upload_2018-12-7_1-19-27.png
    11.5 KB · Views: 1
Last edited:
Back
Top