Skip to content


sugarcrm

sugarcrm为基于php的开源crm

分为社区版,专业版和企业版,其中社区版为免费使用,和收费版基本一样,工组流和组有差别。

最新版为5.2 http://www.sugarforge.org/content/downloads/downloads.php

中文语言包 http://www.sugarforge.org/frs/?group_id=448

  • 解压并复制文件到SugarCRM安装目录下覆盖原有文件
  • 打开“config”文件
  • 在第196行找到以下代码
  •   array (     ‘en_us’ => ‘US English’,   ), 并更改为   array (     ‘zh_cn’ => ‘简体中文’,     ‘en_us’ => ‘US English’,   ),
    退出系统,然后点击 Options ,选择“简体中文”然后重新登陆…OK!

    Posted in PHP, 技术.

    Tagged with , .


    两个广告代码

    右下角提示窗 兼容ie ff

    http://bbs.blueidea.com/thread-2886823-1-1.html

     

    兼容ie、firefox,多个漂浮不冲突,调用只需两行代码

    http://bbs.blueidea.com/thread-2846202-1-1.html

    Posted in HTML/XHTML/CSS, 技术.

    Tagged with , .


    让tinymce中的链接默认为新窗口方式

    方法一:使用tinymce的函数setupcontent_callback 在内容的开头增加

    function myCustomSetupContent(editor_id, body, doc) {
        body.innerHTML = "" + body.innerHTML;
    }
    
    tinyMCE.init({
        ...
        setupcontent_callback : "myCustomSetupContent"
    });
    方法二:在程序入库前在内容的开头增加
    
    以php为例
    
    $Content = "" +$Content;
    
     
    
    方法三:修改tiny_mce.js文件valid_elements中a属性的默认target属性为_blank
    使用未压缩片的文件是tiny_mce_src.js.
    
    ,a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target=_blank|
    
     
    
     
    
    总结:
    tinymce版本为3 0rc1
    
    方法一和二的base方式在FF中有效,IE下需把放在前,并对以后的所有链接都有效,所以效果欠佳。
    
    方法三比较好。

    Posted in JavaScript/DOM/XML, 技术.

    Tagged with , .


    1030-Got error 28 from table handler

    web系统无法登录,用phpmyadmin查看表内容时报”1030-Got error 28 from table handler”

    原因为硬盘没有空间了。

    Posted in Mysql, 技术.

    Tagged with , .


    UCenter Home 1.5 Nginx rewrite

    UCenter Home 1.5 Nginx rewrite http://www.discuz.net/forum-149-1.html

     

     rewrite ^/(space|network)-(.+).html$ /$1.php?rewrite=$2 last;   rewrite ^/(space|network).html$ /$1.php last;   rewrite ^/([0-9]+)$ /space.php?uid=$1 last;

    以上规则含用[Nginx CVE‑2026‑42945高危漏洞](https://blog.c1gstudio.com/archives/2227),2026/05/15 更新新规则
    
    rewrite ^/(?
    space|network)-(?.+)\.html$ /${type}.php?rewrite=${rewrite} last; rewrite ^/(? space|network)\.html$ /${type}.php last; rewrite ^/(? [0-9]+)$ /space.php?uid=${uid} last;

    Posted in Nginx, 技术.

    Tagged with , .


    用jailkit创建一个chroot环境的sftp

    jailkit 官网 http://olivier.sessink.nl/jailkit/

    环境as4 #wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz #tar zxvf jailkit-2.5.tar.gz #cd jailkit-2.5 #./configure #make #make install

    创建jail环境目录 #mkdir /home/jail 创建初始权限 #jk_init -v -j /home/jail basicshell editors extendedshell netutils ssh sftp scp 上面的斜体字都是可用的服务,可以在/etc/jailkit/jk_init.ini 中找到相应的部分 创建需限制的用户 #groupadd backup #useradd -g backup -m john #passwd john 限制该用户 #jk_jailuser -m -j /home/jail john

    如果遇到错误 ldconfig: Can’t open configuration file /etc/ld.so.conf: No such file or directory 编辑/etc/jailkit/jk_init.ini vi /etc/jailkit/jk_init.ini #增加ldconfig [ldconfig] executables = /sbin/ldconfig regularfiles = /etc/ld.so.conf

    [uidbasics]

    this section probably needs adjustment on 64bit systems

    or non-Linux systems

    regularfiles = /etc/nsswitch.conf /etc/ld.so.conf

    comment = common files for all jails that need user/group information libraries = /lib/libnsl.so.1, /lib64/libnsl.so.1, /lib/libnss.so.2, /lib64/libnss.so.2 regularfiles = /etc/nsswitch.conf #去掉/etc/ld.so.conf增加下面一行 includesections = ldconfig

    修改完成后相应的passwd如下 #tail /etc/passwd john:x:504:504::/home/jail/./home/john:/usr/sbin/jk_chrootsh

    #cat /home/jail/etc/passwd root:x:0:0:root:/root:/bin/bash john:x:504:504::/home/john:/usr/sbin/jk_lsh

    参考: http://olivier.sessink.nl/jailkit/howtos_chroot_shell.html http://bemike.org/2007/12/14/jailkit.html http://forums.opensuse.org/applications/390698-jailkit-install-problems.html

    Posted in linux 维护优化, 安全, 技术.

    Tagged with , .


    用scponly创建一个chroot环境的sftp

    使用scponly可以使用户只能运行scp / sftp等命令,与rsync、subversion、gftp兼容,对winscp这个open source for Windows的client端支持很好.

    scponly官网 http://sublimation.org/scponly/

    服务器为as4 #wget http://nchc.dl.sourceforge.net/sourceforge/scponly/scponly-4.8.tgz #tar zxvf scponly-4.8.tgz #cd scponly-4.8 #./configure –prefix=/usr/local/scponly –enable-chrooted-binary –enable-winscp-compat –enable-sftp-logging-compat –enable-scp-compat –enable-rsync-compat –enable-passwd-compat #make #make install #echo /usr/local/scponly/sbin/scponlyc >> /etc/shells #make jail

    /usr/bin/install -c -d /usr/local/scponly/bin /usr/bin/install -c -d /usr/local/scponly/man/man8 /usr/bin/install -c -d /usr/local/scponly/etc/scponly /usr/bin/install -c -o 0 -g 0 scponly /usr/local/scponly/bin/scponly /usr/bin/install -c -o 0 -g 0 -m 0644 scponly.8 /usr/local/scponly/man/man8/scponly.8 /usr/bin/install -c -o 0 -g 0 -m 0644 debuglevel /usr/local/scponly/etc/scponly/debuglevel if test “xscponlyc” != “x”; then                        \         /usr/bin/install -c -d /usr/local/scponly/sbin;              \         rm -f /usr/local/scponly/sbin/scponlyc;                 \         cp scponly scponlyc;                            \         /usr/bin/install -c -o 0 -g 0 -m 4755 scponlyc /usr/local/scponly/sbin/scponlyc;      \ fi chmod u+x ./setup_chroot.sh ./setup_chroot.sh   Next we need to set the home directory for this scponly user. please note that the user’s home directory MUST NOT be writeable by the scponly user. this is important so that the scponly user cannot subvert the .ssh configuration parameters.   for this reason, a writeable subdirectory will be created that the scponly user can write into.   Username to install [scponly]larry home directory you wish to set for this user [/home/larry] name of the writeable subdirectory [incoming]incoming ldconfig: /usr/lib/libmcrypt.so.4 is not a symbolic link     creating  /home/larry/incoming directory for uploading files   Your platform (Linux) does not have a platform specific setup script. This install script will attempt a best guess. If you perform customizations, please consider sending me your changes. Look to the templates in build_extras/arch.  – joe at sublimation dot org   please set the password for larry: Changing password for user larry. New UNIX password: BAD PASSWORD: it is too simplistic/systematic Retype new UNIX password: Sorry, passwords do not match New UNIX password: BAD PASSWORD: it is too simplistic/systematic Retype new UNIX password: passwd: all authentication tokens updated successfully. if you experience a warning with winscp regarding groups, please install the provided hacked out fake groups program into your chroot, like so: cp groups /home/larry/bin/groups

    #ll /home/larry/ drwxr-xr-x  2 root  root  4096 11月 10 11:23 bin drwxr-xr-x  2 root  root  4096 11月 10 11:23 etc drwxr-xr-x  2 larry larry 4096 11月 10 11:26 incoming drwxr-xr-x  3 root  root  4096 11月 10 11:23 lib drwxr-xr-x  5 root  root  4096 11月 10 11:23 usr

    larry用户登录后只能在incoming目录里传东西

    创建新用户需在编辑目录里执行setup_chroot.sh #./setup_chroot.sh

    #mkdir /home/larry/dev
    #cp -a /dev/null /home/larry/dev/
    64位系统
    
    # mkdir /home/larry/lib64
    # cp /lib64/ld-linux-x86-64.so.2 /home/larry/lib64/

    参考:http://bbs.chinaunix.net/viewthread.php?tid=785820 http://hi.baidu.com/fengzhenjie/blog/item/2a4b1e7fe072ba0e29388a66.html

    Posted in linux 维护优化, 安全, 技术.

    Tagged with , .


    用squid缓存jsp加速lucene搜索

    前面尝试了使用nginx负载均衡lucene,效果还不错,但更新维护比较麻烦。 搜索来源中大部分是由连接方式过来,所以大部分的页面内容相同,可以使用缓存的方式重复使用。

    方案一:用nginx的proxy stone 方案二:用nginx的ncache 方案三:用Varnish 方案四:用squid

    方案一和方案二: 方案一和二是副本概念不会自动更新缓存,需写脚本来控制 都要使用nginx 的rewrite将html转成jsp 修改jsp中分页等连接地址为html 方案二需修改jsp在header中增加max-age 尝试结果: jsp的参数超过了10个,但nginx只支持10个,所以不能缓存所有页面,但可以尝试缓存最常用的关键词第一页。 linux上好像没法将文件缓存起来并且没log,以下是windows上error.log

    2008/11/04 16:39:16 [crit] 2828#0: 3 rename() “/proxy_temp/0000000004” to “html/locals.c1gstudio.com/search/” failed (21: Is a directory) while reading upstream, client: 127.0.0.1, server: locals.c1gstudio.com, request: “GET /search/ HTTP/1.1”, upstream: “http://192.168.1.50:8080/search/“, host: “locals.c1gstudio.com” 2008/11/04 16:39:19 [crit] 2828#0: 1 rename() “/proxy_temp/0000000013” to “html/locals.c1gstudio.com/search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&type=0&do=1” failed (2: No such file or directory) while reading upstream, client: 127.0.0.1, server: locals.c1gstudio.com, request: “GET /search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&jobtype=0&do=1 HTTP/1.1”, upstream: “http://192.168.1.50:8080/search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&type=0&do=1“, host: “locals.c1gstudio.com”, referrer: http://locals.c1gstudio.com/search/

    貌似不必rewrite也可缓存。=_=!!!

    方案三: 缓存放在内存里,软件重启后需重新生成,瞬时并发比较大 网卡流量也比较多,性能也比squid差。 参考it流言终结者的比较 IT流言终结者1续篇:varnish vs squid IT流言终结者1:Varnish vs Squid http://www.hiadmin.com/category/service/squid-app/

    方案四: 以前有架设过,改改配置就可以上了。 选择squid2.6stable22,据测试性能稳定。

    架设参考 squid 安装 https://blog.c1gstudio.com/archives/130

    squid.conf中 开1.5G内存,4G硬盘 cache_store_log none access_log none

    refresh_pattern -i .html$  60       25%     240 refresh_pattern -i .htm$   60       25%     240 refresh_pattern -i .jsp$   5       25%     20

    refresh_pattern -i .gif$   1440    50%     2880      ignore-reload refresh_pattern -i .jpg$   1440    50%     2880      ignore-reload refresh_pattern -i .jpeg$  1440    50%     2880     ignore-reload refresh_pattern -i .png$   1440    50%     2880      ignore-reload

    总结: 最终架构是 nginx(80)->squid(81)->tomcat(8080) nginx 跑在80端口代理81 squid 跑81端口代理远程的tomcat (squid跑在80会报access denied,忘改这个了acl Safe_ports port 81) tomcat 在另一台机器上

    jsp中header增加max-age=3600和相应expires,让页面在ie中缓存一小时,squid中缓存5~20分钟。

    目前的负载 跑nginx和squid的 load average: 0.18, 0.14, 0.08 以前是load为1左右 跑tomcat的 load average: 1.57, 1.41, 1.28 以前load为3左右

    现在改动程序只需改动一台机器,结果很满意哈~

     

    Posted in Nginx, Squid/varnish.

    Tagged with , , , .


    [转]iostat 介绍

    1. iostat 结果解析

    iostat -x

    Linux 2.4.21-9.30AX (localhost) 2004年07月14日

    avg-cpu: %user %nice %sys %idle 3.85 0.00 0.95 95.20

    Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util /dev/hda 1.70 1.70 0.82 0.82 19.88 20.22 9.94 10.11 24.50 11.83 57.81 610.76 99.96 /dev/hda1 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 12.92 0.00 10.77 10.77 0.00 /dev/hda5 0.02 0.00 0.00 0.00 0.03 0.00 0.02 0.00 6.60 0.00 6.44 6.04 0.00 /dev/hda6 0.01 0.38 0.05 0.03 0.43 3.25 0.21 1.62 46.90 0.15 193.96 52.25 0.41 /dev/hda7 1.66 1.33 0.76 0.79 19.41 16.97 9.70 8.49 23.44 0.79 51.13 19.79 3.07

    rrqm/s: 每秒进行 merge 的读操作数目。即 delta(rmerge)/s wrqm/s: 每秒进行 merge 的写操作数目。即 delta(wmerge)/s r/s: 每秒完成的读 I/O 设备次数。即 delta(rio)/s w/s: 每秒完成的写 I/O 设备次数。即 delta(wio)/s rsec/s: 每秒读扇区数。即 delta(rsect)/s wsec/s: 每秒写扇区数。即 delta(wsect)/s rkB/s: 每秒读K字节数。是 rsect/s 的一半,因为每扇区大小为512字节。 wkB/s: 每秒写K字节数。是 wsect/s 的一半。 avgrq-sz: 平均每次设备I/O操作的数据大小 (扇区)。即 delta(rsect+wsect)/delta(rio+wio) avgqu-sz: 平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)。 await: 平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio) svctm: 平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio) %util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。 即 delta(use)/s/1000 (因为use的单位为毫秒)

    如果 %util 接近 100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘 可能存在瓶颈。

    svctm 一般要小于 await (因为同时等待的请求的等待时间被重复计算了), svctm 的大小一般和磁盘性能有关,CPU/内存的负荷也会对其有影响,请求过多 也会间接导致 svctm 的增加。await 的大小一般取决于服务时间(svctm) 以及 I/O 队列的长度和 I/O 请求的发出模式。如果 svctm 比较接近 await,说明 I/O 几乎没有等待时间;如果 await 远大于 svctm,说明 I/O 队列太长,应用 得到的响应时间变慢,如果响应时间超过了用户可以容许的范围,这时可以考虑 更换更快的磁盘,调整内核 elevator 算法,优化应用,或者升级 CPU。

    队列长度(avgqu-sz)也可作为衡量系统 I/O 负荷的指标,但由于 avgqu-sz 是 按照单位时间的平均值,所以不能反映瞬间的 I/O 洪水。

    1. I/O 系统 vs. 超市排队

    举一个例子,我们在超市排队 checkout 时,怎么决定该去哪个交款台呢? 首当 是看排的队人数,5个人总比20人要快吧? 除了数人头,我们也常常看看前面人 购买的东西多少,如果前面有个采购了一星期食品的大妈,那么可以考虑换个队 排了。还有就是收银员的速度了,如果碰上了连钱都点不清楚的新手,那就有的 等了。另外,时机也很重要,可能 5 分钟前还人满为患的收款台,现在已是人 去楼空,这时候交款可是很爽啊,当然,前提是那过去的 5 分钟里所做的事情 比排队要有意义 (不过我还没发现什么事情比排队还无聊的)。

    I/O 系统也和超市排队有很多类似之处:

    r/s+w/s 类似于交款人的总数 平均队列长度(avgqu-sz)类似于单位时间里平均排队人的个数 平均服务时间(svctm)类似于收银员的收款速度 平均等待时间(await)类似于平均每人的等待时间 平均I/O数据(avgrq-sz)类似于平均每人所买的东西多少 I/O 操作率 (%util)类似于收款台前有人排队的时间比例。

    我们可以根据这些数据分析出 I/O 请求的模式,以及 I/O 的速度和响应时间。

    1. 一个例子

    iostat -x 1

    avg-cpu: %user %nice %sys %idle 16.24 0.00 4.31 79.44 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util

    /dev/cciss/c0d0 0.00 44.90 1.02 27.55 8.16 579.59 4.08 289.80 20.57 22.35 78.21 5.00 14.29 /dev/cciss/c0d0p1 0.00 44.90 1.02 27.55 8.16 579.59 4.08 289.80 20.57 22.35 78.21 5.00 14.29 /dev/cciss/c0d0p2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

     

    上面的 iostat 输出表明秒有 28.57 次设备 I/O 操作: delta(io)/s = r/s + w/s = 1.02+27.55 = 28.57 (次/秒) 其中写操作占了主体 (w:r = 27:1)。

    平均每次设备 I/O 操作只需要 5ms 就可以完成,但每个 I/O 请求却需要等上 78ms,为什么? 因为发出的 I/O 请求太多 (每秒钟约 29 个),假设这些请求是 同时发出的,那么平均等待时间可以这样计算:

    平均等待时间 = 单个 I/O 服务时间 * ( 1 + 2 + … + 请求总数-1) / 请求总数

    应用到上面的例子: 平均等待时间 = 5ms * (1+2+…+28)/29 = 70ms,和 iostat 给出的 78ms 的平均等待时间很接近。这反过来表明 I/O 是同时发起的。

    每秒发出的 I/O 请求很多 (约 29 个),平均队列却不长 (只有 2 个 左右), 这表明这 29 个请求的到来并不均匀,大部分时间 I/O 是空闲的。

    一秒中有 14.29% 的时间 I/O 队列中是有请求的,也就是说,85.71% 的时间里 I/O 系统无事可做,所有 29 个 I/O 请求都在142毫秒之内处理掉了。

    delta(ruse+wuse)/delta(io) = await = 78.21 => delta(ruse+wuse)/s = 78.21 delta(io)/s = 78.2128.57 = 2232.8,表明每秒内的I/O请求总共需 要等待2232.8ms。所以平均队列长度应为 2232.8ms/1000ms = 2.23,而 iostat 给出的平均队列长度 (avgqu-sz) 却为 22.35,为什么?! 因为 iostat 中有 bug,avgqu-sz 值应为 2.23,而不是 22.35。 以下为服务器情况

    bbs(scsi 74G) top – 17:06:00 up 61 days, 11 min,  3 users,  load average: 3.98, 3.72, 3.53 Tasks: 250 total,   3 running, 247 sleeping,   0 stopped,   0 zombie Cpu(s): 15.4% us,  3.7% sy,  0.0% ni, 74.6% id,  6.2% wa,  0.1% hi,  0.0% si Mem:   2073976k total,  1922724k used,   151252k free,    36372k buffers Swap:  2040244k total,    46416k used,  1993828k free,  1007456k cached   avg-cpu:  %user   %nice %system %iowait  %steal   %idle           15.17    0.00    3.65    6.21    0.00   75.02   Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util sda               0.13    55.67   12.19   30.50   215.93   690.06    21.22     0.17    3.93   5.22  22.30 search1(sata 80G) top – 17:06:32 up 4 days,  4:31,  2 users,  load average: 1.02, 1.31, 1.19 Tasks:  86 total,   1 running,  85 sleeping,   0 stopped,   0 zombie Cpu(s): 32.3% us,  0.9% sy,  0.0% ni, 62.2% id,  4.2% wa,  0.2% hi,  0.2% si Mem:   2074476k total,  2060532k used,    13944k free,   260740k buffers Swap:  4096532k total,    16264k used,  4080268k free,   159984k cached   avg-cpu:  %user   %nice %system %iowait  %steal   %idle            9.00    0.00    1.62    5.80    0.00   84.02   Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util hda               0.05    35.22   18.19   12.87   189.80   384.73    18.50     5.59  179.86   7.44  23.12

    search2(scsi 74G *2 ) top – 17:07:15 up 17 days, 21:34,  2 users,  load average: 2.21, 2.78, 2.82 Tasks: 155 total,   1 running, 154 sleeping,   0 stopped,   0 zombie Cpu(s): 13.2% us,  4.7% sy,  0.0% ni, 77.7% id,  4.0% wa,  0.0% hi,  0.3% si Mem:   2074936k total,  2003708k used,    71228k free,    74260k buffers Swap:  2031608k total,   342032k used,  1689576k free,   197840k cached   avg-cpu:  %user   %nice %system %iowait  %steal   %idle           21.67    0.00    6.25    4.39    0.00   67.94   Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util sda               0.03     6.66    1.77    2.68    86.44    75.11    36.32     0.13   29.63   4.83   2.15 sdb               0.29    69.29   29.10   13.90   340.41   665.65    23.40     0.62   14.43   4.33  18.64

    www (sas 15K 146G *2 raid 1) top – 17:07:56 up 17 days, 20:33,  1 user,  load average: 0.16, 0.27, 0.26 Tasks: 161 total,   1 running, 160 sleeping,   0 stopped,   0 zombie Cpu(s):  1.1%us,  0.2%sy,  0.0%ni, 98.2%id,  0.4%wa,  0.0%hi,  0.1%si,  0.0%st Mem:   8174384k total,  8113268k used,    61116k free,   277316k buffers Swap:  8191992k total,      140k used,  8191852k free,  6900728k cached   avg-cpu:  %user   %nice %system %iowait  %steal   %idle            2.00    0.00    0.79    0.22    0.00   97.09   Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util sda               0.13    31.81    0.41    8.54    19.85   322.79    38.32     0.58   64.46   2.50   2.24 dm-0              0.00     0.00    0.01    3.92     0.40    31.39     8.08     0.19   47.19   1.44   0.57 dm-1              0.00     0.00    0.46   34.35    18.40   274.76     8.42     1.14   32.63   0.53   1.85 dm-2              0.00     0.00    0.00    0.23     0.00     1.82     8.00     0.01   31.41   8.79   0.20 dm-3              0.00     0.00    0.06    0.57     1.00     4.53     8.89     0.02   35.87   3.40   0.21 dm-4              0.00     0.00    0.00    0.00     0.01     0.02     8.00     0.00   15.83   0.35   0.00 dm-5              0.00     0.00    0.00    1.28     0.04    10.27     8.00     0.16  125.45   0.08   0.01

    参考:http://blog.chinaunix.net/u/27493/showart.php?id=498055

    Posted in LINUX, 其它, 分析报告, 技术.

    Tagged with .


    Nginx for Windows

    kevin写的nginx for windows 支持(Windows Vista, Windows XP, Windows 2000) 他的主页: http://www.kevinworthington.com/nginx/win32/ 目前有三个主流版本下载:

    Branch Download Package Release Date
    Development 0.7.19 13 October 2008
    Stable 0.6.32 07 July 2008
    Legacy 0.5.37 07 July 2008

    tips:请不要用在生产环境,仅供开发测试。

    一。下载 我这里下载0.6.32版http://www.kevinworthington.com/nginx/win32/nginx-0.6.32-win32-setup.exe 下载后安装到c:\nginx。

    PHP 官方下载php 我这里下载PHP 5.2.6 zip package 下载后以解压到c:\php。

    二。配置nginx 下面这张截图内容为廖老师 nginx 配置单:

    上图中用红线椭圆圈起来的,是nginx php 配置的关键部分,没配置正确会出现404错误,让我郁闷很久。 如果你的程式放在有空格的文件夹下如program files下,可以用以下方法。      include fcgi.conf;          set $rootpath “D:\Program Files\wamp\www”;      fastcgi_param SCRIPT_FILENAME $rootpath$fastcgi_script_name;

    三。启动nginx 执行c:\nginx\Start-nginx.bat启动 启动php的cgi server

    关于php cgi server 可以使用以下命令:

          php-cgi.exe -b 127.0.0.1:9000 -q

    这样做,缺陷是命令行窗口一直打开,若关闭那cgi server 也关闭啦。到网上下载RunHiddenConsole.exe 可以使命令行窗口隐藏啦。        RunHiddenConsole.exe php-cgi.exe -b 127.0.0.1:9000 -q

    你也可以写一个批处理来做这件事:

    start_phpcgi.bat  @ECHO OFF ECHO Starting PHP FastCGI… RunHiddenConsole.exe c:/php/php-cgi.exe -b 127.0.0.1:9000 -q EXIT

    关闭的批处理 stop_phpcgi.bat @ECHO OFF ECHO Stopping PHP FastCGI… bin\process.exe -k php-cgi.exe >nul ECHO. EXIT

    最后写一个简单PHPINFO来验证PHP 是否工作正常。

    参考:http://blog.chinaitlab.com/html/30/104830-166195.html

    Posted in Nginx, 技术.

    Tagged with , , .