Solved Memory_limit setting missing in Evo skin and where to change limit displayed in accountmanger php settings?

Richard G

Verified User
Joined
Jul 6, 2008
Messages
14,146
Location
Maastricht
Due to a discussion elsewhere on this forum I went and have a further look to possibility's of the php memory_limit setting.

Now in Enhanced skin I found this in the php settings:
1674344374203.png

As you can see, the user can choose between 64M and 1024M which is odd, because the global memory_limit in php.ini is 256.
So where can I remove the options above 512M so they can't choose them anymore?

Edit: I found this in /usr/local/directadmin/data/templates/php_settings.json but how to change only this value so it won't be overwritten on a next update?

When looking in Evo Skin at the php settings page for the exact same user I see this:
1674344509441.png

I don't know for sure if I asked this before, but here the user can't even choose to add the memory_limit setting.
Not even my own reseller account can add this option on user level.

In Enhanced I've got a whole list of settings which can be changed, in Evo I only have these 6 and not even memory_limit, how come?
I don't have a never_command= setting present in directadmin.conf files.
 
Last edited:
I cant remember if it was there natively, or if I added it, but it must be (for evo skin) in /usr/local/directadmin/data/templates/php_settings.json
 
or if I added it, but it must be (for evo skin) in /usr/local/directadmin/data/templates/php_settings.json
Yes I found that too, but will it be overwritten on an update or not?

Pity the current settings are not displayed.

I found this:
but then the complete file will be custom, not only the values I want customized.

The first link is per domain and it says you can disable it too by using:
set never_commands CMD_PHP_SETTINGS
Then no user can access the php settings part. However, which defaults are used in that case? The ones from the global php.ini and can the user change the values in that case via .htaccess or user.ini files?
Because that's what we were wondering about.

@Hostmavi OMG... LoL I must have been blind. Thank you!
 
Last edited:
Yes I found that too, but will it be overwritten on an update or not?
Ah, yes, you should better use the path with a custom folder: /usr/local/directadmin/data/templates/custom/php_settings.json
You have to create php_settings.json in this custom folder. Settings here will overwrite those in the other php_settings.json, but will not be overwritten.
Concerning php: so far I see this on our box, the level for the global phplimit settings ("master values") is in the (different) php.ini`s. Then, you can overwrite this for single domains in their vhost file. Both limits should be visible as "master values" within phpinfo() output.
Inside this master values, you (your customer) can define their limits in .htaccess or custom ini`s. Those should then be visible as "local values". And they should not overwrite the master values.
You should be able to check values with something like <?php var_dump(ini_get("memory_limit"));> (replace/add other values for "memory_limit" as you need)
 
Concerning php: so far I see this on our box, the level for the global phplimit settings ("master values") is in the (different) php.ini`s.
Yes that is what I was amazed about, since that was set to 256M while we weren't able to change this higher via .htacces files, it was no issue raising that value via the php settings in the account manager without any problem.
The setting I have for my hobby domain is at 512M (while global php limit is 256) and the php info does not give 2 masters but local and master and both at 512M. While in fact the master value should be at 256M so that is what I find odd.

But .htaccess files did not have any effect on the memory limit setting when I tested this evening.
 
Hi Richard;

i asked your phpX_mode in your options.conf # PHP Settings part . do you using mod_php or php-fpm buid your php
this part

# PHP Settings
php1_release=8.2
php1_mode=php-fpm
php2_release=7.4
php2_mode=php-fpm
php3_release=8.1
php3_mode=php-fpm
php4_release=7.3
php4_mode=php-fpm
 
Hello Hostmavi.

Ah then I misunderstood you. I'm not using either mod_php or mod_ruid2, only php-fpm.
# PHP Settings
php1_release=8.0
php1_mode=php-fpm
php2_release=8.1
php2_mode=php-fpm
php3_release=7.4
php3_mode=php-fpm
php4_release=no
php4_mode=php-fpm
secure_php=no
php_ini=no
php_timezone=Europe/Amsterdam
php_ini_type=production
x_mail_header=yes

During install I have set secure_php and php_ini to yes, after installation I change those to no, since I make some small adjustments and don't want them overwritten.
 
Thanyou, out put
test this. it should work limit memory per user by php-fpm.

set your global php limit 256M

Login as admin ---> Custom HTTPD Configurations click on php-fpm.conf(verion) of the domainname
click php-fpm Global |CUSTOM2| add this line
php_admin_value[memory_limit] = 512M

and save it.

check on then domain phpinfo you will see 512 MB Ram.

now go to this domain directadmin panel --->> php setting change memory_limit
more then 512M (1024M) save it.

check again on this domain phpinfo. domain still has 512 MB

" this user can not change the php memory_limit more than in your php-fpm Global |CUSTOM2
php_admin_value[memory_limit] = you add"

if user changed php version also other php version it will work same php memory_limit "512MB"

Best Regards.
 
Hello.

Ah thank you, but that was not what I was wondering about. Normally one can change that setting via .htaccess files and it seems now that is not possible anymore. In fact that is a good thing.

Your solution is great on a per domain base.

But I wanted it global, so I used the custom json file and removed everything above 512M and now any user can choose only a limit of max 512.
The default is taken from the global php.ini file in the memory_limit setting, so that is 256, I could lower this to 128 but then maybe lot of wordpress sites get issues. :)
However they still can raise the value above 512 via a user.ini file. I'm looking for a global limit to that, or a restriction for this globally.
 
Ah never mind, found it. The .user.ini can be disabled in the global php.ini file. So that fixes things.
This way users can only use the account setting via DA to choose a different memory limit.
 
for global memory limit you can do this.

your global php.ini 128M
your setting 256M

cd /usr/local/directadmin/data/templates/custom
nano php-fpm.conf.custom2
add this line.
php_admin_value[memory_limit] = 256M
save the file

this will limit php memory limit max 256M

write the setting for all users
cd /usr/local/directadmin/custombuild
./build rewrite_confs


if any user make changing in Da panel -->> php setting --> memory limit more then 256M
or if you enable .user.ini and memory_limit setting in user.ini more then 256M will not work.
users memory_limit will 256M

and if you creat a new user also your memory limit setting in php-fpm.conf.custom2 will set for the new user.
If user switching php version via php version selector, still your memory_limit works other php versions.


but ther is one issue.
example : if you set in php-fpm.conf.custom2 php_admin_value[memory_limit] = 256M
if users in user.ini or DA admin php setting using less memory limit then 256M (your setting)
this will not effeckt still users has 256M php memory.

this setting will not allow users more memory then (your setting) .

Code:
I could lower this to 128 but then maybe lot of wordpress sites get issues

most wordpress + some pluging will work whit 128M
but plugin like woocommerce need more memory

if some user need more memory better using limit memory per user

if you use global setting and even one user need other memory_limit.
you must make memory changing for all user.


Best Regards
 
Thank you very much.

But I think I will leave it as is now. On the other servers I know have 128M in the global php.ini files and disabled .user.ini files. Then custom json files with a max of 512. Now they can all choose between 128M and 512M and not use higher values in .htaccess or .user.ini either.

If I need more memory for a specific user then I will add it specifically for that user.
 
Some client will not happy with this if you disable .htaccess or .user.ini directive value.

Example: wordpress have plugin call "Wordfence", and some function need to be set directive value like this.
Code:
auto_prepend_file = '/path/to/public_html/site-two/wordfence-waf.php'

if just want to limit their memory usage, Resource Limit ( CGroup ) should be better option.
 
and some function need to be set directive value like this.
Ah yes.... I've seen 3 customers with that setting. Pity WP does not use the .htaccess for this.
Because it is possible, one can put the line in .htaccess like this:
php_value auto_prepend_file “/path/to/public_html/site-two/wordfence-waf.php”

CGroup is too much customizing for me.

For the time being I will enable the .user.ini again, but if somebody goes around the memory limit I will disable it again and then advise the customers to put that line in their .htaccess file.
 
Back
Top