Koozali.org: home of the SME Server

How do I change php.ini settings in SME 10?

Offline wdepot

  • ***
  • 89
  • +0/-0
    • http://westerndepot.com
How do I change php.ini settings in SME 10?
« on: July 30, 2021, 12:56:25 AM »
I need help with changing PHP ini settings on SME10. I'm trying to get get our web site updated for current versions of PHP and I can't find how to set things so errors will display on our test server. When using SME9.2 on the test server I simply set up a custom template that added the following to the very end of the php.ini file:
Code: [Select]
memory_limit = 348M
max_execution_time = 120
allow_url_fopen = On
session.use_trans_sid = 0
default_charset = "UTF-8"
mbstring.encoding_translation = 1
zlib.output_compression = On
upload_max_filesize = 40M
post_max_size = 200M
max_input_vars = 4000
max_file_uploads = 50
; settings for test server ONLY
error_reporting=-1
display_errors=on
display_startup_errors=on
disable_function=

Unfortunately this isn't working under SME10. I have copied the custom template so that it adds this to /etc/opt/remi/php74/php.ini but that doesn't help. I found in the forums a note about the WebHosting contribution but it only solved part of the problem. I'm at least able to use phpinfo to check settings now but still can't get error messages and I noticed that allow_url_fopen remains off even though I enabled it in WebHosting.

From what I've been able to find I'm guessing that I need to set up a custom template for one of the conf files found in /etc/opt/remi/php74/php-fpm.d but I'm not sure which one or exactly the wording I need to use though I can guess at wording after looking at the www.conf file. Any help that can be provided would be appreciated.

Offline Jean-Philippe Pialasse

  • *
  • 2,762
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How do I change php.ini settings in SME 10?
« Reply #1 on: July 30, 2021, 04:30:42 AM »
we do not use php module anymore, we use php-fpm.

Default php-fpm is php74 for SME10. If you need to alter any php setting you need to alter the setting for the php-fpm pool for this ibay.

that says there are 3 levels of config overriding previous one

php version php.ini < php version php-fpm.conf  < ibay pool section of php version php.d/ibays.conf

eg:
/etc/opt/remi/php74/php.ini < /etc/opt/remi/php74/php-fpm.conf < /etc/opt/remi/php74/php-fpm.d/ibays.conf

if memory_limit is defined in those 3 files, then the value used is in /etc/opt/remi/php74/php-fpm.d/ibays.conf in the section [php74-primary] for the ibay Primary


All of those files are templates using metadata templates. in other words the same template is used for all the version of php, and the content of /etc/e-smith/templates.metadata does the magic to expand it at the right place

there are current limits : you can not add templates-customs for an ibay php-pool section, this could be done after some extra development.



most of needed setting are available using the contrib smeserver-webhosting per ibay.


for very specifics  you might need to open a bug

those ones are not available per ibay and you will need to bug that against core smeserver-php package if needed per ibay:

those are already as you want

Code: [Select]
session.use_trans_sid = 0 (but default is already 0)
default_charset = "UTF-8" (but default is already UTF-8)


this one is never defined so can be just added using a template-custom in php.ini
Code: [Select]
mbstring.encoding_translation = 1 (default is 0)

this on can be set per php version
config setprop php74 MaxFileUpload 50
Code: [Select]
max_file_uploads = 50 (default is 20)

this is hardcoded in php ini
Code: [Select]
zlib.output_compression = On (default is 0, and be aware that if apache is already set to compress you will have issues)
error_reporting=E_ALL (default is set already at php.ini E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT and is hardcoded /etc/e-smith/templates/etc/php.ini/30ErrorHandling)
display_startup_errors=on ( this is at off in php.ini and is hardcoded /etc/e-smith/templates/etc/php.ini/30ErrorHandling)

this is hardcoded in php ini and php.d/10Ibays
Code: [Select]
display_errors=on ( this is overridden with off in the current fragment per ibay so you need to open a bug)
« Last Edit: July 30, 2021, 04:36:30 AM by Jean-Philippe Pialasse »

Offline wdepot

  • ***
  • 89
  • +0/-0
    • http://westerndepot.com
Re: How do I change php.ini settings in SME 10?
« Reply #2 on: August 05, 2021, 02:16:06 AM »
Thanks for the help. I was actually able to get display_errors turned on by copying the 10Ibays file to templates-custom/etc/php-fpm.d/ibays.conf and changing the hard coded off to an on. Since that turns it on for all ibays that is not ideal so I've raised a bug as you suggested. I dropped the line for compression after seeing your note since we use mod_deflate and realized that most of the other items that aren't taken from php.ini can be set with the appropriate config setprop php74 setting.

Offline Hamish

  • 5
  • +0/-0
Re: How do I change php.ini settings in SME 10?
« Reply #3 on: September 24, 2021, 02:04:25 PM »
Just a note for any one else scratching their heads on /etc/php.ini
The default in SME10 appears to have moved to /etc/opt/remi/php74/php.ini.
As far as I can make out, the template system updates /etc/php.ini, as it used to in SME 9
A php script within a test page to the effect of:
Code: [Select]
$inifile = php_ini_loaded_file();
if (!$inifile) $inifile = 'No ini file loaded';
echo 'ini file: '.$inifile;
saves having to liven up phpinfo();

After editing the file in /etc/opt/remi/php74, I've yet to find a way to re-load the ini file without restarting the server.
The following had no effect:
systemctl restart php-fpm.service
systemctl restart httpd-e-smith.service

Any other suggestions welcome.
All's well that ends.

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: How do I change php.ini settings in SME 10?
« Reply #4 on: September 24, 2021, 03:50:19 PM »
The default in SME10 appears to have moved to /etc/opt/remi/php74/php.ini.

Because PHP 7.3 is about EOL/deprecated.

Quote
As far as I can make out, the template system updates /etc/php.ini, as it used to in SME 9

It isn't that simple as we use PHP pools as explained above.

Please read the wiki:

https://wiki.koozali.org/PHP

Some additional older notes here:

https://wiki.koozali.org/Php-fpm

Lots of forums threads if you search. Read JPs post above carefully and then have read through templates.

Quote
saves having to liven up phpinfo();

You can enable phpinfo per ibay, along with lots of other settings. phpinfo by default is a disabled function because it is insecure, and we try to ensure that SME is secure by default as is is used by a lot of non technical users.

It can be re-enabled via DisabledFunctions - I'd add them all except the one you require.

Code: [Select]
my $disabled_functions  = $pool->prop('DisabledFunctions') || 'system,show_source,' .
                                                                'symlink,exec,dl,shell_exec,' .
                                                                'passthru,phpinfo,' .
                                                                'escapeshellarg,escapeshellcmd';


Quote
After editing the file in /etc/opt/remi/php74,

Please don't do that. It won't work. Please learn to use the system as it was designed. Also, use custom-templates so you don't break your system.

Quote

I've yet to find a way to re-load the ini file without restarting the server.

The following had no effect:
systemctl restart php-fpm.service
systemctl restart httpd-e-smith.service

Any other suggestions welcome.

Usually signal-event smeserver-phpupdate or signal-event webapps-update should do it.

Help yourself by looking in the /etc/e-smith directory structure and see how some of this works. It will make far more sense.

Yes, there are lots of changes from v9. That is because lots of things have changed. Using PHP pools is far more flexible so you can run different PHP versions with different settings for different apps - take a look at Nextcloud as a good example.

Those who helped test as we built it will have learned about it already.......
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,762
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How do I change php.ini settings in SME 10?
« Reply #5 on: September 25, 2021, 05:42:57 PM »
again simply using the webhosting contrib will do it for you instead of trying to battle against the system without reading the manuals before ( php, systemd, php-fpm and SME for a starter. )