If you are trying to develop some website on shared hosting using wordpress, there are high chances you will encounter following error sometime,
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49152 bytes) in "/path/filename.php" on line "linenumber"
This error is mainly due to PHP memory limitations, we get by default for the shared hosting servers.
Solution : We need to increase the PHP memory limitations by changing the php.ini file. For this you will need an access to /public_html folder of your shared hosting. If you have an FTP access to /public_html folder in your hosting,
- Check if you have phpinfo.php and php.ini files in /public_html folder, if those are there then you will just need to make sure those two files contain the following lines. You can edit those files as mentioned in next step.
- If you don’t have phpinfo.php & php.ini files, we need to create those two files and upload to /public_html using FTP.
Create phpinfo.php [ Note: we used vim editor on ubuntu, you can use any other editor on any other OS like windows as you are comfortable ]
$ vim phpinfo.php
<?php phpinfo(); ?>
Save the file with above changes.
$ vim php.ini
max_execution_time 600 memory_limit 128M post_max_size 32M upload_max_filesize 32M
Save php.ini with above changes and upload both files to /public_html/ location in your server. and Try refreshing your browser where you have seen this error. There are possibility that you may need to Kill PHP Process if you have access to cPanel, if error still persist, or wait for some time to let the changes takes effect by your hosting service provider and try again. This Works !