I added the line ini_set('memory_limit', '2048M'); into the pub/index.php and reloaded the Nginx config, however, the memory_limit didn't change.

I created a phpinfo.php and the memory_limit1 is still showing 768M...

Cleared /var and pub/static but still not luck.

4 Answers 4


I changed the memory_limit using the php.ini file:

You must find where your php.ini file is, you can easily do that typing php --ini

Personally I have it in:


Then you open the file using nano, vi or vim:

vi /opt/plesk/php/7.0/etc/php.ini

Inside the file typing / you can search inside. Search for memory_limit

Once you find it, change the value and exit typing: :x.

Hope you achieve it.

  • I have other websites on my stack and this would change the memory_limit for all the sites?
    – Greg
    Aug 2, 2018 at 11:24
  • I don't know what do you mean by "stack", but what I can assure is that all Magentos using that php.ini file will suffer the changes from it. Example: If you have 3 diferent Stores under the same domain: dom1.domain.com, dom2.domain.com, dom3.domain.com, they will all have those changes.
    – Raül
    Aug 2, 2018 at 11:30
  • By "stack" I meant all the other websites using this file... and this is not something I am looking forward to... thank you for your help tho!
    – Greg
    Aug 2, 2018 at 11:33
  • Well, in case you only have 1 store in a server and you need it, it is pretty useful :D I'll have a look if there is another way to do it then.
    – Raül
    Aug 2, 2018 at 11:41
  • There must be some kind of "per domain" Nginx config wrapper. I'll dig it out ;) Thanks
    – Greg
    Aug 2, 2018 at 11:56

Open vim /etc/php-fpm.d/www.conf

php_admin_value[memory_limit] = 10000M ; 128M

Then restart php-fpm:

service php-fpm restart

Please try this

  • bash: vim: command not found error on console.
    – Greg
    Aug 2, 2018 at 10:16
  • try vi or nano instead of vim, you might not have vim installed
    – Raül
    Aug 2, 2018 at 10:18
  • nano worked, however it tried to create a new file, meaning it doesn't exist.
    – Greg
    Aug 2, 2018 at 10:22
  • @Bare Feet Sorry to late response . please review this wiki.gentoo.org/wiki/Nano/Basics_Guide
    – Shorabh
    Aug 2, 2018 at 10:44

If none of the other answers worked, you can also configure PHP settings in the Nginx configuration file for your site.

For example, Magento 2 comes with a default Nginx virtual host configuration file, nginx.conf.sample, which sets the memory_limit to 768M.

This snippet comes from that file:

# PHP entry point for main application
location ~ (index|get|static|report|404|503)\.php$ {
    try_files $uri =404;
    fastcgi_pass   fastcgi_backend;
    fastcgi_buffers 1024 4k;

    fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";

    # Change the memory_limit value to whatever is appropriate for your site:
    fastcgi_param  PHP_VALUE "memory_limit=4096M \n max_execution_time=18000";

    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;

    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;

The above extract sets the memory_limit to 4096M (4GB). You'll need to include it within the server block of your virtual host and this only applies to PHP-FPM.

  • Tried your solution but get duplicate errors as such: nginx: [emerg] "fastcgi_connect_timeout" directive is duplicate in /etc/nginx/fastcgi_params:8 and changing the configuration in the main config file is not something I am willing to do...
    – Greg
    Aug 2, 2018 at 11:38
  • @BareFeet You should modify the snippet to suit your circumstances. If fastcgi_connect_timeout is already defined, then don't include it in your virtual host config file. Aug 2, 2018 at 15:16

for apache2 you can change the memory limit in src/pub/.htaccess

just be sure ot change it for your php version (5 or 7)

  • I am using NginX so .htaccess will to reflect any changes...
    – Greg
    Aug 2, 2018 at 10:31
  • true. I never really used nginx so I didn't know they don't use htaccess. Aug 2, 2018 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.