1. bluehost knowledge base

VPS & Dedicated Hosting: Change Your PHP Version and Configuration - EasyApache 4

EasyApache 4 only

The following instructions are for servers running EasyApache 4. While that should apply in most cases, some older servers may still be running EasyApache 3. If you cannot access the Software » EasyApache 4 section in WHM, this indicates your server is still using EasyApache 3. Please contact support for help in upgrading to EasyApache 4.

Introduction

On our VPS and Dedicated hosting service, changing the PHP versions, loading custom Apache mods, and other Apache/PHP customizations are all performed in the Web Host Manager (WHM). To make changes to PHP configuration and set the version used by a domain, please follow the instructions below:

Configuration 

Recommended values. While it may be tempting to set parameters like memory_limit and max_execution_time to very high values, this can have negative effects such as causing the server to run out of memory or lock up. This is especially the case on smaller servers, with limited resources. Typically, most customers should not need a memory_limit higher than 384 MB, or a max_execution_time greater than 30 seconds. If a script requires so much resources, it typically indicates an issue with the application.

  1. Log into your WHM: How to Access the WHM If you see the "Feature Showcase" scroll to the bottom and click the Exit to WHM button
  2. Once in the WHM go to the search bar in the top left, and type PHP.
  3. In the ‘Software’ section in the left-hand menu, you will see “MultiPHP INI Editor”. Click on that. 
  4. PHP settings are changed on a per-version basis, so you first need to choose from the drop-down list, the appropriate version. If you are not sure what version is currently active for a domain, this can be checked through WHM (see the ‘Versions’ section below). 
  5. The most commonly changed settings can be found in Basic Mode. These can be changed under the ‘Setting’ column, by clicking the button to enable/disable, or filling in the field with the appropriate value. When done, click the ‘Apply’ button at the bottom of the screen.
    • Typically, most servers and website applications should not need a memory_limit higher than 384 MB, or a max_execution_time greater than 30 seconds. If a script requires so much resources, it typically indicates an issue with the application that should be addressed instead

    • While it may be tempting to set parameters like memory_limit and max_execution_time to very high values, this can have negative effects such as causing the server to run out of memory or lock up. This is especially the case on smaller servers, with limited resources. Increasing the value will not speed up your site.
    User-added image
  6. If the parameter you want to change is not listed in Basic Mode, click on Editor Mode and select the PHP version there to get the full list of options, such as error_reporting. When done, click the ‘Save’ button on the right of the screen. 
    User-added image
  7. Below is a basic explanation of the settings in the basic editor.
    • Allow_url_fopen - For security reasons, we recommend leaving this off, unless your PHP applications need it enabled.
    • Display_errors - Leave this off, unless you are using it to currently debug your PHP applications. Once finished, this should be disabled.
    • Enable_dl - Leave this off, unless the applications need it to run and is showing an error without it. It is a PHP parameter that is deprecated and will soon be removed from PHP altogether and if it is in use it is suggested to update these references.
    • File_uploads - This can be on, and is needed to be able to upload media to your websites via their dashboards.
    • Max_execution_time - This is default set to 30 seconds and really shouldn’t be updated. This is how long PHP processes are able to continue to run on the server. Setting this very high allows PHP processes to run for days, causing the server to run out of memory or Apache to lock up.
    • Max_input_time - This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads. This is how long a process is able to run like a Media upload. If something takes longer than 60 seconds, it should be uploaded via FTP instead.
    • Max_input_vars - The default is set to 1000 and it should not be increased as a higher limit may allow DDoS attacks to be more effective and possibly crash the server.
    • Memory_limit - This is the amount of RAM that the server will allow a PHP process to run. Most WordPress websites do not need more than 128M of memory to run and it should not be set to higher than 384M, unless absolutely necessary. For example, if the server has 2GB of RAM, then setting the memory limit to 512M could allow the server to run out of memory with only 4 PHP processes. If your PHP application requires 512M or more (like Magento), we suggest having at least 4G of RAM.
    • Post_max_size - This is the maximum size of uploads via PHP, like uploading files to the media library, or the entirety of a newly created blog post. The default setting is 8M. Most website content should not be this large, as smaller images and media make a faster website, however, if something is larger than 8M, this can be adjusted. We advise that you lower this once the large upload is completed.
    • Session.gc_maxlifetime - This setting is how long the server will store PHP sessions. This setting should not be adjusted unless you are a server administrator and need to adjust the setting.
    • Session.save_path - This is where PHP sessions (from above) are stored. Do not adjust this unless you are a server administrator and need it adjusted.
    • Upload_max_filesize - This goes with post_max_size directly. This is the maximum size of uploads via PHP, like uploading files to the media library, or individual pictures in blog posts. The default setting is 2M. Most website content should not be this large, as smaller images and media make a faster website, however, if something is larger than 2M, this can be adjusted. We advise that you lower this once the large upload is completed.
    • Zlib.output_compression - This is the setting that allows PHP coding to be “compressed” before leaving the server. This is a setting that is default set to off, however, it should be enabled so that PHP website content can be compressed.


Switching PHP Version

  1. Log into WHM (Web Host Manager). Accessing WHM
     If you see the "Feature Showcase" scroll to the bottom and click the Exit to WHM button
  2. In the search field, in the upper left-hand corner, search for “PHP”. In the left-hand column, you should see the “Software” section, and then the “MultiPHP Manager” option. Click on that.
  3. Towards the bottom of the page, you will see the ‘Set PHP Version per Domain’ section. For each domain on the server, you’ll see the account username, account owner, current PHP version, and whether PHP-FPM is on or off.
  4. The PHP version for each domain is a drop-down list. You can click on this to choose which PHP version is active, from the ones currently installed, as shown in the screenshot below. 
     php-version-dropdown
  5. The change will take effect immediately. We recommend taking a note of the old PHP version, so if the new version causes problems with the site, you can set the domain back to using the old version again, in the same way.
  6. Note that changing the PHP version may result in other PHP parameters changing, as these are set on a per-version basis. See the ‘Configuration’ section above, for information on updating these parameters.
  7. If the version of PHP you need to use is not listed, please contact support for help adding new ones to the server. Versions available are from 5.4 up.


Installing new PHP versions via
Easy Apache 4

  1. Log into WHM (Web Host Manager). Accessing WHM If you see the Feature Showcase scroll to the bottom and click the Exit to WHM button.
  2. In the search field, in the upper left-hand corner, search for Easy. In the left-hand column, you should see the Software section, and then the EasyApache 4 option. Click on that.
  3. Select Customize inside the “Currently installed Packages“ box. customize-currently-installed-packages
  4. Select PHP Versions from the menu on the left.
    php-versions
  5. Select the PHP version that you would like to install (or uninstall).
  6. Select the button PHP x.x and Extensions.
    php-and-extentions
  7. Select Review on the left hand menu.
  8. Once loaded, review the installation and select “Provision” from the bottom. There will be a message that states that the provision is complete.