云烟计算-你是云儿我是烟
RSS 图标 Email 图标 首页图标
  • How to enable runkit PHP extension with lampp

    发表于 2009年09月18日 yejun 1 条评论

    Lampp的php extension目录如下:

    [root@www no-debug-non-zts-20060613]# pwd

    /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613

    [root@www no-debug-non-zts-20060613]# ll

    total 2144

    -rwxr-xr-x 1 root root 52784 Sep 24 2008 dbx.so

    -rwxr-xr-x 1 root root 137256 Sep 24 2008 eaccelerator.so

    -rwxr-xr-x 1 root root 28021 Jun 11 09:57 facedetect.so

    -rwxr-xr-x 1 root root 979070 Feb 27 2009 http.so

    -rwxr-xr-x 1 root root 81600 Sep 24 2008 interbase.so

    -rwxr-xr-x 1 root root 147440 Sep 24 2008 ming.so

    -rwxr-xr-x 1 root root 116440 Sep 24 2008 oci8.so

    -rw-r–r– 1 1000 1000 14354 Jun 7 2006 package2.xml

    -rw-r–r– 1 1000 1000 9820 Jun 7 2006 package.xml

    -rwxr-xr-x 1 root root 110444 Sep 24 2008 pgsql.so

    -rwxr-xr-x 1 root root 35408 Sep 24 2008 radius.so

    drwxr-xr-x 8 root root 4096 Sep 18 14:57 runkit-0.9

    -rw-r–r– 1 root root 49807 Sep 18 14:47 runkit-0.9.tgz

    -rwxr-xr-x 1 root root 177751 Sep 18 14:57 runkit.so

    -rwxr-xr-x 1 root root 59828 Sep 24 2008 sqlite.so

    -rwxr-xr-x 1 root root 56864 Sep 24 2008 zip.so

    新加载了这个runkit.so到php.ini里。

    runkit

    runkit support

    enabled

    version

    0.9

    Custom Superglobal support

    enabled

    Sandbox Support

    disable or unavailable

    Runtime Manipulation

    enabled

     

    过程如下:

    • 下载runkit

        在extension目录下,使用pear download runkit 成功下载runkit-0.9.tgz

    Fix is as follows

    Edit the file /usr/local/src/runkit-0.9/runkit_import.c and change the following line

    zend_unmangle_property_name(key, &cname, &pname);

    To:

    zend_unmangle_property_name(key, key_len, &cname, &pname);


    Again continue with the installation steps.

    #cd /usr/local/src/runkit-0.9
    #make
    #make install


    Edit the loaded PHP configuration file ( here /usr/local/lib/php.ini ) and add the following line.

    extension=runkit.so


    You can verify the runkit extension by

    root@host[/usr/local/src/runkit-0.9]# php -i | grep -i runkit
    runkit
    runkit support => enabled

    PHP
  • Yii:CI的又一对手出现了

    发表于 2009年07月18日 admin 没有评论

    Yes, it is Yii — a high-performance component-based PHP framework best for developing large-scale Web applications. Yii comes with a full stack of features, including MVC, DAO/ActiveRecord, I18N/L10N, caching, jQuery-based AJAX support, authentication and role-based access control, scaffolding, input validation, widgets, events, theming, Web services, and so on. Written in strict OOP, Yii is easy to use and is extremely flexible and extensible.

    又将是一个流行框架,吸收了很多现在流行ROR技术和快速开发的工具。

  • Writing hadoop mapreduce program in php

    发表于 2009年03月18日 admin 1 条评论

    最近在作营销效果分析的需求,需要处理大量网页访问日志(千万级PV以上),HADOOP在这方面正好有用武之地。PHP是一个简单实用的语言,我 很喜欢。影响我最大的计算机语言,除了LISP,就是PHP了(python这类的脚本语言学起来也很舒服)。于是我准备在我的D630本本上玩玩php in hadoop.

    • 先下载VMWARE PLAYER:

    The virtual machine image is designed to be used with the free VMware Player.

    VMware Player 2.5.1

    Latest Version: 2.5.1 | 2008/11/21 | Build: 126130

    http://www.vmware.com/download/player/

    • 下载hadoopvm

    Download the VMWare image here:

    http://code.google.com/intl/zh-CN/edu/parallel/tools/hadoopvm/index.html

    启动hadoopvm

    • 去掉原来的源;然后加入源,否则feisty不能升级包;:
    vi /etc/apt/sources.list

    deb http://ubuntu.cn99.com/ubuntu/ feisty main restricted universe multiverse

    deb http://ubuntu.cn99.com/ubuntu/ feisty-security main restricted universe multiverse

    deb http://ubuntu.cn99.com/ubuntu/ feisty-updates main restricted universe multiverse

    deb http://ubuntu.cn99.com/ubuntu/ feisty-proposed main restricted universe multiverse

    deb http://ubuntu.cn99.com/ubuntu/ feisty-backports main restricted universe multiverse

    deb-src http://ubuntu.cn99.com/ubuntu/ feisty main restricted universe multiverse

    deb-src http://ubuntu.cn99.com/ubuntu/ feisty-security main restricted universe multiverse

    deb-src http://ubuntu.cn99.com/ubuntu/ feisty-updates main restricted universe multiverse

    deb-src http://ubuntu.cn99.com/ubuntu/ feisty-proposed main restricted universe multiverse

    deb-src http://ubuntu.cn99.com/ubuntu/ feisty-backports main restricted universe multiverse

    • 执行apt-get update 更新包;
    • 确认当前用户是ROOT

    Login as user ‘root’ (password ‘root’),

    • run ‘apt-get install php5-cli’ to install PHP5.
    • Now switch to user ‘guest’ (password ‘guest’).
    • php -v查看当前PHP是否安装好

    (图1)

    • 生成两个程序:mapper.php和reducer.php

    #!/usr/bin/php

    <?

    $word2count = array();

    // input comes from STDIN (standard input)

    while (($line = fgets(STDIN)) !== false) {

    // remove leading and trailing whitespace and lowercase

    $line = strtolower(trim($line));

    // split the line into words while removing any empty string

    $words = preg_split(’/\W/’, $line, 0, PREG_SPLIT_NO_EMPTY);

    // increase counters

    foreach ($words as $word) {

    $word2count[$word] += 1;

    }

    }

    // write the results to STDOUT (standard output)

    // what we output here will be the input for the

    // Reduce step, i.e. the input for reducer.py

    foreach ($word2count as $word => $count) {

    // tab-delimited

    echo $word, chr(9), $count, PHP_EOL;

    }

    ?>

    reducer.php

    #!/usr/bin/php

    <?

    $word2count = array();

    // input comes from STDIN

    while (($line = fgets(STDIN)) !== false) {

    // remove leading and trailing whitespace

    $line = trim($line);

    // parse the input we got from mapper.php

    list($word, $count) = explode(chr(9), $line);

    // convert count (currently a string) to int

    $count = intval($count);

    // sum counts

    if ($count > 0) $word2count[$word] += $count;

    }

    // sort the words lexigraphically

    //

    // this set is NOT required, we just do it so that our

    // final output will look more like the official Hadoop

    // word count examples

    ksort($word2count);

    // write the results to STDOUT (standard output)

    foreach ($word2count as $word => $count) {

    echo $word, chr(9), $count, PHP_EOL;

    }

    ?>

    • chmod +x /home/guest/mapper.php /home/guest/reducer.php
    • 准备程序所需要的作为输入的文本文件的目录,

    mkdir /tmp/countfile

    • 下载远程的两个TXT文本作为输入

    wget http://pge.rastko.net/dirs/2/0/4/1/20417/20417-8.txt

    wget http://www.pg-news.org/nl_archives/2009/pgmonthly_2009_01_21.txt

    • 把文件放入HADOOP 的DFS中

    cd /home/guest/hadoop/

    bin/hadoop dfs -copyFromLocal /tmp/countfile countfile

    • 执行php程序处理这些文本

    bin/hadoop jar contrib/hadoop-streaming.jar -mapper /home/guest/mapper.php -reducer /home/guest/reducer.php -input countfile/* -output countfile-output


    • 查看输出的结果

    bin/hadoop dfs -ls countfile-output

    bin/hadoop dfs -cat countfile-output/part-00000

    参考:

    http://www.lunchpauze.com/2007/10/writing-hadoop-mapreduce-program-in-php.html

    http://hadoop.apache.org/core/docs/current/mapred_tutorial.html#Example%3A+WordCount+v1.0

  • PHP性能调优好工具XDEBUG+WINCACHEGRIND

    发表于 2007年06月2日 admin 1 条评论

    下载对应PHP版本的xdebug: [url]http://www.xdebug.org[/url] 下载wincachegrind:[url]http://sourceforge.net/projects/wincachegrind/[/url] 配置php.ini: 我的是PHP5.2.2使用5.2.1的xdebug.dll extension=php_xdebug-2.0.0rc4-5.2.1.dll [Xdebug] xdebug.profiler_enable=on xdebug.trace_output_dir=”d:/APMXE5/xdebug” xdebug.profiler_output_dir=”d:/APMXE5/xdebug” 在d:/APMXE5/xdebug会生成cachegrind.out.2336这样的文件。使用wincachegrid打开就可以看到哪些方法调用占的时间多。 在LINUX也有相应的软件读取cachegrind.out.2336这样的文件。上次看到Rambus在作报靠使用的MAC机器上的一个工具,也很好看。 Functionality The Xdebug extension helps you debugging your script by providing a lot of valuable debug information. The debug information that Xdebug can provide includes the following: stack and function traces in error messages with: full parameter display for user defined functions function name, file name and line indications support for member functions memory allocation protection for infinite recursions Xdebug also provides: profiling information for PHP scripts script execution analysis capabilities to debug your scripts interactively with a debug client

    PHP