首页 > Web服务器 > [Original]Nginx实际应用Tips

[Original]Nginx实际应用Tips

2009年11月17日 发表评论 阅读评论

l WordPress的固定链接设置

eg:http://99dev.net/archives/775

修改nginx的Server Section部分如下

location /
    {
    index index.php index.html;
    if (!-e $request_filename)
    {
    rewrite "^/archives/(.+)$" /index.php?p=$1 last;
    }
    }

修改“WordPress控制面板-设置-固定链接-自定义结构”,如下

/archives/%post_id%

关键字:wordpress nginx rewrite 固定链接 PermaLink

 

|nginx 目录列表配置

location  /  {

    autoindex  on;

}

l rewrite规则转换(支持apache>nginx)

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

 

l Rewrite配置

编译过程,默认开启http_rewrite_module

在nginx.conf中加入rewrite rules即可

 

l 绑定多域名

server_name  58zz.com www.58zz.com;

Server_name中,绑定需要的域名,以空格隔开,以分号结束(均为半角字符)

l 自定义404页面

error_page 404 /404.html;

location /404.html{

root /usr/local/webserver/nginx/html/;

               }

 

l 在不停止Nginx服务的情况下平滑变更Nginx配置

1、修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确:

/usr/local/webserver/nginx/sbin/nginx -t

如果屏幕显示以下两行信息,说明配置文件正确:

the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok

the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully

2、这时,输入以下命令查看Nginx主进程号:

ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ‘ ‘ ‘{print $2}’

屏幕显示的即为Nginx主进程号,例如:

6302

这时,执行以下命令即可使修改过的Nginx配置文件生效:

kill -HUP 6302

或者无需这么麻烦,找到Nginx的Pid文件:

kill -HUP `cat /usr/local/webserver/nginx/nginx.p`

 

l 磁盘配额设置

强制卸载正在使用的分区 umount -fl device

修改/etc/fstab,添加"usrquota,grpquota"

Quotocheck -auvg 耗费时间视文件系统大小而定,可能是几十分钟甚至几小时,需要耐心等候

详细过程不累述,鸟哥的教程写得很详细http://linux.vbird.org/linux_basic/0420quota.php

l 开启nginx-stauts

用于显示nginx启动以来的状态

1.编译时,加入该模块的支持

–with-http_stub_status_module

2.修改nginx.conf,在server{}之间加入以下代码

location ~ /nginxstatus/
{
        stub_status on; #Nginx 状态监控配置
        access_log off; 
}

3.访问http://www.example.com/nginxstatus/查看状态。

分类: Web服务器 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.