PHP supports different Server Application Programming Interfaces (SAPI) for environment interaction and connection to non-native technologies. Two of them are PHP CLI and PHP CGI (FastCGI).

As of v. 4.3.0, PHP supports an additional interface called CLI (Command Line Interface) intended to be used in a shell environment.

PHP CLI is used for developing applications in PHP that can be automated with Cron jobs, for administration, testing and other tasks, suitable for shell usage. PHP CLI runs directly in server environment without requesting connection to the web server from the CGI (FastCGI) interface.

Shared hosting and Managed VPS servers by SuperHosting.BG support both interfaces – PHP CGI (FastCGI) and PHP CLI.

PHP CLI differs from other interfaces mainly because of the following reasons:

  • It does not return HTTP headers; it starts with a -q (quiet-mode) option by default, which suppresses HTTP header output (stdout);
  • It does not change its current directory to the directory of the executed script;
  • It uses only plain text error messages. The php.ini directive is set in the following way: html_errors: FALSE. This is due to the fact that reading error messages with HTML tags is quite complicated while working in a shell environment. Hence, HTML formatting has been disabled;
  • Some php.ini directives are overridden for PHP CLI because they do not make sense in shell environments.
    • max_execution_time: 0 (unlimited) does not hold restrictions for script execution time;
    • max_input_time: FALSE – PHP CLI does not support GET, POST or uploading files;

PHP is configured and installed on the server with two separate executable / binary files for CLI and CGI (FastCGI).

 For all PHP versions:
PHP FastCGI/opt/cpanel/ea-phpXX/root/usr/bin/php-cgi
PHP CLI/opt/cpanel/ea-phpXX/root/usr/bin/php
 ea-phpXX – replace with the PHP version,
for example /opt/cpanel/ea-php72/root/usr/bin/php

Note: You can view all the available PHP versions in PHP Manager – cPanel.

PHP settings for the two interfaces differ:

Using a different PHP (cgi/fcgi) version via web

Using a different php.ini file for PHP (cli) via SSH

This article is about: hosting services with cPanel

Updated on 02.04.2022

Was this article helpful?

Related Articles