Nginx – Having trouble increasing WordPress memory limit on nginx server

nginxopenbsdPHPphp-fpmWordpress

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.

Best Answer

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.