Chinaunix首页 | 论坛 | 博客
  • 博客访问: 405219
  • 博文数量: 80
  • 博客积分: 885
  • 博客等级: 准尉
  • 技术积分: 917
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-02 11:43
个人简介

人生就是一次旅行,生活就是艺术,人人都是手艺人.

文章分类

全部博文(80)

文章存档

2023年(1)

2022年(5)

2019年(3)

2018年(1)

2017年(6)

2016年(4)

2014年(8)

2013年(20)

2012年(9)

2010年(3)

2009年(17)

2008年(3)

我的朋友

分类: PHP

2017-11-14 14:31:03

与4核心8G的服务器配置为例:
nginx配置:
keepalive_timeout  0;
php配置:
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.huge_code_pages=1
opcache.file_cache=/tmp 
php-fpm配置:
pm = dynamic
pm.max_children = 1200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 1000
request_terminate_timeout = 30
rlimit_files = 102400
当然以上是关键配置,其它配置在网上很多如下:
user   www www;
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000;
error_log   /www/log/nginx_error.log   crit;
pid         /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 65535;
 
events
{
   use epoll;
   worker_connections 65535;
}
 
http
{
   include       mime.types;
   default_type   application/octet-stream;
 
   charset   utf-8;
 
   server_names_hash_bucket_size 128;
   client_header_buffer_size 2k;
   large_client_header_buffers 4 4k;
   client_max_body_size 8m;
 
   sendfile on;
   tcp_nopush     on;
 
   keepalive_timeout 60;
 
   fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2
                 keys_zone=TEST:10m
                 inactive=5m;
   fastcgi_connect_timeout 300;
   fastcgi_send_timeout 300;
   fastcgi_read_timeout 300;
   fastcgi_buffer_size 16k;
   fastcgi_buffers 16 16k;
   fastcgi_busy_buffers_size 16k;
   fastcgi_temp_file_write_size 16k;
   fastcgi_cache TEST;
   fastcgi_cache_valid 200 302 1h;
   fastcgi_cache_valid 301 1d;
   fastcgi_cache_valid any 1m;
   fastcgi_cache_min_uses 1;
   fastcgi_cache_use_stale error timeout invalid_header http_500; 
   open_file_cache max=204800 inactive=20s;
   open_file_cache_min_uses 1;
   open_file_cache_valid 30s; 
 
   tcp_nodelay on;
   
   gzip on;
   gzip_min_length   1k;
   gzip_buffers     4 16k;
   gzip_http_version 1.0;
   gzip_comp_level 2;
   gzip_types       text/plain application/x-javascript text/css application/xml;
   gzip_vary on;
 
   server
   {
     listen       8080;
     server_name   huan.shouyiren.net;
     index index.php index.htm;
     root   /www/html/;
 
     location /status
     {
         stub_status on;
     }
 
     location ~ .*\.(php|php5)?$
     {
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         include fcgi.conf;
     }
 
     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
     {
       expires       30d;
     }
 
     log_format   access   '$remote_addr - $remote_user [$time_local] "$request" '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent" $http_x_forwarded_for';
     access_log   /www/log/access.log   access;
 
}
/etc/sysctl.conf配置如下:
vm.swappiness = 0
vm.nr_hugepages=512
vm.max_map_count= 655360


net.ipv4.neigh.default.gc_stale_time=120
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.all.arp_announce=2
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.eth0.rp_filter = 0


net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096        87380   4194304
net.ipv4.tcp_wmem = 4096        16384   4194304
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216




net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 30 
net.ipv4.tcp_keepalive_probes = 3 
net.ipv4.tcp_keepalive_intvl = 15 
net.ipv4.ip_local_port_range = 1024 65000 
net.ipv4.tcp_max_syn_backlog = 262144 
net.ipv4.tcp_max_tw_buckets = 20000 
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
阅读(1424) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~