nginx 无缝升级

  1. 解压nginx压缩包
    tar xvzf nginx-0.8.43.tar.gz
    cd nginx-0.8.43/
  2. 安装但只进行到make,在这里你通过 /usr/local/nginx/sbin/nginx -V获得你先前configure参数
    ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --http-client-body-temp-path=/usr/local/nginx/temp/body --http-proxy-temp-path=/usr/local/nginx/temp/proxy --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi
    make
  3. 进入当前安装目录 objs/ 文件夹中,能够找到我们需要nginx文件,命令操作如下
    cd objs/
    mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
    cp nginx /usr/local/nginx/sbin/ 
  4. 最后测试,并让nginx把nginx.pid改成nginx.pid.oldbin 跟着启动新的nginx
     /usr/local/nginx/sbin/nginx -t
    kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
    kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` 

注意:nginx安装路径和pid路径根据自己实际更改;

在nginx中wordpress实现友好url的重写方法

下面介绍2种方法实现对wordpress的 URLs 的可读性和对搜索引擎的友好

  1. 使用重写方式

    location / {
        index index.php;
        if (!-e $request_filename){
            rewrite ^ /index.php?q=$uri&$args;
        }
    }
  2. 基于try_files的url重置

    location / {
      index index.php;
      try_files $uri $uri/ /index.php?q=$uri&$args;
    }
    

nginx 0.8.35 or higher编译时侯出现警告

最近更新服务器的nginx的版本,但在make后出现如下警告:

objs/src/os/unix/ngx_process.o: In function `ngx_process_get_status’:
ngx_process.c:(.text+0xc41): warning: `sys_errlist’ is deprecated; use `strerror’ or `strerror_r’ instead
ngx_process.c:(.text+0xc32): warning: `sys_nerr’ is deprecated; use `strerror’ or `strerror_r’ instead

在其官方网站回复是,这属正常现象,没有替换废弃的函数是因为新的为非异步信号安全的函数
A message “ ‘sys_errlist’ is deprecated; use ‘strerror’ or ‘strerror_r’ instead ”

nginx-0.8.42 开发版发布

Nginx (“engine x”) 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。尽管还是测试版,但是,Nginx 已经因为它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名了。

Nginx 可以在大多数 Unix like OS 上编译运行,并有 Windows 移植版。目前 Nginx 的开发版为 0.8.x,稳定版为 0.7.x,历史稳定版为 0.6.x,建议使用 0.7 系列作为生产版本。 Nginx 的源代码使用 2-clause BSD-like license

我个人本身使用在vps服务器 nginx+php-fcgi(php-fpm)搭建web服务器。

Development versions [changes]

nginx-0.8.42 pgp

nginx/Windows-0.8.42 pgp

Stable versions

nginx-0.7.67 pgp

nginx/Windows-0.7.67 pgp

在IIS 6中安装FastCGI运行PHP

为 系统Windows2003,512M内存的vps配置fastcgi+php支持,步骤如下

  1. 下载必要文件FastCGI扩展:http://www.iis.net/extensions/fastcgi (根据自己系统选择相应版本)
    php文件包:http://windows.php.net/download这里选择下载VC9 x86 Non Thread Safe的zip压缩包,具体说明查看windows平台PHP版本选择说明
  2. 安装FastCGI扩展,同时将会拷贝相关到 “%windir%\system32\inetsrv”文件夹下,并注册成IIS的扩展。其中文件包括:
    1. fcgiext.dll – fastcgi处理程序
    2. fcgiext.ini – 配置文件
    3. fcgiconfig.js – FastCGI的控制脚本

    解压php压缩包到指定目录(c:\webserver\php),并把其安装路径(c:\webserver\php)注册到系统变量PATH中,添加名为 PHPRC 值其php安装目录的系统变量

  3. 运行fcgiconfig.js配置脚本注册php-cgi.exe处理php文件,命令如下:
    cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"c:\webserver\php\php-cgi.exe"

    (fcgiconfig.js存在%windir%\system32\inetsrv目录下,为避免发生找不到脚本的错误,fcgiconfig.js可以使用其绝对路径,或进入其所在目录执行。如果想仅仅是为一个站点添加 php的处理功能可以在命令后添加 “–site:[siteId]” 参数)
    修改php.ini
    extension_dir="c:\webserver\php\ext"
    fastcgi.impersonate = 1
    cgi.fix_pathinfo=1
    cgi.force_redirect = 0

    配置回收php-cgi最大成功请求数

    cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000
    cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP"-EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000

    其请求大小根据自己配置执行设定,但要保持InstanceMaxRequests小于或等于 PHP_FCGI_MAX_REQUESTS 。

参考:Configure the FastCGI Extension for IIS 6.0