LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: eayha

在gentoo上搭建nginx+php+mysql高并发环境

[复制链接]
 楼主| 发表于 2008-10-15 12:32:23 | 显示全部楼层
sir的rp真高!我自己的blog还是先发的 http://silion.72pines.com/2008/1 ... %E7%8E%AF%E5%A2%83/
可怜~~
回复 支持 反对

使用道具 举报

发表于 2008-10-15 17:15:15 | 显示全部楼层
感谢!
照着楼主的指南,还算顺利。起先也碰到了“下载页面”、“403”、“502 Bad Gateway“,还好,胡乱摸了一通nginx.conf就可以了。
nginx.conf
  1. user  nginx nginx;

  2. worker_processes 8;

  3. error_log  /var/log/nginx/error.log  crit;

  4. pid        /var/run/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events {
  8. use epoll;
  9. worker_connections 51200;
  10. }

  11. http
  12. {
  13. include       mime.types;
  14. default_type  application/octet-stream;

  15. #charset  gb2312;
  16.      
  17. server_names_hash_bucket_size 128;
  18. client_header_buffer_size 32k;
  19. large_client_header_buffers 4 32k;
  20.      
  21. sendfile on;
  22. tcp_nopush     on;

  23. keepalive_timeout 60;

  24. tcp_nodelay on;

  25. fastcgi_connect_timeout 300;
  26. fastcgi_send_timeout 300;
  27. fastcgi_read_timeout 300;
  28. fastcgi_buffer_size 64k;
  29. fastcgi_buffers 4 64k;
  30. fastcgi_busy_buffers_size 128k;
  31. fastcgi_temp_file_write_size 128k;

  32. gzip on;
  33. gzip_min_length  1k;
  34. gzip_buffers     4 16k;
  35. gzip_http_version 1.0;
  36. gzip_comp_level 2;
  37. gzip_types       text/plain application/x-javascript text/css application/xml;
  38. gzip_vary on;

  39. #limit_zone  crawler  $binary_remote_addr  10m;

  40. server
  41. {
  42.    listen       80;
  43.    server_name  localhost;
  44.    index index.html index.htm index.php;
  45.    root  /var/www/localhost/htdocs;

  46.    #limit_conn   crawler  20;   
  47.                            
  48.    location ~ .*\.(php|php5)?$
  49.    {      
  50.      #fastcgi_pass  unix:/tmp/php-cgi.sock;
  51.      fastcgi_pass  127.0.0.1:9000;
  52.      fastcgi_index index.php;
  53.      include fastcgi_params;
  54.      fastcgi_param SCRIPT_FILENAME /var/www/localhost/htdocs$fastcgi_script_name;
  55.    }
  56.    
  57.    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  58.    {
  59.      expires      30d;
  60.    }

  61.    location ~ .*\.(js|css)?$
  62.    {
  63.      expires      1h;
  64.    }   
  65. }
  66. }
复制代码


没建www的user,直接用nginx
/usr/bin/php-fastcgi
  1. /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi
复制代码


rewrite规则很敏感么?我这里只是小玩玩,所以没体会 :yun:
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-16 14:42:37 | 显示全部楼层
wordpress  rewrite成功解决自动下载问题,但是mu版本的测试未通过:
[php]
if (!-e $request_filename) {
                 rewrite ^.+/?(/wp-.*) $1 last;
                 rewrite ^.+/?(/.*\.php)$ $1 last;
                 rewrite ^(.+)$ /index.php?q=$1 last;
rewrite ^/.*(/(wp-admin|wp-includes)/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|    tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 las    t;
rewrite ^/.*(/wp-content/(themes|plugins|mu-plugins)/.*\.(html|jpg|jpeg|    gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|    bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|b    z2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-content/blogs.    php?file=$1 last;
  
  }
[/php]

顺便说下我的webbench压力测试结果:
webbench -c 1000 -t 40 myurl
cpu还是会飙到80-90%
可能优化有问题,希望牛人能分享下优化心得。
回复 支持 反对

使用道具 举报

发表于 2008-10-16 20:49:12 | 显示全部楼层
你在同一台机器上运行webserver,又运行webbench吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-17 15:35:27 | 显示全部楼层
那是不会了 这样的话还能叫 压力测试吗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表