Modifying PHP Directives

Bolts are precisely tuned for performance, with optimized hardware, software, and network settings. Some Bolt settings may be more modest for PHP usage than other providers. Our PHP settings are perfectly optimized for most websites and applications, ensuring smooth and hassle-free performance.

Depending on your Bolt, you may achieve this using the .htaccess file or the .user.ini file. This guide will cover both methods.

In general, we don’t recommend changing these directives, as our Bolts are optimized for speed, and changes may affect the performance of your website. However, sometimes, you may need to modify a PHP directive due to WordPress plugin or theme requirements.

Remember that this will only change how PHP functions for visitors to your site. If you invoke PHP through any other means, e.g., SSH or cron jobs, default PHP directives will be used.

To view the current PHP Directives, create a new PHP file called 12345.php with the following content:

<?php

phpinfo(4); 

?>

Upload it to your website’s web root and visit the following page in a browser: example.com/12345.php.

Customizing PHP Directives Using .htaccess

IF your site’s public folder is located at ~/public, you can modify PHP directives using the .htaccess file. This file allows you to set PHP directives directly within your site’s home or public directory (depending on the Admin Panel setting). Here are examples of configuring common PHP directives in the .htaccess file.

Enabling .htaccess

First, you must ensure that .htaccess is enabled for your public directory or both in your Environment Settings.

Environment Settings can be found by navigating to your Bolt -> Environment (Select your Environment) -> Settings on the top navigation bar of our Admin Panel.

Example Directives

php_value upload_max_filesize 200M

php_value post_max_size 200M

php_value max_input_vars 2000

php_value max_execution_time 120

Explanation:

  • php_value upload_max_filesize 200M
    • Sets the maximum upload file size to 200 megabytes.
  • php_value post_max_size 200M
    • Sets the maximum size of POST data that PHP will accept to 200 megabytes.
  • php_value max_input_vars 2000
    • Limits the number of input variables to 2000.
  • php_value max_execution_time 120
    • Sets the maximum time in seconds a script is allowed to run to 120 seconds.

Please refer to the official documentation for a complete list of all configurable PHP directives.

Remember that this will only change how PHP functions for visitors to your site. If you invoke PHP through any other means, e.g., SSH or cron jobs, default PHP directives will be used.

Customizing PHP Directives Using .user.ini

IF your site’s public folder is located at ~/site/public, you can modify PHP directives using the .user.ini file. Unlike .htaccess, the .user.ini file uses a different format for setting PHP directives. Here are the same directives configured in a .user.ini file:

Example Directives

upload_max_filesize = 200M

post_max_size = 200M

max_input_vars = 2000

max_execution_time = 120

Explanation:

  • upload_max_filesize = 200M
    • Sets the maximum upload file size to 200 megabytes.
  • post_max_size = 200M
    • Sets the maximum size of POST data that PHP will accept to 200 megabytes.
  • max_input_vars = 2000
    • Limits the number of input variables to 2000.
  • max_execution_time = 120
    • Limits the number of input variables to 2000.

Please refer to the official documentation for a complete list of all configurable PHP directives.


And as always, should you have any additional questions please don’t hesitate to contact our support chat at servebolt.com!