How do I change the default PHP memory limit and upload size server wide?

Jordz2203

Verified User
Joined
Sep 8, 2022
Messages
74
How do I change the default PHP memory limit and upload size server wide? I need to change both current accounts and accounts in the future
 
For all accounts you can use the php.ini for that.
You can find it in the according php directory like this:
/usr/local/phpXX/lib/php.ini
replace the XX by your php version like php 8.0 would be /php80 and same for 8.1 or 7.4.

Remember to restart the according php-fpm service after making the change.
 
Also an option. Normally php.ini does not get new features fast. At least never seen any in my time, could be wrong.

If I'm not mistaken the default setting in options.conf is php_ini=no which takes care it won't be overwritten.

Anyway, you have 2 choices, but indeed, if you choose my option, check that the php_ini setting in options.conf is indeed set to no.
 
For all accounts you can use the php.ini for that.
You can find it in the according php directory like this:
/usr/local/phpXX/lib/php.ini
replace the XX by your php version like php 8.0 would be /php80 and same for 8.1 or 7.4.

Remember to restart the according php-fpm service after making the change.
Is this the location for lsphp?
 
It's always the same no matter which PHP mode you use.

To make sure you can always run php --ini or /usr/local/phpXX/bin/php --ini to see a correct location.
 
It's always the same no matter which PHP mode you use.

To make sure you can always run php --ini or /usr/local/phpXX/bin/php --ini to see a correct location.
If I go into my user and run a command it says this
Command: /usr/local/bin/php --ini | grep 'Loaded Configuration File'
Reply: Loaded Configuration File: /opt/alt/php74/etc/php.ini


When I go to the above php.ini file in opt/alt.. it says the memory_limit is commented out?
 
When I go to the above php.ini file in opt/alt.. it says the memory_limit is commented out?


OK, I see. The said above is true for native PHP versions compiled by DirectAdmin only.

For the versions installed from CloudLinux repository you should follow another instructions. You should work with /etc/cl.selector/php.conf and /etc/cl.selector/global_php.ini

In my records have I this:

Code:
# cat /etc/cl.selector/global_php.ini | grep -v '^\;'
[Global PHP Settings]
memory_limit = 2048M

(you might need to update users in cagefs)

dated to 2019.

Check instructions from CloudLinux help pages for latest and valid instructions for the case if my records are outdated.
 
Back
Top