Having trouble increasing WordPress memory limit on nginx server

6,379

Solution 1

One can not re-define a constant (in PHP / WordPress). So, you must have put the line...

define('WP_MEMORY_LIMIT', '128M');

at the end of your wp-config.php file. If you are not already aware, the last default line in this file (require_once(ABSPATH . 'wp-settings.php');) setup all the variables and constants.

In order to solve your issue, you must define 'WP_MEMORY_LIMIT' before WordPress sets its constants. So, the contents (or tail wp-config.php) of your site's wp-config.php file should read like this...

define( 'WP_MEMORY_LIMIT', '128M' );

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Basically, there is nothing wrong with Nginx or php-fpm. The issue is in where you define a constant for WordPress.

Solution 2

As far as I can remember, Wordpress doesn't list available/maximum RAM but allowed upload file size.

You can change that through the upload_max_filesize and post_max_size settings in php.ini or per-pool in your php-fpm.d/*.conf files.

Concerning nginx, remember to set client_max_body_size 128m; to allow for bigger POST data to be sent to/through the webserver.

Share:
6,379

Related videos on Youtube

John Tate
Author by

John Tate

I am pretty awesome at C++ and PHP but I get stuck on some stupid shit.

Updated on September 18, 2022

Comments

  • John Tate
    John Tate over 1 year

    I am trying to increase the memory limit on my nginx php-fpm server for wordpress. Specifically the Wordpress plugin WooCommerce needs more available memory.

    I've set the following in wp-config.php...

    define('WP_MEMORY_LIMIT', '128M');
    define('WP_MAX_MEMORY_LIMIT', '128M');
    

    php.ini has the following...

    memory_limit = 128M
    ;suhosin.memory_limit = 0
    

    The fpm server is also set to change this.

    php_admin_value[memory_limit] = 128M
    

    Yet WooCommerce's system status still claims it only has 40MB, how can this be?

    I believe it might be suhosin but I am unsure how to change this on an OpenBSD server. I've tried changing it in the settings for the php-fpm server pool.

    php_admin_value[suhosin.memory_limit] = 128M
    

    If someone can tell me how to change the limit on an OpenBSD server that would be very good.

    • Michael Hampton
      Michael Hampton over 10 years
      Did you restart php-fpm?
    • John Tate
      John Tate over 10 years
      Yes I restarted php-fpm.
    • Pothi Kalimuthu
      Pothi Kalimuthu over 10 years
      Could you post the contents of wp-config.php file, excluding DB credentials, salt, and table_prefix?
  • John Tate
    John Tate over 10 years
    This has nothing to do with upload size. The Wordpress plugin WooCommerce lists available memory on it's system status page. I need to increase the max memory.
  • Andres B
    Andres B over 10 years
    What happens if you go crazy and set memory_limit to 512M or something like that? Make sure there isn't a per-directory php.ini file in effect, overriding the main config. Try momentarily disabling APC as it can show you stale/cached PHP output.
  • John Tate
    John Tate over 10 years
    I don't seem to have APC installed so it isn't that. There is no php.ini for the users directory.
  • John Tate
    John Tate over 10 years
    I definitely don't have APC, just confirmed that.