全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: mojave
打印 上一主题 下一主题

nginx静态规则这样添加为何不行,该如何改

[复制链接]
21#
发表于 2009-10-12 23:05:20 | 只看该作者

回复 20# 的帖子

嗯,整个贴出来好看些。
22#
 楼主| 发表于 2009-10-12 23:13:17 | 只看该作者

回复 20# 的帖子

user  www www;

worker_processes 1;

error_log  /home/logs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
        {
                use epoll;
                worker_connections 51200;
        }

http
        {
                include       mime.types;
                default_type  application/octet-stream;

                #charse  gb2312;

                server_names_hash_bucket_size 128;
                client_header_buffer_size 32k;
                large_client_header_buffers 4 32k;
                client_max_body_size 8m;

                sendfile on;
                tcp_nopush     on;

                keepalive_timeout 60;

                tcp_nodelay on;

                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_buffer_size 64k;
                fastcgi_buffers 4 64k;
                fastcgi_busy_buffers_size 128k;
                fastcgi_temp_file_write_size 128k;

                gzip on;
                gzip_min_length  1k;
                gzip_buffers     4 16k;
                gzip_http_version 1.0;
                gzip_comp_level 2;
                gzip_types       text/plain application/x-javascript text/css application/xml;
                gzip_vary on;

                #limit_zone  crawler  $binary_remote_addr  10m;

server
        {
                listen       80;
                server_name moltown.com;
                index index.html index.htm index.php;
                root  /home/www;

                #limit_conn   crawler  20;

                #location /status {
                #stub_status        on;
                #access_log        off;
                #}

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /home/logs/access.log  access;
        }

server
        {
                listen  80;
                server_name  www.moltown.com;

#                location / {
#                        stub_status on;
#                        access_log   off;
#                                 }

location / {
            rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
            rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
            rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
            rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
            rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
            break;
        }


if ($host != 'moltown.com/my' ) {
        rewrite  ^/(.*)$  http://moltown.com/my/$1  permanent;
  }
  
        rewrite ^/(post|record|sort|author|page)-([0-9]+)\.html$ /index.php?$1=$2;
        rewrite ^/tag-(.+)\.html$ /index.php?tag=$1;
        }
}
23#
 楼主| 发表于 2009-10-12 23:14:12 | 只看该作者

回复 21# 的帖子

贴了
24#
发表于 2009-10-12 23:24:22 | 只看该作者

回复 23# 的帖子

第二段server缺了好多东西,你要把www.moltown.com绑定在哪个目录都没有设置,你是要绑定到bbs目录的话,我给你写下,

把你上面的第二个server段替换成

server
        {
                listen       80;
                server_name www.moltown.com;
                index index.html index.htm index.php;
                root  /home/www/bbs;

                #limit_conn   crawler  20;

                #location /status {
                #stub_status        on;
                #access_log        off;
                #}

location / {
            rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
            rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
            rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
            rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
            rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
            break;
        }

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                log_format  access2  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /home/logs/access.log  access;
        }

这样就OK了
25#
发表于 2009-10-12 23:28:18 | 只看该作者
第二段 的 # 号 错了 你用成 全拼了 应该是 #
其他的 我正在 看
26#
发表于 2009-10-12 23:29:24 | 只看该作者
第二段 缺日志 和 主目录
27#
发表于 2009-10-12 23:29:59 | 只看该作者
额 C大 比我动作快 嘿嘿
28#
 楼主| 发表于 2009-10-12 23:33:26 | 只看该作者

回复 24# 的帖子

[emerg]: unknown log format "access" in /usr/local/nginx/conf/nginx.conf:99
configuration file /usr/local/nginx/conf/nginx.conf test failed
我觉得下面这里没变动
29#
发表于 2009-10-12 23:36:15 | 只看该作者
你把 你的 两个主目录 和 对应的 两个域名 还有两个日志保存位置 和 文件名 写出来
30#
 楼主| 发表于 2009-10-12 23:41:40 | 只看该作者

回复 29# 的帖子

/home/www/bbs    moltown.com/bbs
/home/www/my     moltown.com/my
日志是公用的吧/home/logs/access.log
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-24 14:35 , Processed in 0.069051 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表