bianbian coding life

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

Archive for the 'Linux' Category

Linux…

[原] 减小nginx编译后的文件大小 (Reduce file size of nginx)

Posted by bianbian on 2008-03-13 10:21


本文Tags: , , ,

默认的nginx编译选项里居然是用debug模式(-g)的(debug模式会插入很多跟踪和ASSERT之类),编译以后一个nginx有好几兆。
去掉nginx的debug模式编译,编译以后只有375K(nginx-0.5.33, gcc4)。
在 auto/cc/gcc,最后几行有:
# debug
CFLAGS=”$CFLAGS -g”
注释掉或删掉这几行,重新编译即可。-g参数用法详见这篇blog:[原]Linux下的c/c++ GDB调试

Nginx uses debug mode (-g) in compiling by default, which result in several MB of it’s size.
After debug disabled, the file size of nginx reduced to 375K (nginx-0.5.33, gcc4).
open auto/cc/gcc, find this at last several lines:
# debug
CFLAGS=”$CFLAGS -g”
delete it, and recompile. More of -g: Linux c/c++ GDB debug

标签: , , ,

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

相关日志

Posted in C/C++, Linux, Technology | No Comments »

[原] Slackware忘记root密码的解决

Posted by bianbian on 2008-02-04 12:32


本文Tags: , ,

除了用光盘外,如果使用LILO(默认)作引导,还有如下办法:
出现LILO选择画面时,输入:“Linux init=/bin/bash rw”
开头的”Linux”对应LILO里的label(名称)
引导后出现如下的提示符:
bash-3.00#
运行passwd命令输入新密码即可

有人问这不是很不安全吗?Faint啊,人家都到机器旁边了,要硬盘有硬盘…

标签: , ,

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

相关日志

Posted in Linux, Technology | No Comments »

[原]qmail+vpopmail+maildrop+SpamAssassin遇到的错误及解决

Posted by bianbian on 2008-01-05 12:28


本文Tags: , , , ,

这几天这是多灾多难,修复烂系统真是考验人阿。。。。。。下面把Qmail的错误及解决汇总一下:

■ qmail-1.03的编译出现问题
../load auto-str substdio.a error.a str.a
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss
mismatches non-TLS reference in substdio.a(substdo.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [auto-str] Error 1

后来搜了一下,在哪说的忘记了,是因为gcc版本高了以后对extern int errno这种写法不自动修正了。解决办法:
grep “extern int errno”
把所有grep出来的地方的”extern int errno”换成 #include

试了一下,果然解决。
原文找到了:http://www.webservertalk.com/archive66-2006-3-1441516.html
[bianbian补注]:其实这个错误再打个errno的patch就可以解决的。。。

■ Sorry,_message_has_wrong_owner._(#4.3.5)
queue队列损坏,删除/var/qmail/queue目录,重新make setup check生成目录

■ Sorry,_no_mailbox_here_by_that_name._(#5.1.1)
修改了/var/qmail/control/locals文件,所以,虚拟域名就无效了。
把locals文件清空,就不会出现这个问题了。

■ qmail能发不能收, qmail_has_prog_delivery_but_has_x_bit_set
连自己域内发给自己的都收不到。一般是.qmail-default的权限问题。查看日志会发现:
deferral: Uh-oh:_.qmail_has_prog_delivery_but_has_x_bit_set._(#4.7.0)
前面我抱怨过了,给我的网站恢复数据居然是NTFS的,导致所有文件权限丢失。详见抱怨贴
一定要去掉 /home/vpopmail/domains/域名/.qmail-default 的x权限
即 chmod -x /home/vpopmail/domains/域名/.qmail-default

■ 454 oops, unable to write pipe and I can’t auth
详见:[原] qmail打了smtpd-auth补丁后454 oops, unable to write pipe and I can’t auth

■ pop3 遇到 -ERR this usr has no $HOME/maildir
supervise/qmail-pop3d/run里启动pop3d的脚本可能有错,应该是:
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
exec tcpserver -H -R -v -c100 -u “$QMAILDUID” -g “$NOFILESGID” 0 110 qmail-popup nju.org.cn \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1

■ 解决qmail经常收到投递失败的邮件
这一段部分来自:http://blog.5ilinux.com/archives/2006/04/qmailerror.html
首先说明一下<>和<#@[]>都是系统bouce信件信封(envelope)上的寄信人地址
这两种信都是系统产生的,区别在于<>往往是系统single bouce的地址,而<#@[]>则是系统double bounces或者triple bouces的地址
系统用这两种地址是为了避免邮件回路(mail loops)
来自<#@[]>一般都是系统的double bounces
要去掉这些double bounces可以有一种简单的办法
其原理是产生一个nobody的地址,发往这里的信件都会被丢弃,这样double bouces就不会烦你的postmaster了
具体步骤如下:
echo “#” > /var/qmail/alias/.qmail-doublebounceto (或者直接丢弃:echo “| cat > /dev/null” … )
echo “doublebounceto” > /var/qmail/control/doublebounceto

■ 垃圾邮件太多
1)装上发信黑名单 CBL: http://anti-spam.org.cn
2)装上maildrop和垃圾邮件过滤器 SpamAssassin: http://spamassassin.apache.org/
简单点,直接用perl的cpan安装:cpan Mail::SpamAssassin
这里有具体方法:
Getting SpamAssassin, MailDrop, VPopmail and qmail to play friendly
用 qmail + vpopmail + maildrop + spamassassin 实现邮件过滤的方案

其实我觉得老外的那个办法更好,直接改.qmail-default一个文件就行了。结合两者长处,我写了一个又支持用户自定义黑白名单,又不需要到处放.mailfilter的方法:

.qmail-default
|/usr/local/bin/maildrop ./.mailfilter

.mailfilter
VPOP="| /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox"
VHOME=`/home/vpopmail/bin/vuserinfo -d $EXT@$HOST`

#check dir
`test -d $VHOME/Maildir/`
if( $RETURNCODE != 0 )
{
    echo "Sorry,_no_mailbox_here_by_that_name."
    EXITCODE=77
    exit
}

#blacklist
#
`test -f $VHOME/.blacklist`
if ($RETURNCODE==0)
{
    $DOMAIN=`expr $SENDER : '.*@\(.*\)'`
    if ($SENDER ne '' && (lookup($SENDER, "$VHOME/.blacklist") || lookup($DOMAIN, "$VHOME/.blacklist")))
    {
        #to "$VHOME/Maildir/.Trash/"
        to /dev/null
    }
}

#whitelist
#
`test -f $VHOME/.whitelist`
if ($RETURNCODE==0)
{
    if ($SENDER ne '' && lookup($SENDER, "$VHOME/.whitelist"))
    {
        to "$VHOME/Maildir/"
    }
}

#spamassassin
#
if ($SIZE < 262144)
{
    exception {
        xfilter "spamc -f -u $EXT@$HOST"
    }
}
else
{
    exception {
        to "$VHOME/Maildir/"
    }
    exception {
        to "$VPOP"
    }
}

if (/^X-Spam-Flag: *YES/)
{
    ADDQUOTA = " $SIZE 1"
    `echo $ADDQUOTA >> $VHOME/Maildir/maildirsize`
    to “$VHOME/Maildir/.Trash/”
}
else
{
    exception {
        to “$VHOME/Maildir/”
    }
    exception {
        to “$VPOP”
    }
}

■ 加入maildrop作为投递程序后的可能错误
maildrop:_Cannot_have_world/group_permissions_on_the_filter_file_-_for_your_own_good./
.mailfilter必须是0600属性

failure: Unable_to_execute_/sbin/nologin/Unable_to_execute_/sbin/nologin/
或者
Sorry,_no_mailbox_here_by_that_name._(#5.1.1)
如果编译maildrop的时候设置了vpopmail作为uid来跑,即
./configure –enable-maildrop-uid=vpopmail \
–enable-maildrop-gid=vchkpw –enable-maildirquota –without-db \
–with-trashquota
必须给vpopmail一个shell,默认好像是/sbin/nologin,修改/etc/passwd,改为/bin/bash即可

标签: , , , ,

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

相关日志

Posted in Linux, Technology | No Comments »

[原] 解决 libXp.so.6 找不到的问题

Posted by bianbian on 2008-01-04 03:53


本文Tags: , , ,

error while loading shared libraries: libXp.so.6: cannot open shared object file: No such file or directory.

俺英文写得超级烂了,随便看看吧。一般服务器上都不装X环境的,不过有些变态的程序却要用到X环境的组件:比如java写的Tidy,oracle的安装程序。一般遇到这种情况,偷懒的人都直接rpm或apt-get到libXp.so.6来装。不过我喜欢什么都在自己的掌握中,不喜欢装到哪都不知道的感觉(Slackware甚至不支持rpm,我太欣赏了)。其实libXp.so.6只是XFree86的一个很小的库,根本没必要装整个X。自己动手,乐趣多多的解决办法:
lynx http://ftp.xfree86.org/pub/XFree86/
1)到 http://ftp.xfree86.org/pub/XFree86/,找到最新版本点进去,现在是4.7.0。
2)如果对自己系统不熟悉,可以先下个Xinstall.sh。然后运行 sh Xinstall.sh -check
他会告诉你下哪个编译好的版本适合你的系统。我的是”Linux-ix86-glibc24″。
然后点binaries进去,不研究源码,只是拿来用,就下预编译的好了。接着点“Linux-ix86-glibc24”。
3)这有很多tar,注意:你只要下Xbin.tgz就够了(现在是6.6M)
4)tar zxf Xbin.tgz -C /usr/X11
5)vi /etc/ld.so.conf,加入/usr/X11/lib
6)ldconfig
完毕。

Usually we don’t install X-Window on a Server, unfortunatelly some programs maybe use lib of XFree86, like oracle-installer, java-Tidy, etc. Some guys may use rpm or apt-get to fetch libXp.so.6, but I don’t like that. So lets do it:
1) lynx http://ftp.xfree86.org/pub/XFree86/ , choose lastest version, (now is 4.7.0)
2) if you don’t know much about your system(glibc, arch…), you can download “Xinstall.sh”, and
run “sh Xinstall.sh -check”. It will tell which binary-version you should choose, such as “Linux-ix86-glibc24″
3) ok, click binaries -> Linux-ix86-glibc24, now URL is : http://ftp.xfree86.org/pub/XFree86/4.7.0/binaries/Linux-ix86-glibc24/
You only need download Xbin.tgz (now only 6.6M)
4) tar zxf Xbin.tgz -C /usr/X11
5) vi /etc/ld.so.conf, add “/usr/X11/lib”
6) ldconfig

标签: , , ,

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

相关日志

Posted in Linux, Technology | 1 Comment »

[原] qmail打了smtpd-auth补丁后454 oops, unable to write pipe and I can’t auth

Posted by bianbian on 2008-01-03 04:22


本文Tags: ,

qmail打了smtpd-auth补丁后454 oops, unable to write pipe and I can’t auth 的解决:

我打的补丁是qmail-smtpd-auth-043_tgz.bin,google了N久也没找到好办法。幸好我备份了一个qmail-smtpd.c,对比打过补丁后的qmail-smptd.c,发现传入参数处理被改变了,不需要加域名。解决方法就是把 smtpd的run里:
/var/qmail/bin/qmail-smtpd domain.com /home/vpopmail/bin/vchkpw /bin/true 2>&1
的domain.com去掉,即:
/var/qmail/bin/qmail-smtpd /home/vpopmail/bin/vchkpw /bin/true 2>&1

网上还有盛传的一篇文章说的是用户和组设置的问题:
我估计是针对qmail-smtpd-auth-0.31的补丁版本的。
http://blog.5ilinux.com/archives/2006/04/qmailerror.html

454 oops, unable to write pipe and I can’t auth (#4.3.0)

这个错误是在你打了smtp auth的补丁之后,却发现不能正常auth,输入了正确的用户名密码还是提示不正确。可以通过下面的命令来测试。

[root@caph qmail-smtpd]# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 xxx.com ESMTP
ehlo
250-xxx.com
250-PIPELINING
250-8BITMIME
250-SIZE 104857600
250 AUTH LOGIN PLAIN CRAM-MD5 //显示这个通常表示你已经打好了补丁,不过这个是可以通过修改qmail-smtp.c文件来定制的。
auth login
334 VXNlcm5hbWU6
awefaq23rasdf
334 UGFzc3dvcmQ6
awefwaef
454 oops, unable to write pipe and I can’t auth (#4.3.0)
quit
221 xxx.com
Connection closed by foreign host.

出现了这种问题是因为smtp运行脚本没有设置正确的用户所致。将你的smtp的tcpserver命令的运行用户和组指定一下。

QMAILDUID=`id -u vpopmail`
QMAILDGID=`id -g vpopmail`

/usr/local/bin/tcpserver -v -H -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD”
-u “$QMAILDUID” -g “$QMAILDGID” 0 smtp /usr/local/bin/rblsmtpd -r relays.ordb.org
/var/qmail/bin/qmail-smtpd
/home/vpopmail/bin/vchkpw /bin/true /bin/cmd5checkpw /bin/true 2>&1

不需要修改~vpopmail/bin/vchkpw的属性。

qmail的作者真牛,觉得自己写得很好了,再也不更新。导致现在patch漫天飞啊,苦了俺们了。。。
http://www.shupp.org/toaster/?page=toc

标签: ,

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

相关日志

Posted in Linux, Technology | No Comments »

[原] slackware 12.0 编译内核

Posted by bianbian on 2007-12-28 07:00


本文Tags: , ,

make menuconfig 遇到错误:

In file included from scripts/lxdialog/checklist.c:24:
scripts/lxdialog/dialog.h:32:20: curses.h: No such file or directory
In file included from scripts/lxdialog/checklist.c:24:
scripts/lxdialog/dialog.h:130: error: syntax error before “use_colors”
scripts/lxdialog/dialog.h:130: warning: type defaults to `int’ in declaration of `use_colors’
scripts/lxdialog/dialog.h:130: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:131: error: syntax error before “use_shadow”
scripts/lxdialog/dialog.h:131: warning: type defaults to `int’ in declaration of `use_shadow’
scripts/lxdialog/dialog.h:131: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:133: error: syntax error before “attributes”
scripts/lxdialog/dialog.h:133: warning: type defaults to `int’ in declaration of `attributes’
scripts/lxdialog/dialog.h:133: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:146: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:146: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:149: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:149: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:150: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:150: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:151: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:152: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:153: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:153: warning: function declaration isn’t a prototype
scripts/lxdialog/checklist.c:32: error: syntax error before ‘*’ token
scripts/lxdialog/checklist.c:34: warning: function declaration isn’t a prototype
scripts/lxdialog/checklist.c: In function `print_item’:
scripts/lxdialog/checklist.c:38: warning: implicit declaration of function `wattrset’
scripts/lxdialog/checklist.c:38: error: `win’ undeclared (first use in this function)
scripts/lxdialog/checklist.c:38: error: (Each undeclared identifier is reported only once
scripts/lxdialog/checklist.c:38: error: for each function it appears in.)
scripts/lxdialog/checklist.c:39: warning: implicit declaration of function `wmove’
scripts/lxdialog/checklist.c:39: error: `choice’ undeclared (first use in this function)
scripts/lxdialog/checklist.c:41: warning: implicit declaration of function `waddch’
……

解决:
安装的时候少了一个包, 找到光盘里的 /slackware/l/ncruses-5.6-i486-2.tgz
# installpkg ncruses-5.6-i486-2.tgz
即可

标签: , ,

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

相关日志

Posted in Linux, Technology | No Comments »

[晕] nginx的internal属性的bug

Posted by bianbian on 2007-10-16 02:17


本文Tags: , ,

文档上说,internal用来禁止用户直接通过地址访问。
syntax: internal
default: no
context: location

internal indicates that the matching location can be used only for so called “internal” requests.
For external requests it will return the error “Not found” (404).
Internal requests are the following:
1) requests redirected by the instruction error_page
2) subrequests created by the command include virtual of the “ngx_http_ssi_module” module
3) requests changed by the instruction rewrite of the “ngx_http_rewrite_module” module

An example to prevent clients fetching error pages directly:

  1. error_page   404   /404.html;
  2. location  /404.html {
  3.     internal;
  4. }

实际发现,rewrite的用internal修饰后就挂了。像下面这个配置,如果/realpath/设了internal,用/proxypath/访问就是404。
这个跟本意是违背的(本意只能通过/proxypath/访问,而隐藏/realpath/),应该是nginx的bug(我的版本0.5.32)

  1. location /proxypath/ {
  2.    root     /realpathroot;
  3.    rewrite ^/proxypath/(.+)$  /realpath/$1? last;
  4. }
  5. location /realpath/ {
  6.   internal;
  7. }
标签: , ,

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

相关日志

Posted in Linux, Technology | No Comments »

[原] Intel平台gcc4,gcc3,icc测试

Posted by bianbian on 2007-09-24 12:20


本文Tags: , , , ,

[from zhch begin]
以一个简单的计算程序为例:

int main() {
double s=0;
int i;
for(i=200000001; i>=1; i-=4) s+=1.0/i-1.0/(i+2);
printf(”Pi=%f\n”, s*4);
}

这是一个常见的算Pi的程序,基本算法是Pi/4=1-1/3+1/5-1/7+…..
[from zhch end]

Slackware 12.0预装了gcc 4.1.2,我手动装了gcc 3.4.6,和icc 10.0。下面是测试结果:

bbs@bbs:~/test$ gcc -o PI.gcc PI.c -O3 -march=pentium4 -msse2 -mmmx
PI.c: In function ‘main’:
PI.c:5: warning:incompatible implicit declaration of built-in function ‘printf’

bbs@bbs:~/test$ icc -o PI.icc PI.c -O3 -xP
PI.c(5): warning #266: function “printf” declared implicitly
printf(”Pi=%f\n”, s*4);
^
PI.c(4): (col. 9) remark: LOOP WAS VECTORIZED.

bbs@bbs:~/test$ gcc3 -o PI.gcc3 PI.c -O3 -march=pentium4 -msse2 -mmmx

bbs@bbs:~/test$ time PI.gcc; time PI.gcc3; time PI.icc
Pi=3.141593

real 0m1.568s
user 0m1.544s
sys 0m0.016s
Pi=3.141593

real 0m1.551s
user 0m1.544s
sys 0m0.008s
Pi=3.141593

real 0m1.246s
user 0m1.212s
sys 0m0.012s

测试环境:Intel(R) Xeon(TM) MP CPU 3.00GHz * 4, 8G MEM

文件大小:
bbs@bbs:~/test$ v PI*
-rw-r–r– 1 bbs bbs 140 2007-09-23 22:28 PI.c
-rwxr-xr-x 1 bbs bbs 6365 2007-09-23 23:08 PI.gcc*
-rwxr-xr-x 1 bbs bbs 6343 2007-09-23 23:47 PI.gcc3*
-rwxr-xr-x 1 bbs bbs 19769 2007-09-23 23:08 PI.icc*

果然跟一些文章说的,gcc4比gcc3编译结果和运算速度都有所下降,icc在Intel平台下确实优化比较明显,毕竟是自己家的东西。

标签: , , , ,

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

相关日志

Posted in C/C++, Linux, Technology | 1 Comment »

[原]Linux下的c/c++ GDB调试

Posted by bianbian on 2007-09-18 10:13


本文Tags: , , ,

还是比较厉害的,比较准。
编译的时候加入 -g -rdynamic 选项,之后就可以跑调试了:
linux $ gcc -g -rdynamic -o error error.c
linux $ gdb error
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i686-pc-linux-gnu”…Using host libthread_db library “/lib/libthread_db.so.1″.

(gdb) run
Starting program: /home/linux/error

Program received signal SIGSEGV, Segmentation fault.
错误内容
行数 源码;
(gdb) kill
(gdb) q

linux $

标签: , , ,

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

相关日志

Posted in C/C++, Linux, Technology | 1 Comment »

[原]第一次完整地编译了Linux内核

Posted by bianbian on 2007-09-17 02:10


本文Tags: , , ,

啊,太痛苦了,从下午一直编译到凌晨,终于每个选项都搞清楚了是干嘛的。用的是最新的2.6.22.6内核。
slackware 12.0太好玩了,装好后有几个cpu就会在屏幕上方显示几个LOGO企鹅。一排八个真壮观。。。。

推荐这个文章: http://lamp.linux.gov.cn/Linux/kernel_options.html

共计遇到的主要问题如下:
1)LILO 不能装到MBR,好像做了raid的都不能写MBR。手动写lilo.conf可以解决。(从安装盘引导,mount /dev/cciss/盘 /d1,chroot /d1,然后就可以改 /etc/lilo.conf了,改完直接lilo)
2)make menuconfig报错。类似:
scripts/lxdialog/dialog.h:127: syntax error before “use_colors”
scripts/lxdialog/dialog.h:127: warning: type defaults to `int’ in declaration of `use_colors’
scripts/lxdialog/dialog.h:127: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:128: syntax error before “use_shadow”
scripts/lxdialog/dialog.h:128: warning: type defaults to `int’ in declaration of `use_shadow’
scripts/lxdialog/dialog.h:128: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:130: syntax error before “attributes”
原因是setup装系统的时候有make menuconfig要用到的开发语言和库没有安装进去。重新安装就可以了。网上其他发行版说的需要手动安装libncurses-dev,在Slackware 12.0并不需要,系统应该自带了。

3)网络不通。检查是驱动选错了。(lspci得到的结果不能全相信,仅供参考!我最后是从安装盘里的默认系统开机自检画面里面发现真实网卡驱动的)
4)VFS: cannot open root device。
可能的原因:A)尽管硬盘全都是SCSI,常规IDE里”INCLUDE IDE/ATA disk Support”这个还是得选上。否则就打不开根设备。。。- -!
B)Enable the block layer(块设备支持,使用硬盘/USB/SCSI设备者必选)-》Support for Large Block Devices(仅在使用大于2TB的块设备时需要)。这个选项我发现必须选上。尽管我只有8*140G,不到2T。但是实际上如果这个选项没有选的话可能起不来。因此我觉得这里是翻译有问题。原文并没有指明是2T。
可能还有其他选项上的问题,可以看看这个网址:http://kerneltrap.org/node/970

期间得到ever的大力帮助,特别感谢。
今天还是嘘嘘生日,真是对不住哦。。。。

标签: , , ,

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

相关日志

Posted in Linux, Technology | 1 Comment »

[原]nginx在Slackware 11.0下的编译安装

Posted by bianbian on 2007-09-16 12:24


本文Tags: , ,

configure就不说了,make的时候提示:
objs/src/event/ngx_event.o(.text+0xdbc): In function `ngx_event_init_conf’:src/event/ngx_event.c:1140: warning: warning: epoll_create is not implemented and will always fail
objs/src/event/modules/ngx_epoll_module.o(.text+0×1cc): In function `ngx_epoll_add_event’:src/event/modules/ngx_epoll_module.c:250: warning: warning: epoll_ctl is not implemented and will always fail
objs/src/event/modules/ngx_epoll_module.o(.text+0×416): In function `ngx_epoll_process_events’:src/event/modules/ngx_epoll_module.c:402: warning: warning: epoll_wait is not implemented and will always fail

epoll是高性能网络io,居然不被系统支持,我明明用的是2.6.17的内核。于是make menuconfig,到 General setup / Configure standard kernel features 发现’Enable event poll’ 是关闭的,于是启用。

然后重新编译内核:
make bzImage
make modules
make modules_install
cp System.map /boot/
cp arch/i386/boot/bzImage /boot/vmlinuz
lilo
reboot

话说,Slackware 12.0都出来几个月了,改天我要去装一下。^_^

标签: , ,

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

相关日志

Posted in Linux, Technology | 1 Comment »

[原]用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 »

[原]nginx+FastCGI调试成功

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


本文Tags: ,

终于明白,俺的Linux基本功果然很烂。。。。
FastCGI echo
Request number 1, Process ID: 7422
No data from standard input.

Request environment:

FCGI_ROLE=RESPONDER
GATEWAY_INTERFACE=CGI/1.1
QUERY_STRING=
REQUEST_METHOD=GET
CONTENT_TYPE=
CONTENT_LENGTH=
SCRIPT_NAME=/echo.net
REQUEST_URI=/echo.net
DOCUMENT_URI=/echo.net
DOCUMENT_ROOT=/home/nginx/html
SERVER_PROTOCOL=HTTP/1.1

…..

标签: ,

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

相关日志

Posted in Linux, Technology | No Comments »

[译]利用Nginx的X-Accel-Redirect头实现下载控制(附带php和rails实例)

Posted by bianbian on 2007-04-05 04:40


本文Tags: , ,

有时你可能需要实现控制下载:即将下载文件的请求转发到某脚本, 然后由这脚本决定怎么做:发送这个文件给用户,出现决绝访问页,或着其他的事。在lighttpd服务器里可以通过从脚本传回X-Sendfile头实现;而Nginx是通过使用X-Accel-Redirect头实现的。在这篇文章里我会尽量简捷地描述在php和rails里如何使用这一特性。

假设你使用Apache运行PHP或Rails产生动态内容,而用Nginx作为前台反向代理(bianbian注:反向代理又称为服务器加速(Server accelerate),原理是将用户的请求转发到目标服务器,然后将结果转发给用户。好处有很多:保护目标服务器安全、负载均衡容易实现、有点类似防火墙;坏处我认为就是要传递用户的IP的时候多了些步骤)。你就达到了两个目标:

  1. 因为Nginx服务器会改善所有对动态内容的缓慢请求,能节省服务器的资源(细节正在
    这里). (bianbian注:凭我对Nginx的理解,这个就是Nginx会缓存客户端的请求,等全部发送完毕了才一起转发给后台脚本,比如在上载文件的时候。好处是减少后台脚本等待的时间,确实对性能有一定改善;坏处就是在脚本里时时显示上载进度的功能是不可能实现了[当然,以后Nginx如果自己开放这个进度API也是可能的,不过也不是脚本级的,好在显示进度的功能不常用])
  2. 你能对静态文件的下载做出控制.(bianbian注:后面的一大段都是说这个啦!)

在这里,假设网站位于 /var/www 目录,而一些静态文件(类似电影、歌曲、或其他)位于 /var/www/files 目录。Apache监听8080端口。

首先,让我们看一看nginx配置:
Read the rest of this entry »

标签: , ,

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

相关日志

Posted in Linux, Technology | 4 Comments »