登录  /  注册

ngnix 加 php-fpm配置

不言
发布: 2018-04-09 16:48:06
原创
1430人浏览过

本篇文章给大家分享的内容是关于ngnix 加 php-fpm配置 ,有需要的朋友可以参考一下

文章参考: https://www.cnblogs.com/f-ck-need-u/p/7627035.html

nginx 502 参考 : https://blog.csdn.net/wzqzhq/article/details/53320533

cygwin启动脚本

#!/bin/bash
for i in `ps x | grep php-fpm | awk '{print $1 }'`;do kill -9 $i;done
/usr/sbin/php-fpm.exe
#/usr/sbin/php-fpm restart

#/usr/sbin/nginx.exe -s reload
#netstat -anpo | grep "php-cgi" | wc -l
#awk -F: '{print NR,NF,$NF,"\t",$0}' /etc/passwd   //依次打印行号,字段数,最后字段值,制表符,每行内容


#/usr/sbin/nginx -s reload
for i in `ps x | grep nginx | awk '{print $1}'`;do kill -9 $i;done
/usr/sbin/nginx >> /var/log/nginx.log.new 2>&1 && echo $?
登录后复制

nginx 配置

user www;
worker_processes  4;
worker_rlimit_nofile 30000;

error_log  /usr/local/nginx/logs/error.log;
pid        /usr/local/nginx/logs/nginx.pid;

events {
    use epoll;
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log /usr/local/nginx/logs/access.log;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  75;
    tcp_nodelay        on;

    gzip  on;
    gzip_min_length  512;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_buffers     4 8k;
    gzip_types       text/html text/xml text/plain application/x-javascript text/css application/xml;

    server_names_hash_bucket_size 128;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;

    include /usr/local/nginx/conf/sites-enabled/*;
}
登录后复制

sites-enabled/test.com 配置

server {
        listen   80;
        #listen   443 ssl;

        #ssl_certificate      /etc/cert/test.com.chained.crt;
        #ssl_certificate_key  /etc/cert/test.com.key;

        server_name      test.com;
        access_log       /usr/local/nginx/logs/$host.log;

        set $server_root /home/test/root;

        root  $server_root;

        location / {
                index  index.php index.htm index.html;
                if (!-f $request_filename) {
                        rewrite  ^/(.*)_v=* /$1  last;
                }
        }

        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $server_root$fastcgi_script_name;
                include /usr/local/nginx/conf/fastcgi_params;
        }

        location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma|json|xml)$ {
                expires 7d;
        }
}
登录后复制

2. php-fpm 配置

pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
; pool name ('www' here)
[www]
listen = 127.0.0.1:9000
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives:
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 50

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 20
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 35

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'.
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/local/php5)

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;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
request_terminate_timeout = 300
登录后复制

相关推荐:

php配置php-fpm启动参数及配置详

php版本切换的详细过程和线上Linux环境下常见php-fpm常见问题

PHP-FPM中两种进程管理模式

以上就是ngnix 加 php-fpm配置 的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
关于CSS思维导图的课件在哪? 课件
凡人来自于2024-04-16 10:10:18
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号