All 3 files does similar function to be honest, still not not sure what are the difference. using all the methods if all of them are available especially if you are using PHP-FPM
here is the result feel free to add your experience for all of us to learn.
I had an issue with rest API, the main reason of that issue was the resources control over PHP for only 2 individual sites, while the global is set and and controlled on Direct admin Panel which was not enough.
I belive we need to give extra resources to cover all the activity on all the site, site by site each one is different set of rules. why not?
not only to WordPress activity.
When deciding whether to modify the PHP memory limit through `wp-config.php`, `.htaccess`, or `.user.ini`, each method has its pros and cons depending on the server environment and the goals of the modification.
1. Using `wp-config.php`:
-Best for WordPress-specific configurations.
– This method directly affects WordPress and is the simplest way to change the memory limit for a single site without impacting the entire server. It allows you to set the limit with:
“`php
define(‘WP_MEMORY_LIMIT’, ‘256M’);
“`
– Good Practice: It is recommended when you’re working only within WordPress and you want a solution that is straightforward and limited to WordPress without touching the broader server settings.
– Drawback: It only works within WordPress and won’t apply to other PHP processes outside of WordPress. Also, if WordPress crashes due to memory issues, accessing the `wp-config.php` might not be possible until the error is resolved.
2. Using `.htaccess`:
– Best for Apache environments.
– Adding `php_value memory_limit 256M` in `.htaccess` applies PHP configurations globally to the entire website, not just WordPress.
– Good Practice: If you want broader control beyond WordPress (e.g., if your website has other PHP applications or scripts), using `.htaccess` is ideal. This method provides flexibility but requires Apache to be configured to allow overrides.
– Drawback: This won’t work in environments that don’t use Apache or where PHP runs in CGI/FastCGI mode. It also affects all PHP scripts in the directory and its subdirectories.
3. Using `.user.ini`:
– Best for FastCGI or PHP-FPM environments.
– Adding the memory limit to `.user.ini` affects PHP settings when PHP runs in FastCGI or PHP-FPM mode.
– Good Practice: Use `.user.ini` in modern setups like FastCGI or PHP-FPM where `.htaccess` may not apply. It’s a great option for controlling PHP settings at the site or directory level without needing root access or server-wide changes.
– Drawback: Changes in `.user.ini` can take a few minutes to apply (typically up to 5 minutes). Also, like `.htaccess`, this file will apply changes to the whole website, not just WordPress.
Conclusion:
– For WordPress-specific changes, modifying `wp-config.php` is generally the easiest and cleanest method.
– For broader control** over PHP configurations in Apache environments, `.htaccess` is a solid choice.
– In environments running FastCGI or PHP-FPM, `.user.ini` is a more appropriate option.
Each method has its place based on your server configuration. If you only need to adjust the memory limit for WordPress, `wp-config.php` is a quick and reliable method. For broader control of PHP settings across an entire website, `.htaccess` or `.user.ini` might be more appropriate, especially in non-WordPress-specific contexts.