Cart

    Sorry, we could not find any results for your search querry.

    I want to update the PHP version in CentOS

    By default CentOS uses older versions of some software (although updated with the latest security updates) because it prefers stability above the latest features. This is also the reason that the default PHP version is usually a few versions behind on what is available. If you want to use PHP 7 for example, you will first need to update the PHP version on your VPS.

    Important!
    - It is not without risk to update the PHP version on your VPS. You are advised to always create a snapshot before performing below commands in case something goes wrong.
    - The current active version of PHP can be checked by the command php -v via the console (or SSH).

    Step 1: Adding an extra repository for PHP
    • Because both CentOS 6 & 7 only have older versions in their default repository, you will need to add an additional repository. To do so, you can use the Webtatic.com repositories for example.
    • Install the repository via 'rpm' for your specific version of CentOS:
      - CentOS 6.x:
      rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
      (You can use rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm as an alternative).
      - CentOS 7.x:
      rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
      (You can use rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm as an alternative).

    Step 2: Installing the new PHP-version
    • Before installing the new PHP version, it is important you know which PHP 'handler' / 'runtime environment' you want to use. In the example below the default "mod_php" (DSO) is used, but should you like to use a different handler such as php-fpm, this is of course possible. More information regarding the different PHP handlers can be found here.
    • Enter the following command:
      yum install php70w php70w-opcache
      The 'opcache' part is optional, but this is something you would want to use in most situations.
    • Now that you added PHP 7 to the VPS, you can start using it on your website (a restart of Apache / Nginx is required however). However, the default PHP version is not yet changed. This is not without risk and please realize the following steps can cause issues for your webserver. Should you want to update the default PHP version, enter the following command:
      yum install yum-plugin-replace 
      yum replace php-common --replace-with=php70w-common
      

    Need help?

    Receive personal support from our supporters

    Contact us