I just found two executable files, php-cgi.exe
and php.exe
in the bin
folder of the WAMP server on my laptop. I am learning PHP and could not figure out the difference. What is difference between them?
It is a specification “protocol” for transferring information between a Web server and a CGI program. A CGI program is any program designed to accept and return data that conforms to the CGI specification. Basically, it's a way to run a server-side script (PHP, Perl, Python) when an HTTP request comes.
PHP's Command Line Interface (CLI) allows you to execute PHP scripts when logged in to your server through SSH. ServerPilot installs multiple versions of PHP on your server so there are multiple PHP executables available to run.
php-fpm ist running in its own process all the time. It can use apc because it uses continuously the ram over several requests. The memory is only released through the garbage collector or if you kill the fpm process. But the a CLI process lives only for one command and when its finished the memory is released.
By default, PHP is built as both a CLI and CGI program, which can be used for CGI processing. If you are running a web server that PHP has module support for, you should generally go for that solution for performance reasons.
php-cli is meant for running PHP on the command line. php-cgi does additional things for you, such as HTTP headers and certain security modifications. Having said that, consider installing a FastCGI module and using PHP's FastCGI interface.
This is equal to the CLI version, except that php-win doesn't output anything and thus provides no console (no "dos box" appears on the screen). This behaviour is similar to PHP GTK. Show activity on this post. CGI: (common gateway interface) It is a specification "protocol" for transferring information between a Web server and a CGI program.
Unlike the PHP-CLI which is a command line interface for PHP to allows Users to interact with PHP via terminal. mod_php: an Apache module to run PHP. It execute PHP scripts inside the Web Server directly as part of the web server without communicating with a CGI program.
It runs as a standalone FastCGI server. In general it's a PHP interface for the web servers (Apache, Nginx..) to allows Web Server to interact with PHP. Unlike the PHP-CLI which is a command line interface for PHP to allows Users to interact with PHP via terminal.
From http://www.php-cli.com/php-cli-cgi.shtml
These are the most important differences between CLI and CGI:
This might give you a broader understanding of their difference:
CGI: (common gateway interface) It is a specification "protocol" for transferring information between a Web server and a CGI program.
A CGI program is any program designed to accept and return data that conforms to the CGI specification.
Basically it's a way to run a server side script (PHP, Perl, Python,...) when a HTTP request comes.
CGI is very slow in comparison to other alternatives.
FastCGI: is a better CGI.
Fast CGI is a different approach with much faster results.
It is a CGI with only a few extensions.
FastCGI implementation isn’t available anymore, in favor of the PHP-FPM.
PHP-FPM: (FastCGI Process Manager), it's a better FastCGI implementation than the old FastCGI.
It runs as a standalone FastCGI server.
In general it's a PHP interface for the web servers (Apache, Nginx..) to allows Web Server to interact with PHP.
Unlike the PHP-CLI which is a command line interface for PHP to allows Users to interact with PHP via terminal.
mod_php: an Apache module to run PHP.
It execute PHP scripts inside the Web Server directly as part of the web server without communicating with a CGI program.
mod_SuPHP: is similar to mod_php but can change the user/group that the process runs under.
Basically it address some problems of mod_php related to permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With