User Tools

Site Tools


nginxarchitecture

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nginxarchitecture [2017/03/24 05:55] – [nginx architecture] adminnginxarchitecture [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== nginx with PHP-FPM architecture ======+====== nginx with PHP-FPM ======
 refer:  refer: 
   * http://www.aosabook.org/en/nginx.html   * http://www.aosabook.org/en/nginx.html
Line 28: Line 28:
 ===== Optimize nginx configuration for performance and benchmark ===== ===== Optimize nginx configuration for performance and benchmark =====
 refer: refer:
 +  * http://www.freshblurbs.com/blog/2015/11/28/high-load-nginx-config.html
   * http://tweaked.io/guide/nginx/   * http://tweaked.io/guide/nginx/
   * http://wiki.nginx.org/FullExample   * http://wiki.nginx.org/FullExample
Line 139: Line 140:
 => with above benchmarch for static file ab -n 20 -c 4 http://shop.babies.vn/media/js/af1ae2e07ff564e3d1499f7eb7aecdf9.js(size 400k), we can see the problem for performance because the network or bandwidth => with above benchmarch for static file ab -n 20 -c 4 http://shop.babies.vn/media/js/af1ae2e07ff564e3d1499f7eb7aecdf9.js(size 400k), we can see the problem for performance because the network or bandwidth
 ===== PHP-FPM Config and Optimize ===== ===== PHP-FPM Config and Optimize =====
 +refer: 
 +  * https://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/
 +  * https://tweaked.io/guide/nginx/
 +
 **global** config for all pools:<code> **global** config for all pools:<code>
 [global] [global]
Line 194: Line 199:
 (In some case, the php-fpm child processes full memory and can't process the request, these configurations will automatically restart the php-fpm child processes) (In some case, the php-fpm child processes full memory and can't process the request, these configurations will automatically restart the php-fpm child processes)
 ==== PHP-FPM Pools Configuration ==== ==== PHP-FPM Pools Configuration ====
-refer: http://jeremymarc.github.io/2013/04/22/nginx-and-php-fpm-for-performance/ 
 === Basic Config === === Basic Config ===
 Default php-fpm will use pool **[www]** to configuration for all site. In advance, it’s possible to use **different pools** for different sites and **allocate resources very accurately** and even use **different users and groups for every pool**. Following is just example configuration files structure for PHP-FPM pools for three different sites (or actually three different part of same site):<code> Default php-fpm will use pool **[www]** to configuration for all site. In advance, it’s possible to use **different pools** for different sites and **allocate resources very accurately** and even use **different users and groups for every pool**. Following is just example configuration files structure for PHP-FPM pools for three different sites (or actually three different part of same site):<code>
Line 200: Line 204:
 /etc/php-fpm.d/blog.conf /etc/php-fpm.d/blog.conf
 /etc/php-fpm.d/forums.conf /etc/php-fpm.d/forums.conf
-</code> +</code> 
 +Or config in php-fpm.conf<code> 
 +; Relative path can also be used. They will be prefixed by: 
 +;  - the global prefix if it's been set (-p argument) 
 +;  - /onec/php otherwise 
 +;include=etc/fpm.d/*.conf 
 +</code>(Create directory **/onec/php/etc/fpm.d/**)
 Just example configurations for every pool:  Just example configurations for every pool: 
 +  * default pool [www](listen on port 9000)<code>
 +[www]
 +
 +; Per pool prefix
 +; It only applies on the following directives:
 +; - 'access.log'
 +; - 'slowlog'
 +; - 'listen' (unixsocket)
 +; - 'chroot'
 +; - 'chdir'
 +; - 'php_values'
 +; - 'php_admin_values'
 +; When not set, the global prefix (or /onec/php) applies instead.
 +; Note: This directive can also be relative to the global prefix.
 +; Default Value: none
 +;prefix = /path/to/pools/$pool
 +
 +; Unix user/group of processes
 +; Note: The user is mandatory. If the group is not set, the default user's group
 +;       will be used.
 +user = nobody
 +group = nobody
 +
 +; The address on which to accept FastCGI requests.
 +; Valid syntaxes are:
 +;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
 +;                            a specific port;
 +;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
 +;                            a specific port;
 +;   'port'                 - to listen on a TCP socket to all IPv4 addresses on a
 +;                            specific port;
 +;   '[::]:port'            - to listen on a TCP socket to all addresses
 +;                            (IPv6 and IPv4-mapped) on a specific port;
 +;   '/path/to/unix/socket' - to listen on a unix socket.
 +; Note: This value is mandatory.
 +listen = 127.0.0.1:9000
 +
 +</code>
   * /etc/php-fpm.d/site.conf<code>    * /etc/php-fpm.d/site.conf<code> 
 [site] [site]
nginxarchitecture.1490334949.txt.gz · Last modified: 2022/10/29 16:15 (external edit)