cpsrvd and PHP

cpsrvd (cPanel and WHM) needs to know the path to the specific PHP binary that should be used to process PHP scripts such as phpMyAdmin. There are likely several PHP binaries from which you can choose and several reasons you may want to pick one PHP binary over another.

The usecpphp File

/var/cpanel/usecpphp, when it exists, causes cpsrvd to use a non-system PHP provided by cPanel. You may want to do this if the version of PHP that you have built for Apache does not have all of the features required to run inside of cpsrvd.

This cPanel-provided PHP binary exists on the system as 1 of the 2 following files:

  • /usr/local/cpanel/3rdparty/bin/php
  • /usr/local/cpanel/3rdparty/bin/php-cgi

note Note: php-cgi is preferred over php if both are available and executable.

This particular PHP binary contains all of the necessary options to run inside of cpsrvd. However, if you experience linking issues or require additional features in the PHP binary that cpsrvd uses, you will need to build an additional local PHP binary. You can do this by running the following script:

  • /scripts/makecpphp

This script uses the EasyApache framework to build a PHP configuration that will work with cpsrvd. This PHP binary will exist as 1 of the following 2 files:

  • /var/cpanel/3rdparty/bin/php
  • /var/cpanel/3rdparty/bin/php-cgi

note Note: php-cgi is preferred over php if both are available and executable.

However, if /var/cpanel/usecpphp does not exist, 1 of the the following 2 PHP binaries will be used:

  • /usr/bin/php
  • /usr/bin/php-cgi

For a pseudo-logic example for determining which PHP binary cpsrvd will use, click here. click here to hide.

if (-e /var/cpanel/usecpphp) {
    if (-x /var/cpanel/3rdparty/bin/php[-cgi]) {
        use /var/cpanel/3rdparty/bin/php[-cgi]
    }
    else {
        use /usr/local/cpanel/3rdparty/bin/php[-cgi]
    }
}
else {
    use /usr/bin/php[-cgi]
}

note Note: php-cgi is preferred over php if both are available and executable.

Topic revision: r7 - 05 Oct 2009 - 13:08:04 - Main.MelanieSeibert
AllDocumentation/WHMDocs.CpsrvdAndPhp moved from Sandbox.CpsrvdAndPhp on 02 Oct 2009 - 21:30 by Main.JustinSchaefer - put it back
 

Copyright © cPanel 2000-2009.