Sites hosted on Nexcess will already have very high PHP defaults (php.ini default values) without having to override those values via a .user.ini file in most cases.
However, one should be well versed on how those values are configured, including the required formats for specifying gigabytes, megabytes, and kilobytes.
Please note that the required formats for the PHP values documented in this article apply when configuring the values documented in both php.ini and .user.ini files.
What is the php.ini file?
Your Apache web server's php.ini file is the standard configuration file used in your PHP-based applications. This settings file is used to set upload sizes, display errors, resource limits, file timeouts, and many other things. There is a default PHP settings (php.ini) file installed on your server.
Where is the php.ini file located?
Your Apache web server's php.ini file is the default configuration file for applications that require PHP. It is used to manage values such as upload sizes, file timeouts, and resource limits. The php.ini file is located on your server in the /public_html folder.
Modifying PHP limits in general at Nexcess
However, making a .user.ini file in the website's document root is another approach to change the PHP restrictions on any type of website hosted on a Nexcess server.
The html directory serves as the document root for the majority of hosted websites. Either the pub directory or the domain-named directory will serve as the document root for Magento sites.
Other PHP methods for overriding php.ini timeout values
Other PHP methods for overriding php.ini timeout values are covered in the following article:
Overriding php.ini timeout values with your PHP Script's execution time limit | Nexces
That article reviews that maximum execution time setting with regard to PHP scripts and how to override the php.ini timeout value that is set with the max_execution_time variable in the php.ini setting file. You can change the maximum allowed execution time for your PHP scripts as this article outlined.
About the very high default php.ini values used at Nexcess
With regard to the php.ini default values at Nexcess, the following common PHP values are set as follows:
Those commonly requested values on your site for plugins and themes do not need to be changed. This is because the default values for PHP memory and post max and upload max file sizes are already more than high enough.
Some plugins and themes might recommend setting the PHP memory to at least 256 MB in size but the PHP memory by default is already going to be higher. The same is true for upload file size limits that are already high enough in most cases.
Take the time to reference the default PHP values already set before making any custom PHP default changes using the .user.ini file.
Regarding the exact format that must be used for the default php.ini values and your custom .users.ini values
About shorthand byte values in PHP
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:
Avoiding gigabyte, megabyte, and kilobyte value formatting issues
As well documented on Stack Overflow in the article below, you must specify your gigabyte, megabyte, and kilobyte values in the exact format expected for them to work:
"So, I solved this. Really really annoyingly. The problem was that I typed 1GB instead of 1G in php.ini. No error messages were given, and it wasn't clear at all that it wasn't using 1 gigabyte. But php.ini won't recognize things like 1KB, 1MB or 1GB as you have to type it without the B.
Lesson learned, a lot of time wasted." ~ John M
Default php.ini values: gigabyte must be specified only with a trailing "G" and not a using trailing "GB" to work properly
Gigabyte must be specified only with a trailing "G" and not using a trailing "GB" to work properly in your default php.ini values.
Furthermore, gigabytes can only be specified in whole numbers (1, 2, 3, etc.), which limits the possible range of values to the exact value represented by the whole number value of the gigabyte value you specify:
Gigabytes to megabytes and kilobytes
- 1 GB = 1000 MB (in decimal)
- 1 GB = 1024 MB (in binary)
- 1 GB = 1000000 KB (in decimal)
- 1 GB = 1048576 KB (in binary)
- 2 GB = 2000 MB (in decimal)
- 2 GB = 2048 MB (in binary)
- 2 GB = 2000000 KB (in decimal)
- 2 GB = 2097152 KB (in binary)
- 3 GB = 3000 MB (in decimal)
- 3 GB = 3072 MB (in binary)
- 3 GB = 3000000 KB (in decimal)
- 3 GB = 3145728 KB (in binary)
Most developers and system admins use M for megabytes since its more widely accepted and offers a greater degree of configurability.
Default php.ini values: megabyte must be specified only with a trailing "M" and not using a trailing "MB" to work properly
Megabyte must be specified only with a trailing "M" and not using a trailing "MB" to work properly in your default php.ini values.
Furthermore, megabytes can be specified in more precise units, where using four digits is the standard practice as per the following examples:
Default php.ini values: kilobyte must be specified only with a trailing "K" and not using a trailing "KB" to work properly
Kilobyte must be specified only with a trailing "K" and not using a trailing "KB" to work properly in your default php.ini values.
Although kilobytes can be specified in more precise units, where using seven digits would be done, they are a less popular configuration choice.
In this article you learned that webites hosted on Nexcess have high php.ini default values. We reviewed how those values are configured, including the required formats for php.ini and .user.ini files.
If you need more help with your PHP settings, feel free to contact our staff by email at email@example.com for assistance.
Note about the original publication date
This article was originally published in May 2021. It has since been updated for accuracy and comprehensiveness.