文章标签 ‘php’

转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/
Nginx与php-cgi是两个独立的程序,通过TCP或Unix套接字通信,不像Apache那样是集成在一起的。所以,Nginx有fastcgi 缓冲区,数据超出缓冲区大小、或程序执行完,才会将内容输出到客户端。如果要使用ob_flush,不能开启gzip压缩输出。
nginx.conf:
fastcgi_buffer_size 4k;
fastcgi_buffers 8 4k;
gzip off;
php.ini:

output_buffering = Off

<?php
set_time_limit(0);
ob_end_clean();
ob_implicit_flush(1);

for($i = 0; $i < 10; $i++)
{
echo $i . "<br />\n";
echo str_repeat('', 1024*4);
sleep(1);
}

其中 echo str_repeat('', 1024*4);
使得fastcgi_buffer_size 4k; 的缓冲区满,从而输出内容到浏览器
参考: http://blog.s135.com/nginx_php_v6/2/1/
-- EOF --

2010年3月8日11:45 | 没有评论

转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/lighttpd_phpfastcgi_config/
php(fastcgi) 5.2.6 编译参数

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-gd=/usr --enable-calendar --with-zlib --with-bz2 --with-curl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-openssl --enable-zend-multibyte --with-gettext --enable-exif --with-png-dir=/usr --with-jpeg-dir=/usr --with-libxml-dir=/usr --enable-gd-native-ttf --enable-dom --with-freetype-dir=/usr --with-iconv-dir=/usr --enable-fastcgi

lighttpd 1.5.0 编译参数

./configure --prefix=/usr/local/lighttpd --with-mysql=/usr/bin/mysql_config --with-openssl --with-pcre --with-bzip2 --enable-lfs --with-linux-aio

添加fastcgi 及lighttpd执行用户

groupadd www
useradd -g www -s /sbin/nologin -d /dev/null www

复制lighttpd源码包内 doc/spawn-php.sh 并修改如下

#!/bin/bash

## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/usr/local/lighttpd/bin/spawn-fcgi"

## ABSOLUTE path [...]

2008年6月15日19:06 | 没有评论
标签: , ,

转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/configure_lamp/
编译环境
Debian (Ubuntu)

apt-get install build-essential
apt-get install libncurses5-dev
sudo apt-get install libxml2-dev libcurl3-dev libpng-dev libmhash-dev libmcrypt-dev libxslt-dev libpspell-dev

Mysql编译安装参数
CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
配置成功会提示:
MySQL has [...]

2008年3月18日16:35 | 2 条评论

转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/use_dbprefix_in_zendframework/
目录结构

在 config.ini 定义 prefix
[general]
adapter = PDO_MYSQL
host = localhost
username = root
password = 123456
dbname = test
charset = utf8
prefix = pf_ //表前缀
index.php 中将 prefix 注册
// 读取数据库配置
$dbconfig = new Zend_Config_Ini('../config/config.ini', 'general');
// 配置数据库
$database = Zend_Db::factory($dbconfig->adapter,$dbconfig->toArray());
// 设置数据库编码
$database->query("set names {$dbconfig->charset};");
Zend_Db_Table::setDefaultAdapter($database);
Zend_Registry::set('database',$database);
// 数据表前缀
Zend_Registry::set('dbprefix',$dbconfig->prefix);
在 library/Custom 目录下新建文件 Db.php 继承 Zend_Db_Table 类
class [...]

2008年1月17日23:07 | 没有评论

转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/cakephp_note/
1. 自定义 layout
在 cakephp 中 layout 默认指向 /app/views/layouts/default.thtml
如果要自定义 layout,需要在 controller 中定义:
var $layout = 'mydefault';
layout 则指向了 /app/views/layouts/mydefault.thtml
2. 创建不使用数据库表的 model 或者改变 model 对应的表名
我需要创建一个不使用任何表的model。例如,我想通过 $validate 数组方便底验证输入数据,保持model逻辑的正确性。但创建 model 时对应的表不存在,CakePHP 就会报错。通过在 model 中加入以下代码可以解决这个问题:
var $useTable = false;
你也可以通过这种方法改变model对应的表名。
var $useTable = 'some_table';
3. 快速创建后台管理
如果你需要创建后台管理程序,并且希望所有管理action都位于某个特定文件夹下,那么打开 config/core.php 并将下面这一行的注释去掉:
define('CAKE_ADMIN', 'admin');
这样所有以"admin_"开头的action都可以通过 /admin/yourcontroller/youraction 来访问。例如,如果在 posts controller 中创建了名为 "admin_add" 的 action,那么可以通过 www.example.com/admin/posts/add 访问这个action。这样就可以方便地为 admin 目录设置密码以避免他人随意访问。
4. 自定义404页面
如果你需要自定义404页面,只需创建 /app/views/errors/error404.thtml。
5. 让controller使用其他model
如果你的controller需要调用来自不同model的数据,只要在controller开头使用如下代码:
class [...]

2007年11月13日01:31 | 没有评论
页数 1 of 3123