您好,欢迎访问一九零五行业门户网

ngnix 加 php-fpm配置

本篇文章给大家分享的内容是关于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配置 的详细内容。
其它类似信息

推荐信息