Nexcess Logo

Modifying the PHP memory limit on cloud hosting plans

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
January 11, 2023

Nexcess cloud hosting plans and Managed WordPress and WooCommerce plans are scalable plans with resources optimized for various content management systems our clients might use to manage their sites.

Modifying the PHP memory limit on cloud hosting plans

Sometimes the scripts your websites are running will need additional resources compared to what’s already available to them by default.

Here you’ll learn how to modify PHP memory limits to ensure the functionality of your websites can run without errors.

PHP memory management

Every site hosted on a Nexcess plan already has PHP memory limits set high enough to allow it to function normally. The following common PHP values are set as follows:

  • max_execution_time 600
  • max_file_uploads 1024M
  • max_input_vars 16384
  • memory_limit 2048M
  • post_max_size 1536M
  • upload_max_filesize 1536M

Note about the shorthand byte values used in PHP

As is well-documented in the following article, the M shown above represents megabytes and to avoid issues, the proper shorthand byte values of K, M, and G must be used appropriately when setting a PHP memory limit:

What are the php.ini default values Set for Nexcess customers?

So, a few PHP directives may also take on shorthand byte values, as opposed to only int byte values. People often want to know what the available shorthand options for byte values in PHP are. The available options are K for kilobytes, M for megabytes, and G for gigabytes — and they are all case-insensitive:

PHP: Using PHP - Manual

PHP: Description of core php.ini directives - Manual

Checking PHP limits including PHP memory limits

You can check the PHP limits set for your site by creating a nexinfo.php file within the document root directory of your website. Running this command when you’re in the site’s document root directory will allow you to check them:

echo"<?php phpinfo(); ?>" >> nexinfo.php

The information page can be accessed through your main domain, like

Please note that frequently the Content Management System (CMS) you’re using for the website might be blocking the creation of this file or access to it. In those cases, we’d suggest deleting the nexinfo.php file and contacting our Nexcess Support Team to confirm the actual limit values. Please always delete this file after you’ve checked the information you need.

About the PHP settings file

The primary way to modify the PHP memory limits on any type of website hosted on a Nexcess server is to create the PHP settings file. The file used for PHP memory management will need to be called the .user.ini file and located within the document root of the website.

The document root directory for most websites is the html directory. The document root for Magento sites will be either the pub directory or the domain-named directory.

The directives within the .user.ini file will need to be similar to the following:

memory_limit = 128M
max_execution_time = 3600
max_input_vars = 20000

More information about these directives can be found in the PHP manual. Using .htaccess files to modify PHP limits — including the PHP memory limit — is not advisable on Nexcess servers.

Modifying PHP limits for WordPress-based websites

WordPress websites hosted on the Nexcess Cloud plans or within Managed WordPress/WooCommerce plans will rarely need more resources than allocated to them by default PHP limits. However, occasionally, your website’s WordPress dashboard might show different values than the default ones. In that case, we’d recommend creating the nexinfo.php file, as you’ll be able to confirm the actual limits by visiting the nexinfo.php page, as previously explained.

However, if your website suddenly goes down with the “Critical Error” message, there could be a memory limit. If that happens, you should see an error message similar to the following within the PHP error log or the WordPress debug log:

Fatal error: Allowed memory size of 157286400 bytes exhausted (tried to allocate 5775295 bytes)

WordPress is specific in the way that the PHP limits can be modified in multiple locations. On Nexcess servers, it is not recommended to modify these limits in the .htaccess file, as it can cause further issues.

Modifying PHP limits via the wp-config.php file

Should you wish to modify the PHP limits using the wp-config.php file, you’ll need to create a backup of the initial file and add directives similar to the following:

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

Once you save the file, you should be done. However, if you’re still getting the fatal error with mentions of a memory limit, you might need to increase it further.

Should you want to increase the memory limit for the admin area, you’ll need to add a directive similar to the following:

define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Modifying PHP limits for Magento-based websites

PHP limits for Magento — including the PHP memory limit — can be modified within the .htaccess file, as well as the .user.ini file. Both of these can be added to the document root directory of the website. There can be multiple .htaccess and .user.ini files within various directories of the Magento installation. Caution is always advised here, as the directives within them can contradict one another, and the lowest limits will be applicable.

Conclusion and more about Nexcess web hosting

Nexcess Cloud, Managed WordPress, and Managed WooCommerce plans are scalable plans — that even in multi-tenant environments — allow the sites to perform resource-heavy tasks. The amount of RAM allocated to each plan is not fixed, as it varies depending on the site’s need for resources. PHP memory limits are set initially high and allow for standard functionalities of most sites.

Nexcess Cloud hosting plans offer an easy way to switch PHP versions. as discussed in the following article:

How to update PHP versions in the Nexcess Cloud

Each website within the plan can have an unlimited number of email accounts, along with the hosting space optimized specifically for CMS-based websites, depending on the plan purchased.

These scalable hosting plans come with free daily backups, unlimited email accounts, and the 30-Day Money Back Guarantee included with every plan.

Valuable and vast web hosting education resources are provided from Nexess to assist our customers understand our technology and platforms. So, feel free to browse the extensive Nexcess Knowledge Base and the Nexcess Client Portal Guide.

With a sound technology solution at the core

At Nexcess, having a sound technology solution as the foundation is the key to everything we do. Therefore, our hosting architecture is optimized for performance and other critical factors.

A technology platform to advance your website

Hosting with elite performance and technology. Learn about all of the stellar benefits of our managed hosting services.

See how Nexcess can elevate your Internet presence.

Recent articles

Related articles

Amy Myers
Amy Myers

Amy is a leader of one of the Linux support teams with Liquid Web and Nexcess, with expertise in customer service and Linux support. She considers expanding upon and sharing knowledge as one of life's top priorities. She is an avid technology and art fan.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.