62
mod_php vs PHP CLI vs FastCGI vs FPM @jacques_thekit

mod_php vs FastCGI vs FPM vs CLI

Embed Size (px)

Citation preview

mod_php vs PHP CLI vs FastCGI vs FPM@jacques_thekit

• Graphic designer turned programmer• PHP/JS Developer 10 years

experience• Have worked in Python, ActionScript,

ColdFusion, others… • Big community supporter• Co-author of virtPHP

The beard is on the way back

Who am I?

Some Questions:Do you know?

Some house keepingWhat is a process?

A process is

A process isAn app answering a request

Request

App

Response

A thread isAn task requested by a process

Request

Process

Response

Thread Thread Thread

What is PHP, really?

C Binary

C Binary

Computer

C Binary

Computer

Request

?

C Binary

Computer

RequestServer

Port

Ready to keep diving?That was the easy part.

How does our server talk to PHP?

C Binary

SAPI

SAPI: Server Application Interface

C Binary

mod_php

FPMCLI

http://www.slideshare.net/auroraeosrose/php-extensions-45834933

Even extensions

What are the types?The rabbit hole keeps going.

mod_php FastCGI FPM CLI

And Others

Starting with CGIApplies both to CGI and FPM

C Binary

Computer

Request

Computer

Request

CGI isolates requests to “locked down” environments

Computer

Request

FastCGI

FastCGI acts as interface to CGI and script

Computer

Request

FPM

FPM = FastCGI Process Manager

How is mod_php different? Apache baby!

mod_php

apache

Request

apache ≠ CGI

apache = web server

and so is nginx

nginx vs apacheThis rabbit needs some white gloves

apache mpm_prefork

apache

apache

Request

apache

Request

Request

apache

Request

nginx

Request Request

nginx

Request Request

Request

nginx

Request

Request

Request

nginx

Request

Request

apache

Request

PHP PHP PHP PHP PHP

apache

PHP PHP PHP PHP PHP

nginx

Request Request

PHP

apache

PHP PHP PHP PHP PHP

nginx

StaticDynamic

Reverse Proxy

Are we done?

sum that up for me

The types of PHP are just APIs for web servers to interface with PHP

The web server you use will most likely determine what type of PHP to use.

You should consider your needs before picking which version of PHP to use.

What about CLI?

CLI is command line SAPIyou know $ php…

$ php -a access interactive shell

$ php -r “echo ‘hi’”;

hi

$ php your_file.php

virtPHP

mod_php vs PHP CLI vs FastCGI vs FPM@jacques_thekit

Resourceshttps://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations http://www.php-cli.com http://php-fpm.org http://php.net/manual/en/install.fpm.php http://www.fastcgi.com/drupal/node/5?q=node/10 http://www.suphp.org/Home.htmlt http://www.sitepoint.com/setting-up-php-behind-nginx-with-fastcgi/ https://www.chriswiegman.com/2011/10/fastcgi-vs-suphp-vs-cgi-vs-mod_php-dso/

mod_php vs PHP CLI vs FastCGI vs FPM@jacques_thekit