HoganHost blog

[email protected]

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, your server is still using EasyApache 3. Don’t hesitate to get in touch with support for help in upgrading to EasyApache 4.



    Overview

    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). Please follow the instructions below to change the PHP configuration and set the version used by a domain.

    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 adverse effects, 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 many resources, it typically indicates an issue with the application.

    1. Log into your 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, and type PHP.                                                       
    3. In the Software section in the left-hand menu, click on the MultiPHP INI Editor.                                     
    4. PHP settings are changed on a per-version basis, so you first need to choose from the drop-down list the appropriate version.
    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 many 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 adverse 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. 
    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
    7. Below is a basic explanation of the settings in the basic editor.
      Basic Editor Settings
      Allow_url_fopen We recommend leaving this off for security reasons unless your PHP applications need it enabled.
      Display_errors Leave this off unless you are using it to debug your PHP applications currently. Once finished, this should be disabled.
      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 can 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 can 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 server’s amount of RAM to 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 necessary. For example, if the server has 2GB of RAM, 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, this can be adjusted if something is larger than 8M. 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, this can be adjusted if something is larger than 2M. We advise that you lower this once the large upload is completed.
      Zlib.output_compression This setting 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).

        If you see the Feature Showcase, scroll to the bottom and click the Exit to WHM button.

      2. In the search field, search for PHP. You should see the Software section in the left-hand column, then click on the MultiPHP Manager option.                                                                                                                           
      3. In the Set PHP Version per Domain tab, you’ll see the account username, account owner, current PHP version, and whether PHP-FPM is on or off for each domain on the server.
      4. The PHP version for each domain is a drop-down list. As shown in the screenshot below, you can click on this to choose which PHP version is active from the current ones.                                                     
      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.

        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.

      6. If the version of PHP you need to use is not listed, don’t hesitate to get in touch with 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).

        If you see the Feature Showcase, scroll to the bottom and click the Exit to WHM button.

      2. In the search field, search for Easy. In the left-hand column, you should see the Software section. Click on EasyApache 4 option.                                                                                                                                                 
      3. Select the Customize button inside the Currently installed Packages box. 
      4. Choose the PHP Versions from the menu on the left.                                             
      5. Pick the PHP version you would like to install (or uninstall).

        Important:  When updating the PHP version, you will be prompted to install the extensions. We highly recommend doing this during the installation of a new PHP version to ensure the proper MySQL extension is installed.
        To check the PHP extensions, kindly go to ( WHM >> Home >> Software >> EasyApache 4 >> PHP Extensions) From the search box field, type in MySQL.

      6. Select the button PHP x.x and Extensions.                                                               
      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.

 

Holla we hope this helps. check out our cheap vps/dedicated hosting

Leave a Comment

Your email address will not be published. Required fields are marked *