Koozali.org: home of the SME Server

How do I set MariaDB 10.5 as default for PHP for one ibay?

Offline wdepot

  • **
  • 54
  • +0/-0
    • http://westerndepot.com
I am trying to test the beta of osCommerce 4 and ran into a problem because its database uses DEFAULT CURRENT_TIMESTAMP on DATETIME fields which MariaDB didn't support until version 10. I have the beta in an ibay named osc4 and have installed the MariaDB 10.5 contribution. The problem is osCommerce 4 doesn't have a setting for the mySQL port and socket but just uses the PHP defaults and I'm not sure how to set up MariaDB 10.5 as the default version of mySQL used by any version of PHP I might choose to run on the osc4 ibay. I suspect that I will need to set up a custom template for php-fpm.d but I'm not quite sure how I would need to word it.

After looking at the MariaDB 10 contributions and noticing that the end of life for version 10.1 was in 2020 before SME10 was released, I must admit that I'm wondering why SME10 comes with MariaDB 5.5.8 rather than some version of MariaDB 10 in the first place.

Offline Jean-Philippe Pialasse

  • *
  • 2,161
  • +8/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How do I set MariaDB 10.5 as default for PHP for one ibay?
« Reply #1 on: May 11, 2022, 10:01:57 PM »
there is no such default database by ibay.

please refer to your software authors to provide you with documentation on how to properly setup the access to your wanted db.


considering versions provided by Red Hat please read https://access.redhat.com/security/updates/backporting

Offline wdepot

  • **
  • 54
  • +0/-0
    • http://westerndepot.com
Re: How do I set MariaDB 10.5 as default for PHP for one ibay?
« Reply #2 on: May 12, 2022, 02:18:50 AM »
there is no such default database by ibay.

Too bad. Where is mysqli.default_socket set for PHP then? All of the php.ini files I've found on the server have it blank but I would assume it has to be set somewhere in order for PHP to access a database. I take it not all php.ini settings for php_fpm are possible to designate to a specific ibay even if you create a custom template. I guess I'll have to modify the osCommerce 4 mysqli_connect statements to include the socket for MariaDB 10.5.

Offline Jean-Philippe Pialasse

  • *
  • 2,161
  • +8/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How do I set MariaDB 10.5 as default for PHP for one ibay?
« Reply #3 on: May 12, 2022, 04:14:16 AM »
edit the socket as per your need for whole server availability

https://www.php.net/manual/en/mysqli.configuration.php


Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/php.ini/
cp -a  /etc/e-smith/templates/etc/php.ini/80ModuleSettings08MySQLi /etc/e-smith/templates-custom/etc/php.ini/80ModuleSettings08MySQLi
vim /etc/e-smith/templates-custom/etc/php.ini/80ModuleSettings08MySQLi

signal-event webapps-update

note that this could be set also directly in your php scripts using init_set() as this is a PHP_INI_ALL directive (https://www.php.net/manual/en/configuration.changes.php), or using a php pre script which can be set per ibay :

/etc/e-smith/templates/etc/php-fpm.d/ibays.conf/10Ibays
my $autoprepend         = $ibay->prop('AutoPrependFile') 

Only limit the script must be in the open_basedir

Offline wdepot

  • **
  • 54
  • +0/-0
    • http://westerndepot.com
Re: How do I set MariaDB 10.5 as default for PHP for one ibay?
« Reply #4 on: May 12, 2022, 11:58:17 PM »
I found the solution that works easily for me which I will post here in case someone else needs to do something similar.

step 1 On the server perform the following command:
db accounts setprop IBAYNAME MDB10 enabled

where you replace IBAYNAME with the actual name of the ibay you want to use MariaDB 10.

step 2
Copy the file 10Ibays from /etc/e-smith/templates/etc/php-fpm.d/ibays.conf to /etc/e-smith/templates-custom/etc/pfp-fpm.d/ibays.conf

step 3 Modify the copy of 10Ibays you just made in templates-custom by adding three lines as follows:

BEFORE the $OUT command add these two lines:
  my $mdbv     = $ibay->prop('MDB10') || 'off';
  $mdbv    = ($mdbv =~ m/^1|yes|on|enabled$/) ? 'php_admin_value[mysqli.default_socket] = /var/lib/mysql/mariadb105.sock' : '';

then AFTER the $OUT command and before the line reading _EOF add this line:
$mdbv

Make sure this last $mdbv is on a line all by itself with nothing before or after it on that line.

step 4 On the server run the following command
expand-template /etc/php-fpm.d/ibays.conf; signal-event webapps-update

Now any ibay for which have set a property named MDB10 to yes, on or enabled will use MariaDB 10.5 and any which don't have the property set or have it set to some other word will use the version of MariaDB provided by SME Server.

Offline Jean-Philippe Pialasse

  • *
  • 2,161
  • +8/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How do I set MariaDB 10.5 as default for PHP for one ibay?
« Reply #5 on: May 14, 2022, 03:02:31 PM »
I would very STRONGLY discourage this avenue. 

the reason is you are hiding all future updates on this critical fragment of template. 
This fragment host a lot of security sensitives options that might need adjusting depending on future CVS or bug reports.
This is not a simple fragment for a single option but a fragment with ALL the options for ALL your ibays.

Please use a different path, again explore the prepend script that will be able to do it by using a simple php script in your ibay root without putting you at risk
« Last Edit: May 14, 2022, 03:04:29 PM by Jean-Philippe Pialasse »