Edit PHP files — .user.ini, nexinfo.php, and php.ini files
Any application using the Hypertext Preprocessor (PHP) platform in its programming language uses the php.ini file as its default configuration file. If done correctly, admin users can edit PHP files to change system variables such as file timeouts, resource limits, and upload sizes — among other variables found in the existing PHP settings files.
Getting starting when you need to edit PHP files
Sometimes, scripts running on your websites may require more resources than what is available by default. We will show you how to modify the PHP settings file or files as necessary to ensure your websites function correctly. This kind of modification involves your capability to edit PHP files.
Nexcess default PHP limits
Per website hosted with us, PHP settings file’s default limits are set high enough on all cloud hosting plans to ensure normal website functionality works as expected. Nexcess uses the following standard PHP configuration:
- max_execution_time 600
- max_file_uploads 1024M
- max_input_vars 16384
- memory_limit 2048M
- post_max_size 1536M
- upload_max_filesize 1536M
Creating a phpinfo file to output the PHP limits currently configured
It is important to note that the PHP information files created by following the guidance in this section should always be removed and not left on the server after testing.
You can check PHP limits used on your site simply by creating a phpinfo file named nexinfo.php within the document root directory on your site. It only requires one snippet of code within the file to call on the phpinfo() function, and you can add it by running a simple command from your site’s document root directory:
echo "?php phpinfo(); ?" >> nexinfo.phpYou can then access the phpinfo page through your main domain (for example, https://domain.com/nexinfo.php). After reviewing this particular PHP settings file, we advise that you permanently delete the phpinfo file (for example, the nexinfo.php file you just created in the steps above) from your site.
Adjusting PHP limits via the wp-config.php PHP settings file
Before modifying the PHP limits in the wp-config.php file, create a backup of the original file. Then, add directives like the following:
define('WP_MEMORY_LIMIT', '128M');Note that for sites running WooCommerce, we recommend setting the PHP memory limit to at least 256M.
You should be done once you save the file. If you’re still getting the fatal error message, you may need to increase it further. To increase the admin area’s memory limit, you’ll need to add a directive similar to this:
define( 'WP_MAX_MEMORY_LIMIT', '256M' );Edit PHP files to modify PHP limits for Magento-based websites
You can modify PHP limits for Magento in the .user.ini and .htaccess files.
Adjusting PHP limits via the .htaccess and .user.ini PHP settings files
Both of these may be included in the website’s document root directory. Multiple .htaccess and .user.ini files may exist in various directories within the Magento installation. You should use the lowest applicable restrictions here, and caution is always advised because the directions within them may conflict with one another.