Page tree
Skip to end of metadata
Go to start of metadata

 

For cPanel & WHM version 11.50

How do I change the version of PHP on my server?

PHP 5 is the only major version of PHP that cPanel & WHM supports.

You can only install one version of PHP 5 on your server, unless you install a customization (for example, the CloudLinux™ PHP selector).

You can install a different minor version of PHP on your server in WHM's EasyApache (Apache Update) interface (Home >> Software >> EasyApache (Apache Update)). After Apache fully compiles, you can access the new PHP installation.

How can I ensure that the homepage of a folder automatically defaults to the index.php file?

Some lines in the /usr/local/apache/conf/httpd.conf file allow the index.php file to display automatically. If the following lines are present, the index.php file displays:

# DirectoryIndex is set via the WHM -> Service Configuration -> Apache Setup -> DirectoryIndex Priority
DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html

Apache searches for a file that matches one of these names. The search starts with the index.html.var file, searches from left to right, and ends with the home.html file. If a file matches one of those names, the system uses that file. If the index.php file is in the list, Apache uses the the index.php file, unless Apache first reaches a file that matches a name in the /usr/local/apache/conf/httpd.conf file.

If those lines are not present, add the following line to an .htaccess file:

DirectoryIndex index.php

For more information about .htaccess files, read the Apache documentation.

Which PHP modules and plugins does cPanel & WHM support?

You can find a list of supported modules and plugins in our EasyApache documentation.

How can I add or remove support for features like PHP or Java server pages on my Apache webserver?

You can add or remove support for features from the Apache webserver with WHM's EasyApache (Apache Update) interface (Home >> Software >> EasyApache (Apache Update)).

You can also run EasyApache from the command line with the /scripts/easyapache command.

cPanel & WHM with PHP 5

Remember:

cPanel & WHM no longer supports PHP 4. We strongly recommend that you update your site scripts to a version that is compatible with PHP 5.

Note:

You can download and install PHP 4 as an unsupported custom optional module.

How do I upgrade from PHP 4 to PHP 5, and what changes do I need to make?

To upgrade from PHP 4 to PHP 5, recompile PHP during the Apache build process. You can start the Apache build process in WHM's  EasyApache (Apache Update) interface (Home >> Software >> EasyApache (Apache Update)), or from the command line with the /scripts/easyapache command.

Make certain that the PHP programs and scripts that you plan to run are compatible with PHP 5.

Which version of PHP 5 runs without problems?

The answer to this question depends on the third-party extensions that you need. For example, the suhosin patch is not compatible with concurrent PHP.

EasyApache resolves some dependency issues before the build. This process skips extensions that are incompatible, to lessen the problems if a user ignores the warning in the interface.

Which PHP version shows in the end user's cPanel interface?

The cPanel interface displays information for the system's default version of PHP.

How can cPanel users choose to use a specific version of PHP?

cPanel users must rename scripts to choose a specific version of PHP. For example, if the administrator specifies PHP 5 as the default, and the cPanel user's scripts need PHP 4, the PHP 4 handler executes scripts that are renamed with the .php4 file extension.

cPanel users can override these settings via .htaccess files.

Note:

We do not recommend that the end user use .htaccess files to override.

The administrator can use VirtualHost Includes to specify overrides. To do this, include a configuration file in the vhost.

The following example includes a configuration file in the vhost:

Include "/usr/local/apache/conf/userdata/std/2/user/custom.conf"

 Place the configuration file in either of the following directories:

/usr/local/apache/conf/userdata/std/2/
/usr/local/apache/conf/userdata/std/2/user/

Notes:

  • In the above examples, /user/ represents your username.
  • You may need to create these directories. After you create them, execute the /scripts/ensure_vhost_includes script. Add the --help flag to explain the use of the script.

Remember:

The specific Addhandler MIME types that you use for overrides depend upon the specific PHP setup and handler configuration.