discuz在Nginx0.8.34下的伪静态规则

discuz论坛在Nginx下的rewrite规则,修改完后restart nginx

bear@bear-laptop:/etc/nginx/sites-available$ vi bbs.njava 
server {
        listen   80;
        server_name bbs.njava.com;

        access_log  /var/log/nginx/bbs.njava.access.log;

        location / {
            root /home/bear/Sites/bbs.njava;
            index index.html index.htm index.php;

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

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                set $path_info "/";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
                  }
               fastcgi_param SCRIPT_FILENAME /home/bear/Sites/bbs.njava/$real_script_name;
               fastcgi_param script_name $real_script_name;
               fastcgi_param path_info $path_info;
               include /etc/nginx/fastcgi_params;
         }
}

Tags: , ,

星期一, 3月 22nd, 2010 服务器 没有评论

nginx 0.8.34以fastcgi方式运行php

1 安装spawn-fcgi

bear@bear-laptop:~$sudo apt-get install php5-cli php5-cgi php5-xcache build-essential
bear@bear-laptop:~$ sudo apt-get install  spawn-fcgi

很多地方都说要先安装lighttpd,不用这样,可以直接安装 spawn-fcgi
2 增加fastcgi控制脚本

bear@bear-laptop:/usr/bin$ sudo vi /etc/init.d/php-fastcgi
#!/bin/bash
SCRIPT=/usr/bin/spawn-fcgi
NAME=php-fastcgi
DESC=Spawn-fcgi

case "$1" in
    start)
	echo -n "Starting $DESC: " 
	$SCRIPT -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/$NAME.pid|| true
	echo "$NAME."
;;
    stop)
      echo -n "Stopping $DESC: "
      killall -9 php5-cgi
      echo "$NAME."
;;
    restart)
       echo -n "Stopping $DESC: "
	killall -9 php5-cgi
	sleep 1
       echo  "Starting $DESC: " 
     	$SCRIPT -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/$NAME.pid|| true
	echo  "$DESC."
;;
*)
      echo "Usage: $NAME {start|stop|restart}"
      exit 1
;;
esac
exit 0

3 开机启动

bear@bear-laptop:/usr/bin$ sudo gedit /etc/rc.local
/etc/init.d/php-fastcgi start

Tags: , , ,

星期一, 3月 22nd, 2010 服务器 没有评论

ubuntu9.10安装nginx0.8.34

源里的是nginx0.7.62,决定把他升级到nginx0.8.34

1 卸载nginx0.7.62

bear@bear-laptop:~/$ sudo apt-get remove nginx

2 安装编译环境

bear@bear-laptop:~/soft/nginx-0.8.34$ sudo sudo apt-get install build-essential libpcre3-dev libssl-dev libxslt-dev libgd2-xpm-dev libgeoip-dev

4 下载nginx0.8.34

bear@bear-laptop:~/soft$ axel http://nginx.org/download/nginx-0.8.34.tar.gz
bear@bear-laptop:~/soft$ tar -xzvf nginx-0.8.34.tar.gz

5 下载upstream fair 模块

bear@bear-laptop:~/soft$ wget http://github.com/gnosek/nginx-upstream-fair/tarball/master
bear@bear-laptop:~/soft$ tar -xzvf gnosek-nginx-upstream-fair-2131c73.tar.gz

6 编译

bear@bear-laptop:~/soft$ cd nginx-0.8.34/
bear@bear-laptop:~/soft/nginx-0.8.34$ ./configure --conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-mail --with-mail_ssl_module --with-ipv6 --with-http_realip_module --with-http_geoip_module --with-http_xslt_module --with-http_image_filter_module --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --add-module=../gnosek-nginx-upstream-fair-2131c73

....

...

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ using sha1 library: /usr/include/openssl
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"

bear@bear-laptop:~/soft/nginx-0.8.34$ make

bear@bear-laptop:~/soft/nginx-0.8.34$ sudo make install
make -f objs/Makefile install
make[1]: 正在进入目录 `/home/bear/soft/nginx-0.8.34'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin'         || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx'         || mv '/usr/local/nginx/sbin/nginx'             '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/etc/nginx'         || mkdir -p '/etc/nginx'
cp conf/koi-win '/etc/nginx'
cp conf/koi-utf '/etc/nginx'
cp conf/win-utf '/etc/nginx'
test -f '/etc/nginx/mime.types'         || cp conf/mime.types '/etc/nginx'
cp conf/mime.types '/etc/nginx/mime.types.default'
test -f '/etc/nginx/fastcgi_params'         || cp conf/fastcgi_params '/etc/nginx'
cp conf/fastcgi_params         '/etc/nginx/fastcgi_params.default'
test -f '/etc/nginx/fastcgi.conf'         || cp conf/fastcgi.conf '/etc/nginx'
cp conf/fastcgi.conf '/etc/nginx/fastcgi.conf.default'
test -f '/etc/nginx/nginx.conf'         || cp conf/nginx.conf '/etc/nginx/nginx.conf'
cp conf/nginx.conf '/etc/nginx/nginx.conf.default'
test -d '/var/run'         || mkdir -p '/var/run'
test -d '/var/log/nginx' ||         mkdir -p '/var/log/nginx'
test -d '/usr/local/nginx/html'         || cp -r html '/usr/local/nginx'
test -d '/var/log/nginx' ||         mkdir -p '/var/log/nginx'
make[1]:正在离开目录 `/home/bear/soft/nginx-0.8.34'
bear@bear-laptop:~/soft/nginx-0.8.34$

7 修改 /etc/init.d/nginx 脚本

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

set -e

. /lib/lsb/init-functions

test_nginx_config() {
if /usr/local/nginx/sbin/nginx -t
then
return 0
else
return $?
fi
}

8 update-rc脚本

sudo update-rc.d -f nginx defaults

9 over

Tags: ,

星期一, 3月 22nd, 2010 服务器 没有评论

给ubuntu9.10的fastcgi方式的php增加eaccelerator0.9.6加速

1 安装编译环境

root@njava:~# sudo apt-get install build-essential php5-dev

2 安装eaccelerator

root@njava:~# axel http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
root@njava:~# tar -xjvf eaccelerator-0.9.6.tar.bz2
root@njava:~#cd eaccelerator-0.9.6.tar.bz2
root@njava:~#sudo /usr/bin/phpize
root@njava:~/eaccelerator-0.9.6# ./configure -enable-eaccelerator=shared -with-php-config=/usr/bin/php-config
root@njava:~/eaccelerator-0.9.6# make
root@njava:~/eaccelerator-0.9.6# make install
Installing shared extensions:     /usr/lib/php5/20060613+lfs/
root@njava:~/eaccelerator-0.9.6# mkdir /tmp/eaccelerator
root@njava:~/eaccelerator-0.9.6# chmod 777 /tmp/eaccelerator/
root@njava:~/eaccelerator-0.9.6# vi /etc/php5/conf.d/eaccelerator
[eaccelerator]
zend_extension="/usr/lib/php5/20060613+lfs/eaccelerator.so"
#extension="eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Tags: , ,

星期日, 3月 21st, 2010 Web 没有评论

nginx-0.8.34配置ZendOptimizer-3.3.9

ubuntu9.10下把apache2干掉了,代码编译安装0.8.34,php以fastcgi方式运行,配置ZendOptimizer的方法

root@njava:~# axel http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
root@njava:~# cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so  /usr/lib/php5/20060613+lfs/
root@njava:~# vi /etc/php5/cgi/conf.d/zendoptimizer.ini
extension=ZendOptimizer.so
:wq

root@njava:~# /etc/init.d/nginx restart

64位的地址

root@njava:~# axel http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

Tags: ,

星期日, 3月 21st, 2010 服务器 没有评论

nginx的301跳转

今天把vps上的apache换成了nginx,需要对wordpress进行了301重定向,把www.njava.com和njava.com进行合并,通过判断nginx核心变量host来实现:

server {
server_name www.njava.com njava.com ;
if ($host != 'www.njava.com' ) {
rewrite ^/(.*)$ http://www.njava.com/$1 permanent;
}

Tags: ,

星期六, 3月 20th, 2010 服务器 没有评论

正则表达式教程

为了写.htaccess的rewrite留存

正则表达式30分钟入门教程

Tags:

星期四, 3月 18th, 2010 网址 没有评论

njava迁往米国BURSTNET VPS

上帝保佑

Tags:

星期二, 3月 16th, 2010 服务器 没有评论

欢迎网站第一批访问者各路蜘蛛,爬虫

蜘蛛的启示

一只蜘蛛在断墙处结了网,把家安了下来,但是它的生活并没有安宁,因为它常常会遭受风雨的袭击。
又是这么一天,大雨来临,它的网又一次遭受劫难。大雨刚过,这只蜘蛛向墙上支离破碎的网艰难地爬去。由于墙壁潮湿,它爬到一定的高度就会掉下来。他一次次的向上爬,一次次的又掉下来。
一直在里面避雨的3个人看到蜘蛛爬上去又掉下来的情景,开始讨论起来,他们的观点却大不一样。
第一个人看到后,叹了一口气,自言自语的说:“哎,我的一生不正如这只蜘蛛吗?我们的境况就是这样,虽然一直都在忙忙碌碌可结果却一无所得。看来我的命运和这只蜘蛛一样也是无法改变的。”于是,他继续沉迷于颓废之中,日渐消沉。
第二个人在一旁静静地看了一会儿,不屑一顾地说道:“这只蜘蛛真愚蠢,为什么不从旁边干燥的地方绕一下爬上去呢?以后我可不能向它那样愚蠢。再遇到棘手的问题时,我一定要用头脑认真思考,不能一味地埋头苦干,尽量寻找解决问题的捷径。”从此,他变得聪明起来。
第三个人专注的看着屡败屡战的蜘蛛,他的心灵为之深深地震撼了,他在想:“一只小小的蜘蛛,竟然有如此执着而顽强的精神,有这样的精神,就一定可以取得成功。我真应该向这只蜘蛛学习!”受这只蜘蛛的启发,他从此坚强无比。
大道理:善于发现,善于思考,处处都有成功力量的源泉。其实成功的本质就蕴藏在人的心内,总想着成功的人,在什么地方都能受到启迪。

第一批光顾本博的访问者,Yandex,Google,Sogou,Yahoo都来了

77.88.27.25 - - [13/Mar/2010:09:40:55 -0800] "GET /njava-category/%e9%9f%b3%e4%b9%90/feed HTTP/1.1" 200 1753 "-" "Yandex/1.01.001 (compatible; Win16; I)"
66.249.68.76 - - [13/Mar/2010:09:47:01 -0800] "GET /sitemap.xml.gz HTTP/1.1" 304 173 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
220.181.94.216 - - [13/Mar/2010:10:16:19 -0800] "GET /njava-68/feed HTTP/1.1" 200 842 "-" "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)"
77.88.27.25 - - [13/Mar/2010:10:17:29 -0800] "GET /njava-category/%e6%9c%8d%e5%8a%a1%e5%99%a8 HTTP/1.1" 200 4283 "-" "Yandex/1.01.001 (compatible; Win16; I)"
66.249.68.76 - - [13/Mar/2010:10:25:19 -0800] "GET /sitemap.xml.gz HTTP/1.1" 304 173 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
67.195.115.184 - - [13/Mar/2010:10:25:26 -0800] "GET /robots.txt HTTP/1.0" 200 355 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"
67.195.115.184 - - [13/Mar/2010:10:25:28 -0800] "GET /Multimedia/Audio/Source/?S=A HTTP/1.0" 200 4116 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)"

找了找历史baidu昨天也来过

77.88.27.25 - - [12/Mar/2010:16:49:04 -0800] "GET /njava-tag/ddos HTTP/1.1" 200 3863 "-" "Yandex/1.01.001 (compatible; Win16; I)"
123.125.66.108 - - [12/Mar/2010:16:49:19 -0800] "GET /robots.txt HTTP/1.1" 200 355 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)"
66.249.68.76 - - [12/Mar/2010:16:49:24 -0800] "GET /njava-77/feed HTTP/1.1" 200 831 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Tags: ,

星期六, 3月 13th, 2010 Web 没有评论

freebsd常用状态信息命令

systat 实时查看各种信息

systat -pigs 猪头进程占用CPU
systat -iostat 硬盘IO
systat -swap 交换分区
systat -mbufs 网络缓冲区
systat -vmstat 虚拟内存
systat -netstat 网络
systat -icmp ICMP协议
systat -ip IP协议
systat -tcp TCP协议
systat -ifstat 网卡

显示PCI总线设备信息

pciconf -lv

显示内核加载的模块

kldstat -v

显示指定模块

klsdstat -m ipfilter

即插即用设备

pnpinfo

显示设备占用的IRQ和内存地址

devinfo -u
cpu
sysctl -a|grep cpu
sysctl -a|grep sched 查看使用的调度器

虚拟内存

vmstat

硬盘

gstat
systat -iostat
iostat

网卡

ifconfig
systat -ifstat

网络

netstat
sockstat
tcpdump
trafshow

Tags: ,

星期六, 3月 13th, 2010 服务器 没有评论
Pages: Prev 1 2 3 ... 5 6 7 8 9 10 11 12 13 14 15 Next
1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr