Archlinux: Lighttpd下配置Django

July 4th, 2009

假定我们需要在/home/site/demo下开发一个基于Django的网站,域名是www.demo.com,如果准备使用Lighttpd的FastCGI模式运行,那么可以进行如下的配置:

首先是按装必要的软件包

# pacman –S lighttpd fcgi python django python-flup

准备好我们的目录

# mkdir /home/site/demo
# cd /home/site/demo
# django-admin.py startproject demo

然后要配置Lighttpd,第一要确保mod_rewrite, mod_fastcgi, mod_alias, mod_access, mod_accesslog等模块已启用,然后增加如下内容:

$HTTP["host"]==www.demo.com {
     server.document-root="/home/site/demo/"
     fastcgi.server=(
         "/runfcgi" =>(
             "main" =>(
                 "host" => "127.0.0.1",
                 "port" => 3333,
                 "check-local" =>"disable",
             )
         ),
     )
     url.rewrite-once = (
         "^(/media.*)$" => "$1",
         "^/favicon.ico$" => "/media/favicon.ico",
         "^(/.*)$" => "/runfcgi$1",
     )
     alias.url += ("/media/" => "/usr/lib/python2.6/site-packages/django/contrib/admin/media/")

}

在/home/site/demo/下建立运行脚本runfcgi:

PROJDIR="/home/site/demo"
PIDFILE="$PROJDIR/demo.pid"
cd $PROJDIR
if [ -f $PIDFILE ]; then
     kill `cat -- $PIDFILE`
     rm -f -- $PIDFILE
fi

exec /usr/bin/env python ./manage.py runfcgi method=threaded host=127.0.0.1 port=3333 pidfile=$PIDFILE

如何运行lighttpd并启动django站点呢?

# /etc/rc.d/lighttpd start
# /home/site/demo/runfcgi
Author: xchange Categories: Linux, 网站开发 Tags: , , , ,

PHP 5.3.0和Firefox 3.5正式发布

July 2nd, 2009

PHP 5.3.0和Firefox 3.5均于当地时间6月30日发布,PHP的新版本还未使用过,但是Firefox 3.5的Windows版用了一下觉得不是很稳定,频繁崩溃,并且插件的兼容性不好。

PS: PostgreSQL 8.4在6月29日发布了

Author: xchange Categories: 杂七杂八 Tags: ,

Archlinux: CPU频率调节

May 4th, 2009

针对本人的E2160

首先安装相关软件

# pacman –S cpufrequtils

然后加载内核模块

# modprobe acpi-cpufreq

修改配置

# vim /etc/conf.d/cpufreq

——— Begin /etc/conf.d/cpufreq ———

#configuration for cpufreq control
# valid governors:
#  ondemand, performance, powersave,
#  conservative, userspace
governor="ondemand"

# valid suffixes: Hz, kHz (default), MHz, GHz, THz
min_freq="1.2GHz"
max_freq="1.8GHz"

——— End /etc/conf.d/cpufreq ———

运行守护进程

# /etc/rc.d/cpufreq start

最后将相应的模块和守护进程写到/etc/rc.conf中

Author: xchange Categories: Linux Tags:

Test

March 20th, 2009

地图图片

Author: xchange Categories: 杂七杂八 Tags:

Windows Live Wrtier

March 20th, 2009

可以自动检测WordPress的设置,很方便地发布日志。谨以此篇作为测试。

fedora-6

Author: xchange Categories: 杂七杂八 Tags:

所谓的“PHP on Windows 性能测试报告”

December 9th, 2008

PHPChina的第十四期PHPer杂志中包含了一个所谓的“PHP on Windows 性能测试报告”,得出结论:PHP在Windows 2008+IIS7平台上的表现超过了LAMP平台。

该报告的缺点十分明显:

  1. 没有说明各个平台上PHP的详细配置方法,最起码应该交待一下PHP在Apache下是mod_php模式还是FastCGI模式
  2. 压力测试没有说明具体的测试方法
  3. 缺少重复
Author: xchange Categories: 网站开发 Tags: , , ,

PHP: 在数组中特定位置增加一个元素

November 19th, 2008
  1. $a=array('apple', 'banana', 'orange');
  2. var_dump($a);
  3. /* It will output:
  4. array(3) {
  5.   [0]=>
  6.   string(5) "apple"
  7.   [1]=>
  8.   string(6) "banana"
  9.   [2]=>
  10.   string(6) "orange"
  11. }
  12. */
  13.  
  14. array_splice($a,2,0,'grape');
  15. var_dump($a);
  16. /* It will output:
  17. array(4) {
  18.   [0]=>
  19.   string(5) "apple"
  20.   [1]=>
  21.   string(6) "banana"
  22.   [2]=>
  23.   string(5) "grape"
  24.   [3]=>
  25.   string(6) "orange"
  26. }
  27. */
Author: xchange Categories: 网站开发 Tags:

PHP命名空间诞生记

November 11th, 2008

提供图片一张!

Author: xchange Categories: 网站开发 Tags: ,

我也曾如此矫情

November 10th, 2008

“世界是美丽的也是丑陋的。没有人可以统一一个美与丑的标准,但我知道价值观在其中扮演着很重要的角色。”

“不管是美是丑,总得面对现实,不能逃避。”

“在那个遥远的日子,我们许下了无法实现的约定……”

2005年的我就是这个样子吗?那个虚幻的我们究竟意味着什么样的精神诉求?

http://blog.donews.com/xchange/有感而发。

Author: xchange Categories: 杂七杂八 Tags:

我在实验室用的电脑

November 8th, 2008

是不是很强大啊?

Author: xchange Categories: 杂七杂八 Tags: