Question

How to increase memory limit

  • Posted on February 15, 2022
  • WalktailsAsked by Walktails

Hi Team,

I am not able to increase the memory limit for my website.

Can you please help me with the same.

Regards, Kanchan Singh


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

What I would personally do is the following:

  • Start by creating a new file called info.php with the following content:
<?php
phpinfo();
  • Save the file and then visit the file via your browser, eg your_website.com/info.php

  • This will show you your PHP configuration as follows:

PHP info file

  • On that page, look for the Loaded Configuration File which will show you the exact location of your php.ini file. In my case it is:
/etc/php/8.0/fpm/php.ini

But keep in mind that if you are using a different PHP version with a different handler the location would be different.

  • Then open that file with your favorite text editor:
sudo nano /etc/php/8.0/fpm/php.ini
  • And look for the memory_limit line and update the value accordingly:
memory_limit = 128M
  • Finally, if you are using PHP FPM you would need to restart it:
sudo systemctl restart php8.0-fpm.service

If you want to change this for your PHP CLI too, you could run php -i | grep php.ini and this will show you the location of the php.ini file for your CLI version.

Hope that this helps!

Best,

Bobby