Child pages
  • Configure PHP and suEXEC

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Include Page
LIB:_Version
LIB:_Version

(WHM >> Home >> Service Configuration >> Configure PHP and SuExec)

Table of Contents
stylenone

Overview

This interface allows you to change Apache’s PHP handlers configuration, PHP version, and enable or disable suEXEC.

Warning
titleWarning:

This interface only appears if your server runs EasyApache 3. We strongly recommend that you upgrade your server to run EasyApache 4.

In EasyApache 4, you can perform the actions that this document describes in the following interfaces:

Change the default PHP version

You can define which version of PHP the system uses when Apache serves a .php file.

To change the default PHP version, select the version of PHP that you wish to use from the Default PHP Version (.php files) menu and click Save New Configuration. 

Enable or disable Apache suEXEC

When you enable suEXEC, Apache runs CGI software as the account owner rather than as the nobody user.

To enable or disable suEXEC, select on or off from the Apache suEXEC menu and click Save New Configuration.

To test your new configuration, select the Do a dryrun checkbox. This feature allows you to verify the new configuration before deployment. After you click Save New Configuration, click Apply Settings in the following interface to apply the new settings to your PHP configuration.

Warning
titleWarning:

Apache suEXEC differs from PHP suEXEC. Apache suEXEC only pertains to PHP that CGI handles.

Define a PHP handler

A PHP handler calls the PHP libraries that the system requires to interpret the PHP code. The handler that you choose determines the libraries that the system accesses. You may assign different PHP handlers to different versions of PHP.

Note
titleNote:

If you build Apache without PHP, the interface will not display any handlers in the menu.

To define new PHP handlers, perform the following steps:

  1. Select the handlers that you wish to handle one or both versions of PHP.
  2. In the PHP 5 Handler menu, select the handler that you wish to use.
  3. Click Save New Configuration.

Migrate from DSO to suPHP

Note
titleNote:

For more information about PHP handlers, read our PHP Handlers documentation.

To migrate from DSO to suPHP, perform the following steps: 


 

Section


Column
width72px


Column

Configure WHM for suPHP

In the PHP 5 Handler menu, select suPHP and click Save Configuration.


 


 

Section


Column
width72px


Column

Update permissions and ownership

To update file permissions and ownership, perform the following changes inside each user's public_html directory:

  • Change the permissions of files to 644 and directories to 755.
  • Change the ownership of the files and directories within the public_html directory to user:user.

    Warning
    titleWarnings:
    • Do  not  change the  public_html  directory owner. The public_html  directory defaults to the   user:nobody owner .
    • Do not make any changes to the directory itself.
    • If you change ownership or permissions of files outside of the public_html directory, you may cause problems with other aspects of the account, such as mail.



 


 

Section


Column
width72px


Column

Edit the .htaccess files

If you previously allowed PHP customizations through .htaccess files, you must remove or comment out all php_value or php_flag settings in the user .htaccess files.

Warning
titleWarning:

We strongly recommend that you perform a backup before you make changes to your .htaccess files.

Run the following commands to remove the php_value and php_flag settings from the .htaccess files:

Code Block
languageperl
linenumberstrue
find /home -type f -name '.htaccess' -exec grep -Hrn 'php_value' '{}' \;
find /home -type f -name '.htaccess' -exec grep -Hrn 'php_flag' '{}' \;



 


 

Section


Column
width72px


Column

PHP customizations

To allow PHP customization, create a custom php.ini file in the user's directory.

To create a custom php.ini file, perform the following steps:

  1. Copy the server's /usr/local/lib/php.ini to the user's home directory.
  2. Add the new values to the user's php.ini file.

    Warning
    titleWarning:

    If an invalid php.ini file resides in the user's directory, suPHP defaults to the php.ini file in the /usr/local/lib/ directory.


  3. For each directory that contains  PHP  scripts that require the custom settings, add  suPHP_ConfigPath /home/username/  to the  .htaccess  file in the folder that contains the  PHP  script.


Additional documentation

Localtab Group


Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","suexec") and label = "whm" and space = currentSpace()


Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","suexec") and label = "cpanel" and space = currentSpace()


Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","suexec") and label = "whm" and space in (currentSpace(),"CKB")


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","suexec") and space = "DD"