Announcement

Collapse
No announcement yet.

Cloudlinux 7.1 and PHP Selector

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

  • Cloudlinux 7.1 and PHP Selector

    Info

  • #2
    Hello,

    Ive installed a fresh Cloudlinux 7.1, registered and installed CageFS, LVM and PHP Selector. My goal is to run this server globally with a version of PHP 5.3. CentOS 7.1 comes with PHP 5.4 so this is the way Ive used to temporary downgrade the version and in the future handle the upgrades.
    From the yum output, all seems correctly installed. Ive performed following commands:

    Code:
    yum install cagefs
    
    /usr/sbin/cagefsctl --init
    
    yum install lvemanager
    
    yum groupinstall alt-php
    
    yum upd ate cagefs lvemanager
    
    selectorctl --list
    
    selectorctl --current
    
    selectorctl --set-current=5.3
    
    cagefsctl --enable-all
    Im NOT using any WEB gui to manage sites like Plesk or whatever. Ive a single virtual host. BTW, even if Ive se t-up the default PHP 5.3 it continues to use the native PHP 5.4.

    Code:
    selectorctl  --current --show-native-version
    
    5.3     5.3.29  /opt/alt/php53/usr/bin/php-cgi
    If I open the browser pointing it to a test paghe with:

    Code:
     phpinfo()?>
    I got always the PHP 5.4.
    Im missing the part on how manually switch the PHP version for apache.

    Any help?

    Thanks a lot!

    Comment


    • #3
      Did you restart Apache after making the changes?

      Comment


      • #4
        Yes, Ive restarted it (apache 2.4).
        Nothing changed. Is there a way to check-debug it? Maybe Im missing some steps

        Comment


        • #5
          After you ran $ /usr/sbin/cagefsctl --init
          Did you create the skeleton directory?
          $ mkdir /home/cagefs-skeleton
          $ ln -s /home/cagefs-skeleton /usr/share/cagefs-skeleton

          Comment


          • #6
            As written in the DOC the init does the job. I need the steps you mentioned only if I have not enough space. Look:

            Code:
            # ls -al /usr/share/cagefs-skeleton/
            
            total 76
            
            drwxr-xr-x   13 root root   141 Oct 22 16:57 .
            
            drwxr-xr-x. 122 root root  4096 Oct 22 16:57 ..
            
            lrwxrwxrwx    1 root root     7 Oct 22 16:57 bin -> usr/bin
            
            drwxr-xr-x    4 root root  8192 Oct 22 16:58 dev
            
            drwxr-xr-x    2 root root     6 Oct 22 16:57 etc
            
            dr-xr-xr-x.  28 root root  4096 Oct 22 16:55 lib
            
            dr-xr-xr-x.  55 root root 36864 Oct 22 16:56 lib64
            
            drwxr-xr-x.   6 root root    46 Oct 22 16:55 opt
            
            dr-xr-xr-x  496 root root     0 Oct 22 16:50 proc
            
            drwxr-xr-x    2 root root     6 Oct 22 16:57 root
            
            drwxr-xr-x    3 root root    22 Oct 22 16:57 run
            
            lrwxrwxrwx    1 root root     8 Oct 22 16:57 sbin -> usr/sbin
            
            drwxr-xr-x    2 root root     6 Oct 22 16:57 tmp
            
            drwxr-xr-x   12 root root   135 Jun 24 17:52 usr
            
            drwxr-xr-x    9 root root    94 Oct 22 16:57 var
            Also the dirs are ok, so I think.
            I missing how apache knows to use the alternate version of PHP.
            Looking on the loaded files:

            Code:
            # lsof | grep php
            
            (...)
            
            httpd     40048        apache  mem       REG              253,0    256560  405692052 /usr/lib64/php/modules/pdo.so
            
            (...)
            Nothing points me that the alternate version is in use, that should be in a different path, in example, for pdo, not in usr/lib but in opt:

            Code:
            # locate pdo.so
            
            /opt/alt/php51/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php52/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php53/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php54/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php55/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php56/usr/lib64/php/modules/pdo.so
            
            /opt/alt/php70/usr/lib64/php/modules/pdo.so
            
            /usr/lib64/php/modules/pdo.so
            What Im missing...?

            ADD
            I think not having any control panel, I need to setup the apache config files to point to the new php manually per virtualhost. So I need help on that (I think)

            Comment


            • #7
              Hi,

              Well, its hard to decide what is wrong there, but for proper php-selector work you need active system user with enabled cagefs, as all php-switches are done with prelinking inside cagefs. I suggest you using the following KB article as base for your setup: http://kb.cloudlinux.com/2015/09/con...control-panel/

              Comment


              • #8
                Hello!

                Thanks a lot for the link. Ive made some steps forward, but Im getting some errors. Ive corrected the setup to match the CentOS 7.1 version.
                So, switching to the user I can see the right php version:

                ROOT:

                Code:
                # php -v
                
                PHP Warning:  PHP Startup: No such handler: gdbm in Unknown on line 0
                
                PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
                
                Copyright (c) 1997-2013 The PHP Group
                
                Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
                USER:

                Code:
                # su - my_user
                
                Last login: Mon Oct 26 09:02:52 CET 2015 on pts/2
                
                -bash-4.2$ php -v
                
                PHP 5.3.29 (cli) (built: Aug 19 2015 10:05:30)
                
                Copyright (c) 1997-2014 The PHP Group
                
                Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
                The document root of the site is located here:

                Code:
                DocumentRoot /home/my_user/jail/ramdisk/my_site/
                Ive recompiled suexec as well and it matches now:

                Code:
                # suexec -V
                
                -D AP_DOC_ROOT="/home"
                
                -D AP_GID_MIN=500
                
                -D AP_HTTPD_USER="apache"
                
                -D AP_LOG_EXEC="/usr/local/apache2/logs/suexec_log"
                
                -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
                
                -D AP_UID_MIN=500
                
                -D AP_USERDIR_SUFFIX="public_html"
                BTW a phpinfo shows me always the default php.
                Does the "AP_USERDIR_SUFFIX" have something to do not matching the default users DocumentRoot?

                Here my httpd conf:

                Code:
                ServerName www.my_site
                
                ServerAlias new.my_site
                
                DocumentRoot /home/my_user/jail/ramdisk/my_site/
                
                ErrorLog /home/my_user/jail/logs/my_site_error_log
                
                CustomLog /home/my_user/jail/logs/my_site_access_log combined
                
                ScriptAlias /cgi-bin/ /home/my_user/jail/ramdisk/my_site/cgi-bin/
                
                SuexecUserGroup my_user my_user
                
                AllowOverride FileInfo AuthConfig Indexes Limit Options=Indexes,FollowSymLinks
                
                Options +MultiViews +Indexes +SymLinksIfOwnerMatch +IncludesNoExec +FollowSymLinks +ExecCGI
                
                Require all granted
                
                AddHandler php5-fastcgi .php
                
                Action php5-fastcgi /cgi-bin/php.fcgi
                
                AllowOverride None
                
                Options +FollowSymLinks
                
                Require all granted
                Ive tried the suPHP version as well, but cannot find the package in the Cloudlinux repo:

                Code:
                # yum install mod_suphp
                
                Loaded plugins: dellsysid, fastestmirror, rhnplugin
                
                This system is receiving updates from CLN.
                
                Loading mirror speeds from cached hostfile
                
                * cloudlinux-x86_64-server-7: cl-mirror.cloud.dk
                
                * epel: mirror.de.leaseweb.net
                
                No package mod_suphp available.
                
                Error: Nothing to do
                Suggestions?

                Thanks!

                Simon

                Comment


                • #9
                  As far as I see you have configured php to use fastcgi, if so mod_suphp is not needed.

                  Anyway, next step is to check if your user has been properly identified when opening from web, please create a simple php script to display whoami:

                  Code:
                  <?php echo exec("whoami") ; ?>
                  I see you defined SuexecUserGroup in virtualhost, but if this test page will say root/nobody it means something not Ok with suexec, or it was not loaded.

                  If you see username then check if suexec is really patched, you should see some LVE functions in binary, like:

                  Code:
                  $ strings /usr/local/apache/bin/suexec | grep -i lve
                  
                  liblve.so.0
                  
                  lve_jail_uid
                  
                  failed to init LVE library %s

                  Comment

                  Working...
                  X