How to Increase Memory Limit in PHP Ubuntu?

03-Apr-2023

.

Admin

How to Increase Memory Limit in PHP Ubuntu?

Hello Friends,

In this tutorial, you will learn how to increase the memory limit in php ubuntu. We will help you to give examples of how to increase php memory limit. You'll learn how to change php memory limit in the php.ini file.

We will cover how to implement how to increase memory limit in php ubuntu. This tutorial will give you a simple example of increasing PHP's memory limit on ubuntu. This article will give a simple example of increasing the php memory limit. this example will help you change the php memory limit in the php.ini file. Follow the below tutorial step on how to increase maximum upload and php memory limits.

How to Increase memory limit php Ubuntu


Execute the following command to get the currently loaded php.ini file in your ubuntu system:

php -i | grep php.ini

You will find the following output and copy the loaded php.ini file path:

Configuration File (php.ini) Path => /etc/php/8.1/cliLoaded

Configuration File => /etc/php/8.1/cli/php.ini

Now, execute the following command on the terminal to set or change max input vars in php ini Ubuntu by editing the php.ini; as follows:

sudo nano /etc/php/8.1/cli/php.ini

Then find and set the following two values; as follows:

post_max_size = 100M

upload_max_filesize = 100M

max_file_uploads = 20

max_input_vars = 200

memory_limit = -1

Save and close the file. Where,

  1. post_max_size = 100M :
  2. upload_max_filesize = 100M : Maximum allowed size for uploaded files.

Restart Apache server

Now, execute the following command into the terminal to restart the apache web server; as follows:

$ sudo service apache2 restart

OR

$ systemctl restart apache2.service

I hope it can help you...

#Ubuntu