PHP-FPM performance optimization, PHP-FPM performance Optimization _php Tutorial

Source: Internet
Author: User
Tags configuration php php error php error log stop script python script

PHP-FPM for performance optimization and PHP-FPM performance optimization


Brief introduction:

PHP-FPM is a PHP FastCGI manager, General Nginx above the PHP program will throw PHP program to PHP-FPM to parse. All right, that's it!

PHP 5.4 began to integrate the PHP-FPM, that is, when compiling PHP, as long as the--ENABLE-FPM installed PHP-FPM.

First, install the PHP-FPM

Shell >./configure--prefix=/usr/local/php \--with-config-file-path=/usr/local/php--with-mysql=/usr/local/ mysql/\--with-mysqli=/usr/local/mysql/bin/mysql_config--with-gd--with-xsl--with-bz2 \--with-zlib--with-curl-- With-pear--without-iconv--with-mcrypt \--with-gettext--with-openssl--with-libxml-dir--with-png-dir-- With-jpeg-dir--with-freetype-dir \--with-libdir=lib64--enable-ftp--enable-fpm--enable-opcache--enable-exif-- Enable-soap--enable-bcmath--enable-calendar \--enable-sockets--enable-mbstring--enable-gd-native-ttf-- Disable-rpath--disable-debug

# # See above this heap of parameters No, this is in compiling PHP, where there is a parameter is--ENABLE-FPM Yes, this is the Enable PHP-FPM extension.

Shell > make; Make install

Second, the configuration php-fpm

Shell > Cp/usr/local/src/php-5.6.17/php.ini-production/usr/local/php/php.ini # This is the PHP configuration file Shell > cp/usr/local/ SRC/PHP-5.6.17/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM # This is PHP-FPM's startup script Shell > Cd/usr/local/php/etc/shell > CP php-fpm.conf.default php-fpm.conf # Copy a configuration file shell > Vim php-fpm.conf[global]pid = run/php-fpm.pid # Pidrlimit_f Iles = 65535 # Open file limit [www] # process Pool user = Nginx # run as Nginx # = Nginxlisten = 127.0.0.1:9000 # Listen to the 9000 port of this machine; listen = /dev/shm/php-cgi.sock; # listen to the UNIX socket, and put the socket in the memory space, faster (Nginx also modify)!;listen.backlog = 10240 # UNIX socket is a bit unstable in the way high concurrency, this parameter is used to alleviate (so Cket wait queue length); Listen.owner = The permissions of the Nginx # UNIX SOCKET; listen.group = Nginx;listen.mode = 0660pm = dynamic # The way the process was created, the PM is created dynamically. Max_children = 32 # Maximum number of processes (can not only look at the memory to create, to see the specific usage, sometimes enough memory, the number of processes mostly, resulting in CPU frequent context switching, the load will be high) Pm.start_servers = 5 # initial process number Pm.min_spare _servers = 5 # Minimum number of idle processes pm.max_spare_servers = 10 # maximum idle Process pm.status_path =/php_status # PHP-FPM status Monitor (Nginx to set access rights) Shel L > SErvice php-fpm Start 

third, monitoring php-fpm

Shell > Vim/usr/local/nginx/conf/nginx.conflocation ~/php_status {# Create a separate server or add configuration directly to the server {} Access_log  Off  Allow 127.0.0.1; Allow 36.110.41.194;  # do permissions deny all; Fastcgi_pass 127.0.0.1:9000;  # if it's a UNIX SOCKET, write something like this: Fastcgi_pass Unix:/dev/shm/php-cgi.sock;  Fastcgi_param script_filename $fastcgi _script_name; Include Fastcgi_params;} Shell > Kill-hup ' cat/usr/local/nginx/logs/nginx.pid ' shell > Curl Http://127.0.0.1/php_status # Access this path to get the following data pool:  WWW # process Pool name Process Manager:dynamic # processes managed by Start time:22/jan/2016:15:49:00 +0800 # startup time start since: 375 # Runtime accepted Conn:7 # Number of requests received by the current process pool Listen queue:0 # request waiting queue, if not 0, means that the FPM process is insufficient and requires Increase Max Listen queue:0 # max wait queue number listen Queue len:1024 # SOCKET Wait Queue Length idle Processes:4 # Idle Process Count Active Processes:1 # Active number of processes total Processes:5 # max active PROCESSES:1 # max active process Count Max Childr En reached:0 # achieves maximumNumber of processes, if not 0, means that the maximum number of processes is insufficient, need to increase slow requests:0 # Slow request number, need to set slow Logshell > Curl Http://127.0.0.1/php_status # There are a variety of parameters to choose from, such as: http://127.0.0.1/php_status?html, JSON,? xml,? full

# I want to use a Python script as a monitor, the JSON format is the best!

Articles you may be interested in:

    • Detailed configuration based on PHP-FPM
    • PHP configuration php-fpm startup parameters and configuration details
    • Linux under PHP-FPM turn off use method
    • Nginx Call PHP-FPM Error resolution method and Nginx configuration detailed
    • Implement the configuration method of logging PHP error log when using PHP-FPM in Nginx
    • Nginx and PHP-FPM start-up, restart, stop script sharing
    • Installation and configuration tutorial for PHP-FPM under Linux system

http://www.bkjia.com/PHPjc/1117055.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117055.html techarticle php-fpm performance optimization, PHP-FPM performance Optimization Introduction: PHP-FPM is a PHP FastCGI manager, General Nginx above the PHP program will throw PHP program to PHP-FPM to parse. Good ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.