Scaling API-first – The story of a global engineering organization
Running PHP on nginx
1. 1 #Dynatrace
Proper
configura-on
for
high
performance
websites
Harald
Zeitlhofer
April
2015
Boost
your
website
by
running
PHP
on
Nginx
@HZeitlhofer
harald.zeitlhofer@dynatrace.com
7. 7 #Dynatrace
PHP
run
modes
Apache
Module
– tradi-onal
approach
– used
for
most
PHP
environments
CGI
– Command
Line
Interface
(CLI)
FastCGI
(PHP-‐FPM)
– PHP
applica-on
server
– Run
mul-ple
PHP
worker
processes
to
serve
CGI
requests
8. 8 #Dynatrace
Nginx
Lightweight
HTTP
server
Fast
especially
at
high
load
Event
based
request
handling
Open
Source
project
(BSD)
by
Igor
Sysoev
Nginx,
Inc.
founded
in
2011
14. 14 #Dynatrace
prefork
mode
one
process
per
request
worker
mode
mul-ple
threads
per
process,
one
per
request
worker
event
mode
event
based
request
handling
21. 21 #Dynatrace
• Communica-on
via
sockets
• TCP
vs
Unix
• Unix
slightly
faster
when
used
on
localhost
• Use
TCP
for
high
load
location ~* .php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;