SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Optimización de servidor web
Con
Nginx y PHP-FPM
Yannick Warnier
@ywarnier
http://t3n.de/news/wp-content/uploads/2016/03/nginx-hoster-benchmark-nginx-vs-apache.jpg
PHP-FPM
● FastCGI Process Manager
● Implementación alternativa de PHP FastCGI
● Con funcionalidades adicionales utiles para sitios de
todos tamaños, en particular sitios muy activos
● Integrado en PHP desde PHP 5.4 en Nov 2011
PHP-FPM
● Gestión de procesos avanzada
● Posibilidad workers con uid/ambientes distintos
● ...y php.ini distintos
● Soporte de upload acelerado
● Slow log
● ...
PHP-FPM + Nginx
Apache + modPHP
Apache
HDD / SSD
DB
Mod-PHP
Apache + modPHP
Apache
HDD / SSD
DB
Mod-PHP
Apache + modPHP
Apache
HDD / SSD
DB
Mod-PHP
Apache + modPHP
Apache
HDD / SSD
DB
Mod-PHP
Nginx + PHP-FPM
Nginx
HDD / SSD
DB
PHP-FPM
PHP-FPM
PHP-FPM
Nginx + PHP-FPM
Nginx
HDD / SSD
DB
PHP-FPM
PHP-FPM
PHP-FPM
Nginx + PHP-FPM
Nginx
Asíncrono
HDD / SSD
DB
PHP-FPM
PHP-FPM
PHP-FPM
Nginx + PHP-FPM
Nginx
Asíncrono
HDD / SSD
DB
PHP-FPM
PHP-FPM
PHP-FPM
Nginx + PHP-FPM
Nginx
Asíncrono
HDD / SSD
DB
PHP-FPM
PHP-FPM
PHP-FPM
Instalar PHP-FPM
Configurar PHP-FPM
user@server:~$ sudo vim /etc/php/7.1/fpm/
conf.d/       php­fpm.conf  php.ini       pool.d/   
user@server:~$ sudo vim /etc/php/7.1/fpm/php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
Configurar PHP-FPM
user@server:~$ sudo vim /etc/php/7.1/fpm/pool.d/www.conf
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; …
user = www­data
group = www­data
; …
listen = /run/php/php7.1­fpm.sock
listen.owner = www­data
listen.group = www­data
; …
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 10s;
Configurar PHP-FPM
user@server:~$ sudo vim /etc/php/7.1/fpm/pool.d/www.conf
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 10s;
pm.max_requests = 500
access.log = log/$pool.access.log
slowlog = log/$pool.log.slow
request_slowlog_timeout = 0
Configurar PHP-FPM
user@server:~$ sudo vim /etc/php/7.1/fpm/pool.d/www.conf
;php_admin_value[sendmail_path] = /usr/sbin/sendmail ­t 
­i ­f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm­php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
En resumen: todo por defecto!
Configurar Nginx
- sudo apt-get install nginx-full
- sudo vim /etc/nginx/nginx.conf
user www­data;
worker_processes auto;
pid /run/nginx.pid;
events {
    worker_connections 768;
    # multi_accept on;
}
Configurar Nginx
- sudo apt-get install nginx-full
- sudo vim /etc/nginx/nginx.conf
http {
    ##
    # Basic Settings
    ##
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
Configurar Nginx
- sudo apt-get install nginx-full
- sudo vim /etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    index index.html index.htm index.nginx­debian.html;
    server_name _;
    location / {
        try_files $uri $uri/ =404;
    }
Configurar Nginx
- sudo apt-get install nginx-full
- sudo vim /etc/nginx/sites-available/default
server {
    # ...
    # pass the PHP scripts to FastCGI server
    # listening on 127.0.0.1:9000
    #
    location ~ .php$ {
       include snippets/fastcgi­php.conf;
       # With php7.1­fpm:
       fastcgi_pass unix:/run/php/php7.1­fpm.sock;
    }
Configurar Nginx
- sudo service php-fpm restart
- sudo service apache2 stop (si tiene Apache)
- sudo service nginx restart
Ventajas
- Asíncrono (libevent)
- Balanceador de carga (directiva “upstream”)
- Reverse Proxy (caché)
- Soporte SSL completo
- Soporte moderación
- limit_conn / limit_conn_zone
- limit_rate
- limit_req / limit_req_zone
- max_conns (upstream)
- queue
- Compresión
@ywarnier
BeezNest

Mais conteúdo relacionado

Mais procurados

Mais procurados (12)

Arduino presentation by_warishusain
Arduino presentation by_warishusainArduino presentation by_warishusain
Arduino presentation by_warishusain
 
Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino Microcontroller
 
Pll
PllPll
Pll
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
Cascade and cascode amplifiers
Cascade and cascode amplifiersCascade and cascode amplifiers
Cascade and cascode amplifiers
 
Varactor theory
Varactor theoryVaractor theory
Varactor theory
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino Programming
 
Introduction to Raspberrypi
Introduction to  RaspberrypiIntroduction to  Raspberrypi
Introduction to Raspberrypi
 
Intro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino UnoIntro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino Uno
 
Esp8266 NodeMCU
Esp8266 NodeMCUEsp8266 NodeMCU
Esp8266 NodeMCU
 
lecture5.ppt
lecture5.pptlecture5.ppt
lecture5.ppt
 
ppt on IC [Integrated Circuit]
ppt on IC [Integrated Circuit]ppt on IC [Integrated Circuit]
ppt on IC [Integrated Circuit]
 

Semelhante a Introducción a Nginx y PHP FPM

Speed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PGSpeed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PG
Marcus Sá
 
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
MagentoImagine
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yum
Walter Liu
 

Semelhante a Introducción a Nginx y PHP FPM (20)

Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPS
 
Maximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXMaximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINX
 
20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I
 
Speed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PGSpeed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PG
 
Sofia WP User Group Presentation
Sofia WP User Group PresentationSofia WP User Group Presentation
Sofia WP User Group Presentation
 
PHP and FastCGI Performance Optimizations
PHP and FastCGI Performance OptimizationsPHP and FastCGI Performance Optimizations
PHP and FastCGI Performance Optimizations
 
Drupal 8 and NGINX
Drupal 8 and NGINX Drupal 8 and NGINX
Drupal 8 and NGINX
 
PHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on NginxPHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on Nginx
 
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
 
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
Magento's Imagine eCommerce Conference 2011 - Hosting Magento: Performance an...
 
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yum
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Magento caching
Magento cachingMagento caching
Magento caching
 
Last Month in PHP - June 2016
Last Month in PHP - June 2016Last Month in PHP - June 2016
Last Month in PHP - June 2016
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam RuzickaOSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
 

Mais de Yannick Warnier

Crear cursos-virtuales-chamilo-flisol-2014
Crear cursos-virtuales-chamilo-flisol-2014Crear cursos-virtuales-chamilo-flisol-2014
Crear cursos-virtuales-chamilo-flisol-2014
Yannick Warnier
 
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
Yannick Warnier
 

Mais de Yannick Warnier (20)

Chamilo, 12 ans déjà
Chamilo, 12 ans déjàChamilo, 12 ans déjà
Chamilo, 12 ans déjà
 
Chamilo en FLISOL Perú 2018
Chamilo en FLISOL Perú 2018Chamilo en FLISOL Perú 2018
Chamilo en FLISOL Perú 2018
 
Novedades de PHP 7.*
Novedades de PHP 7.*Novedades de PHP 7.*
Novedades de PHP 7.*
 
The benefits of using Git
The benefits of using GitThe benefits of using Git
The benefits of using Git
 
Skillms, solution de gestion des talents
Skillms, solution de gestion des talentsSkillms, solution de gestion des talents
Skillms, solution de gestion des talents
 
Chamilo "Lectoura", proyecto Hackaton EdTech, Lima 2017
Chamilo "Lectoura", proyecto Hackaton EdTech, Lima 2017Chamilo "Lectoura", proyecto Hackaton EdTech, Lima 2017
Chamilo "Lectoura", proyecto Hackaton EdTech, Lima 2017
 
Novedades de Chamilo 1.11 - 2017
Novedades de Chamilo 1.11 - 2017Novedades de Chamilo 1.11 - 2017
Novedades de Chamilo 1.11 - 2017
 
Chamilo, qu'est-ce? - Chamilo Camp Lyon 2017
Chamilo, qu'est-ce? - Chamilo Camp Lyon 2017Chamilo, qu'est-ce? - Chamilo Camp Lyon 2017
Chamilo, qu'est-ce? - Chamilo Camp Lyon 2017
 
L'avenir de Chamilo - 2017
L'avenir de Chamilo - 2017L'avenir de Chamilo - 2017
L'avenir de Chamilo - 2017
 
Desarrollo del plugin Chamilo-Wordpress
Desarrollo del plugin Chamilo-WordpressDesarrollo del plugin Chamilo-Wordpress
Desarrollo del plugin Chamilo-Wordpress
 
Calidad de código en Chamilo: Behat, Travis-CI y Scrutinizer-CI
Calidad de código en Chamilo: Behat, Travis-CI y Scrutinizer-CICalidad de código en Chamilo: Behat, Travis-CI y Scrutinizer-CI
Calidad de código en Chamilo: Behat, Travis-CI y Scrutinizer-CI
 
Como usar un aula virtual como recurso educativo - Caso Chamilo
Como usar un aula virtual como recurso educativo - Caso ChamiloComo usar un aula virtual como recurso educativo - Caso Chamilo
Como usar un aula virtual como recurso educativo - Caso Chamilo
 
Asociación Chamilo
Asociación ChamiloAsociación Chamilo
Asociación Chamilo
 
Crear cursos-virtuales-chamilo-flisol-2014
Crear cursos-virtuales-chamilo-flisol-2014Crear cursos-virtuales-chamilo-flisol-2014
Crear cursos-virtuales-chamilo-flisol-2014
 
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
Chamilo LMS y otros LMSes - Universidad de Valencia, España - Octubre 2013
 
Prepa certificación docente Chamilo 1.8 (CHACOBU)
Prepa certificación docente Chamilo 1.8 (CHACOBU)Prepa certificación docente Chamilo 1.8 (CHACOBU)
Prepa certificación docente Chamilo 1.8 (CHACOBU)
 
Chamilo advantages against other LMSes
Chamilo advantages against other LMSesChamilo advantages against other LMSes
Chamilo advantages against other LMSes
 
Taller de optimizacion de servidores web tipo LAMP
Taller de optimizacion de servidores web tipo LAMPTaller de optimizacion de servidores web tipo LAMP
Taller de optimizacion de servidores web tipo LAMP
 
Chamilo, c'est pas le Pérou - Jeudis du libre
Chamilo, c'est pas le Pérou - Jeudis du libreChamilo, c'est pas le Pérou - Jeudis du libre
Chamilo, c'est pas le Pérou - Jeudis du libre
 
TICs en educación y Chamilo, introducción para Maestria en Edumática, 2011
TICs en educación y Chamilo, introducción para Maestria en Edumática, 2011TICs en educación y Chamilo, introducción para Maestria en Edumática, 2011
TICs en educación y Chamilo, introducción para Maestria en Edumática, 2011
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

Introducción a Nginx y PHP FPM