bianbian coding life

便便代码人生: 关注技术, 翻译文档, 偶尔动动手

[原]用perl写了个自动配置脚本

Posted by bianbian on 2007-04-08 11:26


本文Tags: , ,

经常要安装各种包,而且每个包的configure参数千差万别;而且以后升级版本或者换个机器装的话又记不得加哪些参数,实在不方便。于是写了个自动配置的脚本。
升级包的版本的时候要把旧版本的目录删除。
我自己用觉得很方便,主要是为了记录configure的参数,省得用到的时候又得找。

配置:
在@list里面第1行写好包的前缀名(省去版本,能grep出唯一结果即可);紧接一行是configure的参数

使用:
./autoConfigure.pl <参数>
<参数>:make(每个目录调用make);install(每个目录调用make install);其他(每个目录configure)

第二次用perl,写得烂不要见效。

  1. #!/usr/bin/perl
  2.  
  3. # AutoConfigure
  4. # first line:  name to match, like nginx-
  5. # second line: configure parameters
  6. @list = (
  7.   "nginx-",
  8.   "--prefix=/home/nginx --without-http_browser_module"
  9.   ,
  10.   "fcgi-",
  11.   "--prefix=/usr"
  12. );
  13.  
  14. # -------- below need not to modify --------
  15. for($i=0; $i < @list; $i += 2) {
  16.   $cmd = "ls -d */ | grep \"$list[$i]\" |";
  17.   open (PIPE, $cmd);
  18.   @out = <PIPE>;
  19.   chomp($out[0]); #chop \n
  20.   $cmd = "cd " . $out[0] . "; ";
  21.   if ($ARGV[0] eq "make") {
  22.     $cmd .= "make";
  23.   } elsif ($ARGV[0] eq "install") {
  24.     $cmd .= "make install";
  25.   } else {
  26.     $cmd .= "./configure " . $list[$i + 1];
  27.   }
  28.   close PIPE;
  29.   $cmd .= "; cd ..";
  30.   system($cmd);
  31. }
标签: , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Linux, Technology | No Comments »

[译]nginx的worker_processes设为多少才合适?

Posted by bianbian on 2007-04-06 09:49


本文Tags: , ,

搜索到原作者的话:
一般一个进程足够了,你可以把连接数设得很大。如果有SSL、gzip这些比较消耗CPU的工作,而且是多核CPU的话,可以设为和CPU的数量一样。或者要处理很多很多的小文件,而且文件总大小比内存大很多的时候,也可以把进程数增加,以充分利用IO带宽(主要似乎是IO操作有block)。

As a general rule you need the only worker with large number of
worker_connections, say 10,000 or 20,000.

However, if nginx does CPU-intensive work as SSL or gzipping and
you have 2 or more CPU, then you may set worker_processes to be equal
to CPU number.

Besides, if you serve many static files and the total size of the files
is bigger than memory, then you may increase worker_processes to
utilize a full disk bandwidth.

Igor Sysoev

经我实践配置,多cpu+gzip+N多小文件+文件总大小大大超过内存 的环境(BBS啦~),设置为cpu的两倍较好。(不过一个nginx是4.3M噢)

标签: , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Linux, Technology | 2 Comments »