This article explains how to enable or disable PHP properties for a specific account on a Linux dedicated server with cPanel/WHM.
Important: The configuration method depends on how PHP is implemented on your server: PHPSuExec / CGI, Apache module, or FastCGI. First identify which one you use before editing files.
Determine the PHP Implementation Type
- Connect via SSH with the
rootuser (see the SSH access article in this category). - Enter an account's web directory, for example:
cd /home/USER/public_html
- Create a
phpinfo.phpfile with this content:<?php phpinfo(); ?>
With
vi: runvi phpinfo.php, pressito insert, paste the code, pressEsc, type:wqand Enter. - Assign permissions and owner to the file (replace
USERwith the account):chown USER:USER phpinfo.php chmod 644 phpinfo.php
- Open in browser:
http://yourdomain.com/phpinfo.php - Look for the Server API line and note the value.
| Server API Value | Implementation |
|---|---|
| CGI / CGI/FastCGI | PHPSuExec or similar environment → use php.ini per directory. |
| Apache, Apache 2.0 Handler or another Apache variant | PHP as Apache module → use .htaccess. |
| FastCGI | Configuration in cgi-bin + .htaccess (see FastCGI section). |
Security: Delete phpinfo.php when you finish verifying the implementation. Do not leave it published in production.
Configuration with PHPSuExec / CGI (php.ini file)
Place a php.ini file inside the web directory where you want to apply the changes (e.g. public_html).
Note: php.ini directives are not recursive. If you need different values in subfolders, create a php.ini in each directory.
Syntax:
directive = value ; Examples: display_errors = Off memory_limit = 256M max_execution_time = 120 upload_max_filesize = 64M
Configuration with Apache Module (.htaccess file)
Edit or create the .htaccess file in the account's public_html.
Syntax:
php_flag directive value php_value directive value ; Examples: php_flag display_errors Off php_value memory_limit 256M php_value max_execution_time 120
Attention: php_flag and php_value only work if PHP runs as an Apache module. If your Server API is CGI, these directives in .htaccess can cause a 500 error.
Configuration with FastCGI
- Enter the account's
cgi-bindirectory:cd /home/USER/public_html/cgi-bin
- Copy the global
php.iniand adjust permissions:cp /usr/local/lib/php.ini . chown USER:USER php.ini
- Create the
php5.fcgifile with this content:#!/bin/sh export PHP_FCGI_CHILDREN=1 export PHP_FCGI_MAX_REQUESTS=10 exec /usr/local/cpanel/cgi-sys/php5
- Assign owner and execution permissions:
chown USER:USER php5.fcgi php.ini chmod 755 php5.fcgi
- Add these lines to the
public_html.htaccess:AddHandler php5-fastcgi .php Action php5-fastcgi /cgi-bin/php5.fcgi
- Edit the necessary directives in the
php.inicopied tocgi-bin.
Verify that changes applied
- Check
phpinfo.phpagain and look for the modified directive in the Local Value table. - If the site returns a 500 error after editing
.htaccessorphp.ini, revert the last change and test one directive at a time. - On servers with recent cPanel, you can also check MultiPHP INI Editor from WHM or cPanel before editing files manually.
Common issues
- 500 Error when saving .htaccess: you are probably using Apache module directives in a CGI environment; switch to the
php.inimethod. - Changes do not apply: verify that the file is in the correct directory and that there is no other
php.inior.htaccessin a subfolder with different priority. - FastCGI does not execute: check
755permissions onphp5.fcgiand make sure the path/usr/local/cpanel/cgi-sys/php5exists in your cPanel version. - Directive not allowed: some options are locked globally in WHM (PHP Configuration Editor).
If you cannot identify the PHP implementation, a directive does not apply, or the site becomes inaccessible after the changes, open a ticket from the client portal or consult via the site's online chat.
