Chinaunix首页 | 论坛 | 博客
  • 博客访问: 299222
  • 博文数量: 61
  • 博客积分: 1508
  • 博客等级: 上尉
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-13 08:26
文章分类

全部博文(61)

文章存档

2010年(1)

2009年(1)

2007年(59)

我的朋友

分类: BSD

2007-10-12 15:45:16

What for? Nginx is a great replacement of Apache with very low memory footprint and contrary to Lighttpd, doesn't suffer from memory leak over time. You can then use all the memory left to unleash the power of mysql for instance by increasing the default query cache.

真的有传说中的好吗?呵呵,试一下先。

Step1 安装必备软件
    MySQL+PHP+Pcre
cd /usr/ports/database/mysql50-server && make install clean
cd /usr/lang/php5/ && make install clean
cd /usr/devel/pcre && make install clean

Step2 安装FastCgi(借用lighttpd的spawn-cgi)
wget
tar -xvjf lighttpd-1.4.18.tar.bz2 cd lighttpd-1.4.18
cd lighttpd-1.4.18
./configure
make
cp src/spawn-fcgi /usr/bin/spawn-fcgi

vi /usr/bin/php-fastcgi

#!/bin/sh

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -f /usr/local/bin/php-cgi

chmod 755 /usr/bin/php-fastcgi

vi /etc/rc.d/init-fastcgi

#!/bin/bash

PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
    start)
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    stop)
      killall -9 php
      RETVAL=$?
  ;;
    restart)
      killall -9 php
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL

chmod 755 /etc/rc.d/init-fastcgi

Step3 安装Nginx(本文用目前稳定版)
wget
tar xvzf nginx-0.5.32.tar.gz
cd nginx-0.5.32
./configure (默认安装在/usr/local/nginx)
make && make install

Step4 配置Nginx (主要修改)
cp conf/fastcgi_params /usr/local/nginx/conf/fastcgi_params

location / {
     root /var/www/wordpress; (此处就是你的web根目录)
            index index.php index.html index.htm;
        }

location ~ .*\.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
            include /usr/local/nginx/conf/fastcgi_params;
        }


Step5 启动了,呵呵
/etc/rc.d/init-fastcgi start
/usr/local/nginx/sbin/nginx 效果如下:


阅读(3611) | 评论(0) | 转发(0) |
0

上一篇:偶尔看了滨海的一个报道

下一篇:BSD随记

给主人留下些什么吧!~~