If you are trying to fix PHP Memory limit error on VPS then i would like to recommend you to follow the below process. You might receive error like”
PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>" OR ”
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/xxx/public_html/wp-includes/plugin.php on line xxx. This is the error because of small size PHP memory assigned on the server or your VPS server.
There are various ways of fixing PHP Memory limit errors. You can directly add some code to your .htaccess file or PHP.INI file if this is allowed on your server. By default this feature are disabled from server end.
To increase PHP memory using .htaccess, you can simply add this
define( 'WP_MEMORY_LIMIT', '500M' );
to your .htaccess file. By default on server this size is limited to 32MB or may be more in some case like dedicated server. If you are using shared web hosting server and the above method do not work, they you need to contact your server administrator.
To Increase PHP Memory limit using WHM/Cpnael ROOT access.
If you are using VPS and have WHM/Cpanel installed on your server, you can increase the PHP memory limiit very easily. Just follow the below navigation process.
WHM >> Server Configuration >> PHP Configuration Editor >> memory_limit and change it from default value like 32M to 600M or your desired memory.
To Increase PHP Memory limit using command line.
First you need to check the current allocated memory on your VPS or dedicated server. You can check your current PHP memory limit using the below code.
php -r "echo ini_get('memory_limit').PHP_EOL;"
Now to increase limit using “PHP.INI”. Navigate to /etc /php5.6 /cli /php.ini. on Debian like system and edit this. You will see something like below on php.ini file
; Use -1 for unlimited or define an explicit value like 2G memory_limit = -1
And thus you can increase your PHP limit in your desired way.