Announcement

Collapse
No announcement yet.

How to change server default PHP version? (Using cpanel)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change server default PHP version? (Using cpanel)

    Hello,

    I am using cpanel and CloudLinux PHP Selector. I want to change the entire server default from the version created by EasyApache to the PHP 5.4 version managed by the PHP Selector.

    How do I do that? Do I need to recompile using EasyApache? Or is it as easy as going into LVE Manager and then changing the "Default PHP version" from "native" to "PHP 5.4"? Will that automatically update all customer accounts that are using "native" version from cpanel?

    Thanks.

  • #2
    If you switch version to PHP5.4 as default, all new users will get it, but existing users will continue to use native version.

    If you want to switch all users to default version of PHP (be it native, or PHP5.4 -- what ever you have selected in PHP selector), run:
    $ cagefsctl --cl-selector-reset-versions

    Yet, I would recommend first testing it on 5-6 customers, like, you can do it by specifying their user names:
    cagefsctl --cl-selector-reset-versions user1 user2 user3 user4 user5...

    Comment


    • #3
      Ok, you are correct -- if you have individual php.ini files for end users in custom.etc directories -- you need to do that.

      Comment


      • #4
        OK. Heres the situation. I think this is very typical for CloudLinux users:

        1. We have PHP 5.2 installed using cpanel EasyApache. This is the CloudLinux PHP Selector "native" version.

        2. Current "Default PHP version:" in LVE Manager is "native".

        3. We have some customers who have used PHP Selector to change their PHP version. (ie: They have used PHP Selector to change to PHP 5.3 or PHP 5.5, etc...)

        So now, we want to change all customers who are using "native" cpanel version to instead use PHP Selector 5.4 version. We do not want to modify any customers who have specifically selected a different PHP version (#3 above.)

        What should we do?

        Comment


        • #5
          This question is going to arrive eventually when one of the older versions of PHP supported by PHP Selector eventually has some security problem.

          At that time, many server owners will want to know how to switch everyone who is using version X to version Y.

          I hope this is possible?

          Comment


          • #6
            Hello!

            Please use the following script:

            #!/bin/bash

            # $1 = "from" php version
            # $2 = "to" php version

            if [ -z "$1" -o -z "$2" ]; then
            echo "Usage: $0 from to"
            echo "Example: $0 native 5.4"
            exit 1
            fi

            for user in `cagefsctl --list-enabled | grep -v "enabled user(s)"`; do
            php_vers=`cl-selector --current=php --user="$user" | cut -s -f 1`
            if [ "$php_vers" == "$1" ]; then
            echo -n "Switching $user from $php_vers to $2 ... "
            cl-selector --select=php --version="$2" --user="$user"
            php_vers2=`cl-selector --current=php --user="$user" | cut -s -f 1`
            if [ "$php_vers2" == "$2" ]; then
            echo "Ok"
            else
            echo "Failed"
            fi
            fi
            done

            Comment


            • #7
              Perfect. Thanks!

              Comment


              • #8
                where would we add that code? assume that code sets the native to 5.4?

                Comment


                • #9
                  Its a shell script, you would save it to a file like changephp.sh then run something like

                  ./changepphp.sh 5.2 5.3

                  Id be carefull though to make sure you dont change any you dont want to…

                  Comment


                  • #10
                    It would be nice to see some utilities like this easily executable from within the LVE Manager interface.

                    Comment

                    Working...
                    X