修改符号链接的属主的方法 (Linux/Unix)
发布于 2008-01-15 18:49 阅读:141,459 评论:0 标签: Linux 方法 链接

    如下,检查为FreeBSD 4.8p-STABLE

以下是引用片段:
autoinstall# uname -a
FreeBSD autoinstall 4.8p-STABLE FreeBSD 4.8p-STABLE #0: Sun Nov  9 04:39:25 GMT 2003     root@dell1550.sina.com.cn:/usr/obj/usr/src/sys/SINA  i386

    我当前为root

以下是引用片段:
autoinstall# whoami
root

    建立一个文件

以下是引用片段:
autoinstall# touch a

autoinstall# ls -l
-rw-r--r--  1 root       wheel    0 Jan 15 17:38 a

    建立一个软连接:

以下是引用片段:
autoinstall# ln -s a b
autoinstall#
autoinstall# ls -l
-rw-r--r--  1 root       wheel    0 Jan 15 17:38 a
lrwxr-xr-x  1 root       wheel    1 Jan 15 17:38 b -> a

    现在我想修改b的属主:

以下是引用片段:
autoinstall# chown yayu b
autoinstall#
autoinstall# ls -l
-rw-r--r--  1 root       wheel    0 Jan 15 17:38 a
lrwxr-xr-x  1 root       wheel    1 Jan 15 17:38 b -> a

    很遗憾,失败了!确定yayu这个用户是存在的。于是上chinaunix问了一下,嗯,感谢ports 的回答。教训:学会man的好习惯!

    解决如下:加个“-h”参数

    在linux下man结果为:

以下是引用片段:
       -h, --no-dereference
              affect  each  symbolic  link  instead  of any referenced file (useful only on systems that can change the ownership of a symlink)

    在freebsd下man为:

以下是引用片段:
     -h      If the file is a symbolic link, change the user ID and/or the
             group ID of the link itself.


展开全文  
收起全文  
libeven、memcached、libmemcache安装 (Linux/Unix)
发布于 2007-12-21 19:31 1 阅读:96,797 评论:1 标签: libeven libmemcache Linux memcached 安装

    前端时间玩了一下memcached,由于工作关系得过一段时间在玩它。哎,工作就是这样,老变!

    libeven

    memcached的使用需要libeven的支持,我们得先装上libeven。
    官方网站:http://www.monkey.org/~provos/libevent/
    下载地址:http://www.monkey.org/~provos/libevent-1.4.0-beta.tar.gz
    libevent安装方式比较简单:

以下是代码片段:
./configure && make
make install
    这样就好

    检查如下:

以下是引用片段:
[root@localhost memcached-1.2.2]# ls -l /usr/local/lib/ | grep even
lrwxrwxrwx   1 root root      21 Nov 26 11:32 libevent-1.4.so.2 -> libevent-1.4.so.2.0.0
-rwxr-xr-x   1 root root  267334 Nov 26 11:32 libevent-1.4.so.2.0.0
-rw-r--r--   1 root root  351694 Nov 26 11:32 libevent.a
lrwxrwxrwx   1 root root      26 Nov 26 11:32 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.0.0
-rwxr-xr-x   1 root root  101485 Nov 26 11:32 libevent_core-1.4.so.2.0.0
-rw-r--r--   1 root root  139080 Nov 26 11:32 libevent_core.a
-rwxr-xr-x   1 root root     866 Nov 26 11:32 libevent_core.la
lrwxrwxrwx   1 root root      26 Nov 26 11:32 libevent_core.so -> libevent_core-1.4.so.2.0.0
lrwxrwxrwx   1 root root      27 Nov 26 11:32 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.0.0
-rwxr-xr-x   1 root root  214596 Nov 26 11:32 libevent_extra-1.4.so.2.0.0
-rw-r--r--   1 root root  273270 Nov 26 11:32 libevent_extra.a
-rwxr-xr-x   1 root root     873 Nov 26 11:32 libevent_extra.la
lrwxrwxrwx   1 root root      27 Nov 26 11:32 libevent_extra.so -> libevent_extra-1.4.so.2.0.0
-rwxr-xr-x   1 root root     831 Nov 26 11:32 libevent.la
lrwxrwxrwx   1 root root      21 Nov 26 11:32 libevent.so -> libevent-1.4.so.2.0.0

    看见有很多libevent,就可以放心了。

    memcached

    官方网站:http://www.danga.com/memcached/download.bml
    下载地址:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz

    memcached安装需要些参数:

以下是代码片段:
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local
make
make install

   我们来运行看看:
   运行:

以下是代码片段:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root

    结果:
以下是引用片段:
[root@localhost memcached-1.2.2]# /usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

    查找原因,解决方案如下:

以下是代码片段:
LD_DEBUG=libs /usr/local/memcached/bin/memcached -v

    有如下显示:

以下是引用片段:
[root@localhost memcached-1.2.2]# LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
     18999:     find library=libevent-1.4.so.2 [0]; searching
     18999:      search cache=/etc/ld.so.cache
     18999:      search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib          (system search path)
     18999:       trying file=/lib/tls/i686/sse2/libevent-1.4.so.2
     18999:       trying file=/lib/tls/i686/libevent-1.4.so.2
     18999:       trying file=/lib/tls/sse2/libevent-1.4.so.2
     18999:       trying file=/lib/tls/libevent-1.4.so.2
     18999:       trying file=/lib/i686/sse2/libevent-1.4.so.2
     18999:       trying file=/lib/i686/libevent-1.4.so.2
     18999:       trying file=/lib/sse2/libevent-1.4.so.2
     18999:       trying file=/lib/libevent-1.4.so.2
     18999:       trying file=/usr/lib/tls/i686/sse2/libevent-1.4.so.2
     18999:       trying file=/usr/lib/tls/i686/libevent-1.4.so.2
     18999:       trying file=/usr/lib/tls/sse2/libevent-1.4.so.2
     18999:       trying file=/usr/lib/tls/libevent-1.4.so.2
     18999:       trying file=/usr/lib/i686/sse2/libevent-1.4.so.2
     18999:       trying file=/usr/lib/i686/libevent-1.4.so.2
     18999:       trying file=/usr/lib/sse2/libevent-1.4.so.2
     18999:       trying file=/usr/lib/libevent-1.4.so.2
     18999:
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

    主要是看最后一行提示的错误,那么我们:

以下是代码片段:
ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2

    OK!再次运行:

以下是代码片段:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
    成功!

    貌似用“ldconfig”也可以解决这个问题

     libmemcache   

    libmemcache是memcached C的客户端之一。我准备使用这个玩意。
    官网:http://people.freebsd.org/~seanc/libmemcache/
    下载:http://people.freebsd.org/~seanc/libmemcache/libmemcache-1.4.0.rc2.tar.bz2
    编译:

以下是代码片段:
./configure
make
make install

     写一个有libmemcache函数的程序
     然后    

以下是代码片段:
gcc a.c -o a.cgi -L/usr/local/include -lmemcache


    运行

以下是代码片段:
./a.cgi

    提示类似上面的“error while loading shared libraries”的错误,查了一下可用"ldconfig"解决这个问题,那上面的可否用这个命令解决呢?

    上面的gcc编译的时候,带有参数“-lmemcache”。
    -l参数后面跟的库名有规则的,库的命名方式有libxxxx.so或libxxxx.a,编译时要用-lxxxx就可以了。
    而“-l”的意思就是代表是个“lib”了。

    所以在你自己编写动态库或者静态库时,命名还是得按照 libxxxx.so的形式来。

    不得不认为libmemcache有点糟糕,编译它自带的一个程序编译竟然有问题,很无语!

以下是引用片段:
[root@login benchmark]# gcc benchmark.c -L/usr/local/include -lmemcache
benchmark.c: In function `main':
benchmark.c:100: warning: passing arg 2 of `mc_set' discards qualifiers from pointer target type
benchmark.c:108: warning: passing arg 2 of `mc_set' discards qualifiers from pointer target type
benchmark.c:121: warning: passing arg 2 of `mc_req_add' discards qualifiers from pointer target type
benchmark.c:145: warning: passing arg 2 of `mc_delete' discards qualifiers from pointer target type
benchmark.c:153: warning: passing arg 2 of `mc_add' discards qualifiers from pointer target type
benchmark.c:167: warning: passing arg 2 of `mc_delete' discards qualifiers from pointer target type

    解决方法:

    找到passing arg 2这个参数的定义:

以下是引用片段:
const char *key;

    把const去了:
以下是引用片段:
char *key;

    这样就好了!

    然后:

以下是代码片段:
[root@login memcache-test]# ./a.out

    执行时可能报以下的错误:

以下是引用片段:
./a.out: error while loading shared libraries: libmemcache.so.0: cannot open shared object file: No such file or directory

    解决方法:

    执行ldconfig命令即可!


    附:

    http://kapoc.blogdriver.com/kapoc/1200549.html
    ldconfig命令 - - 动态链接库管理命令

    为了让动态链接库为系统所共享,还需运行动态链接库的管理命令--ldconfig.此执行程序存放在/sbin目录下.

    ldconfig命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态链接库(格式如前介绍,lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件.缓存文件默认为/etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表.

    ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令.

展开全文  
收起全文  
cgi的写法 (C/C++学习)
发布于 2007-12-05 19:57 2 阅读:60,441 评论:2 标签: C C++ Linux

      CGI虽然差不多已经被淘汰,但在大公司有时还是需要用到的。编写、编译和升级的确是件很麻烦的事情。

      个人感觉写CGI主要是两个方面,一个是头信息;一个是让服务器知道它是个CGI。头信息用“Content-type”指定;而要让服务器知道,则把文件放进服务器专门为CGI而准备的目录,否则会被服务器认为的个二进制文件。当然这个目录是可以自己指定的,对apache而言就是httpd.conf文件中“cgi-bin”的位置。

      下面是一个简单的C++例子:

以下是代码片段:

#include <iostream>

using namespace std;

main()
{
 cout << "Content-type: text/html; charset=gb2312\n\n";
 cout << "www.yayu.org" << flush;
 exit(0);
}

展开全文  
收起全文  
memcached英文文档学习 (C/C++学习)
发布于 2007-12-04 17:58 1 阅读:66,120 评论:1 标签: Linux memcached 学习 英文

      今天看了memcached wiki的FAQ,觉得有几句话对了解memcached很有作用,与大家共享一下。

      服务器的内存如何分配问题:

以下是引用片段:
Because a 32-bit process can only address 4GB of virtual memory (usually significantly less, depending on your operating system), if you have a 32-bit server with 4-64GB of memory using PAE you can just run multiple processes on the machine, each using 2 or 3GB of memory.

     memcached之get过程,看点在于client/server的hash key处理:

以下是引用片段:
When doing a memcached lookup, first the client hashes the key against the whole list of servers. Once it has chosen a server, the client then sends its request, and the server does an internal hash key lookup for the actual item data.

      client/server的hash key算法差异:

以下是引用片段:
Different client implementations store data into memcached differently (perl Storable, php serialize, java hibernate, JSON, etc). Some clients also implement the hashing algorithm differently. The server is always the same however.

      当一个memcached down后的情况:

以下是引用片段:
 Remove dead nodes from your list. Be very careful! With default clients adding or removing servers will invalidate all of your cache! Since the list of servers to hash against has changed, most of your keys will likely hash to different servers. It's like restarting all of your nodes at the same time.

      key/value大小的说明:

以下是引用片段:
 Keys are restricted to 250 characters. Stored data cannot exceed 1 megabyte in size, since that is the largest typical slab size.

      数据存储的处理方式:

以下是引用片段:
 At first memcached did just use malloc/free for everything. However this does not play very well with OS memory managers. You get fragmentation, and your OS ends up spending more time trying to find contiguous blocks of memory to feed malloc() than it does running the memcached process.

      如何处理数据过期的问题:

以下是引用片段:
 When do expired cached items get deleted from the cache?

 memcached uses a lazy expiration, which means it uses no extra cpu
 expiring items. When an item is requested (a get request) it checks
 the expiration time to see if the item is still valid before returning
 it to the client.

 Similarly when adding a new item to the cache, if the cache is full,
 it will look at for expired items to replace before replacing the
 least used items in the cache.

      尤其是对数据过期的处理让偶意外,虽然省CPU,但很浪费空间。

       下面是几个常用的链接:

以下是引用片段:
 memcached'home
http://danga.com/memcached/

memcached'wiki
http://www.socialtext.net/memcached/index.cgi

memcached'faq
http://www.socialtext.net/memcached/index.cgi?faq

memcached'Protocol
http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt

memcached'consistent hashing
http://www.last.fm/user/RJ/journal/2007/04/10/392555/

展开全文  
收起全文  
PHP加速器eAccelerator文档翻译 (PHP心得)
发布于 2007-11-06 11:02 1 阅读:62,315 评论:1 标签: eAccelerator Linux PHP 翻译 文档

  前端时间用到这个,看了一下英文文档觉得还是看最原始的资料看到的东西最全。比如说eAccelerator自带了共享内存管理的程序,这个在我找到的中文资料里面就没有看到过。

  本文翻译的是:Release-0.9.5.2 ,官网是:http://www.eaccelerator.net/。原文附后,英文水平不高,如果您发现有不对的地方,还请告诉我!

--------------------------

PHP的eAccelerator
=====================

什么是eAccelerator?
----------------------
eAccelerator是一个的免费、开源的PHP模块,它能够为提供PHP加速、优化、加码、和动态内容缓存功能。它通过存储PH脚本编译后的状态而加快执行PHP脚本的速度,而不需要频繁的编译这个PHP脚本。而且它能优化PHP脚本,以提高执行PHP的速度。eAccelerator特色是减少了服务器负载、使PHP脚本加速1-10倍。

eAccelerator是TurckMMCache的一个分支
(请详见Dmitry Stogov维护的:http://sourceforge.net/project/turckmm-cache/

eAccelerator把编译好的PHP程序存储在共享内存里面,并直接在这里面执行程序。但在共享内存里面寻找编译好的PHP程序时,会在很短的时间内产生一些锁定,所以一个程序可以被多个进程同时执行。不适合放入共享内存的文件将被缓存到硬盘上。

eAccelerator包含了一个PHP加码器和解释器(loader????)。你可以使用encoder.php对你的程序加码,这样在分发程序的时候就可以不给出源码了。加码后的文件可以在任何机子上运行,只要它装有eAccelerator的PHP。加码后的代码不能被恢复,因为它是以编译完了的形式而存储的,而且存储时不包含源码。当然,程序中一些内部的东西可以使用反编译工具(different  reverse  engineering  tools)还原(例如:disassemblers, debuggers等等),但这并不是重要的。

eAccelerator可以和Zend Optimizer的加码器共存。但是在php.ini中Zend Optimizer必须在eAccelerator配置参数的后面。如果你不使用Zend Optimizer的加码器,我们不推荐同时安装Zend Optimizer

eAccelerator不能在CGI模式下运行,但是它能在一些web服务器下的Fast-CGI模式运行,比如:lighttpd。

下面是一些能提供相同作用的产品:
 - Zend Performance Suite (http://www.zend.com/)
 - Alternative PHP Cache (http://pecl.php.net/package/APC)

下载
--------
最新的eAccelerator版本能在下面的页面下载:
http://sourceforge.net/projects/eaccelerator/
版本控制的快照在:
http://snapshots.eaccelerator.net

要求:
--------
apache >= 1.3, mod_php >= 4.1, linux下工具:autoconf, automake, libtool, m4

兼容性:
--------
eAccelerator能与PHP4、PHP5很好的工作,对PHP5.1版本还没很好的兼容。它能使用在Linux, FreeBSD, MacOS X,
Solaris 和 Windows 下的 apache 1.3 and 2, lighttpd 和 IIS.

快速安装:
-------------

你可以在下面的网站上找到更多的安装信息:
http://eaccelerator.sourceforge.net/

注意:在Microsoft Windows下安装,请参考README.win32文件

第一步:编译eaccelerator

  export PHP_PREFIX="/usr"
 
  $PHP_PREFIX/bin/phpize
 
  ./configure \
  --enable-eaccelerator=shared \
  --with-php-config=$PHP_PREFIX/bin/php-config
 
  make

  你必须使用“export”命令指明PHP的安装路径的前缀,它可能是"/usr" "/usr/local",或其它

第二布:安装 eAccelerator

  make install

第三步:配置 eAccelerator

  eAccelerator能做为Zend或PHP的扩展。

对于大于0.9.1版本的eaccelerator,如果你有/etc/php.d目录,你应该复制eaccelerator.ini到里面去,当然你可以根据你的需要修改它。

如果没有,你需要修改你的php.ini文件(通常是/etc/php.ini)

作为Zend的扩展:

  zend_extension="/usr/lib/php4/eaccelerator.so"
  eaccelerator.shm_size="16"
  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="0"
  eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"

  如果你使用thread safe模式安装的PHP,你应该使用“zend_extension_ts”代替“zend_extension”

作为PHP的扩展:

  extension="eaccelerator.so"
  eaccelerator.shm_size="16"
  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="0"
  eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"
 
第四步:建立缓存目录

  mkdir /tmp/eaccelerator
  chmod 0777 /tmp/eaccelerator

 

配置选项
--------

eaccelerator.shm_size
 eAccelerator使用共享内存的总数。单位是MB.
 设置为“0”,则为操作系统默认值。默认为“0”

eaccelerator.cache_dir
 硬盘缓存的目录。eAccelerator存储预编译代码,session数据,内容数据(content)和使用的入口(entres??)。这些数据也能够存储在共享内存里(为了得到更快的通道)。默认为“/tmp/eaccelerator”。

 yayu:建立这个空目录后,在有人访问php页面后会自动建立二级二维目录(0,1.....e,f)(16进制,晕)

eaccelerator.enable
 决定eAccelerator是否有效。“1”为有效,“0”为无效。默认为“1”

eaccelerator.optimizer
 是否使用内置的优化工具加速代码的执行。“1”为是,“0”为否。默认为“1”

eaccelerator.debug
 是否记录eAccelerator debug log。“1”为是,“0”为否。默认为“0”

eaccelerator.check_mtime
 是否检查php程序更新时间。“1”为是,“0”为否。如果你想改变php程序后重编译程序到共享内存,那就应该设置为“1”。默认为“1”

eaccelerator.filter
 决定哪些php文件被缓存。你可能需要指定哪些文件(如:"*.php *.phtml")需要被缓存。如果在文件前加上“!”,那么符合条件的文件将被忽略。默认为"",这以为着所有php文件都会被缓存。

eaccelerator.shm_max
 设置诸如“eaccelerator_put()”之类的函数能往共享内存里面加载数据的大小。单位为MB。“0”为不限制,默认为“0”。

eaccelerator.shm_ttl
 当共享内存空间已满,将删除在“shm_ttl”秒前没有使用的程序。默认为0,为不删除任何文件。

eaccelerator.shm_prune_period
 共享内存已满。前一次操作是在shm_prune_period秒之前,那么这一次将删除所有的旧程序。默认为“0”,意为不删除任何程序。

eaccelerator.shm_only
 是否把编译后程序缓存到硬盘上。这个选项对session数据和内容(content)缓存无效。默认为“0”,意为同时使用共享内存和硬盘做缓存。

eaccelerator.compress
 是否对缓存内容做压缩。默认为“1”,为不压缩。

eaccelerator.compress_level
 压缩的级别,默认和最高都为“9”。

eaccelerator.name_space
 一个对所有键值假拟的字符串。通过在.htaccess文件中设置的这个值,允许两个应用使用相同的键值运行在同一个主机上。

 yayu:命名空间?

eaccelerator.keys
eaccelerator.sessions
eaccelerator.content
 决定那些键,session数据和内容将被缓存,这些可能的值是:

 "shm_and_disk" - 缓存数据在共享内存和硬盘上(默认值)
 "shm"          - 缓存数据在共享内存,如果共享内存已满或者提交的数据大小超过eaccelerator.shm_max,则存储在硬盘上。
 "shm_only"     - 只缓存数据在共享内存
 "disk_only"    - 只缓存数据在硬盘
 "none"         - 不缓存数据

eaccelerator.allowed_admin_path
 允许得到管理信息和管理操作的脚本路径。


控制面板及反汇编
---------------

如果你要使用控制面板,你需要在编译eAccelerator时加上 --with-eaccelerator-info选项,这个是默认值。

复制control.php文件到你的跟目录下,并且设置这个路径到php.ini 或者 eaccelerator.ini的eaccelerator.allowed_admin_path选项。如果你不这样做,你将看不到更多的相关信息,也不能控制eAccelerator。

你可以在control.php文件中设置用户名和密码以进入控制面板

当你使用--with-eaccelerator-disassembler编译时,你需要把dasm.php和PHP_Highlight.php也放到control.php目录里面。反汇编需要在编译PHP时加上对tokenizer的支持(--enable-tokenizer)
你可以在dasm.php文件的上面得到执行反汇编时的用户名和密码


eAccelerator 函数
-----------------

函数文档请看: http://bart.eaccelerator.net/doc/phpdoc/

联系我们
--------
当你有疑问、需要补丁,提交bug,请发email给 Bart Vanbrabant

--------------------------

以下是英文全文:

eAccelerator for PHP
=====================

What is eAccelerator?
----------------------
eAccelerator is a free open source PHP  accelerator,  optimizer,  encoder  and
dynamic content cache for PHP. It increases  performance  of  PHP  scripts  by
caching them in compiled state, so that the overhead of  compiling  is  almost
completely eliminated. It also optimises  the  script  to speed  up  execution
of PHP scripts. eAccelerator typically reduces server load and  increases  the
speed of your PHP code by 1-10 times.

eAccelerator is a fork of TurckMMCache
( http://sourceforge.net/project/turckmm-cache/  by Dmitry Stogov )

eAccelerator stores compiled PHP scripts in shared memory  and  executes  code
directly from it. It creates  locks  only  for  short  time,  while  searching
compiled PHP script in the cache, so one script can be executed simultaneously
by several engines. Files that can't fit in shared memory are cached  on  disk
only.

eAccelerator contains a PHP encoder and loader. You  can  encode  PHP  scripts
using encoder.php in order to distribute them without sources.  Encoded  files
can be run on any site which  runs  PHP  with  eAccelerator.  The  sources  of
encoded scripts can't be restored because they are stored in a  compiled  form
and the encoded version doesn't contain the source. Of course, some  internals
of the scripts can  be  restored  with  different  reverse  engineering  tools
(disassemblers, debuggers, etc), but it is not trivial.

eAccelerator is compatible with Zend Optimizer's loader. Zend  Optimizer  must
be installed after eAccelerator in php.ini. If you don't use  scripts  encoded
with  Zend  Encoder  we  do  not  recommend  to  install  Zend  Optimizer with
eAccelerator.

eAccelerator does not work in CGI mode but it does work in Fast-CGI mode with
webservers like lighttpd.


Here are some other products that provide the same functionality:

 - Zend Performance Suite (http://www.zend.com/)
 - Alternative PHP Cache (http://pecl.php.net/package/APC)

Download
--------
Latest eAccelerator versions can be downloaded at the sourceforge page:
http://sourceforge.net/projects/eaccelerator/
Development snapshots from cvs can be downloaded at
http://snapshots.eaccelerator.net


Requirements
------------
apache >= 1.3, mod_php >= 4.1, autoconf, automake, libtool, m4


Compatibility
-------------
eAccelerator has been reported working with php4 and php5, php 5.1 support
hasn't been integrated yet. It is being used on Linux, FreeBSD, MacOS X,
Solaris and Windows with apache 1.3 and 2, lighttpd and IIS.


Quick install
-------------

You can find more information about installation on eAccelerator website.
http://eaccelerator.sourceforge.net/

Note(1): for Microsoft Windows installation, please refer to README.win32 file.

Step 1. Compiling eAccelerator

  export PHP_PREFIX="/usr"
 
  $PHP_PREFIX/bin/phpize
 
  ./configure \
  --enable-eaccelerator=shared \
  --with-php-config=$PHP_PREFIX/bin/php-config
 
  make

  You must specify the real prefix where PHP is installed in the "export"
  command. It may be "/usr" "/usr/local", or something else.

Step 2. Installing eAccelerator

  make install

Step 3. Configuring eAccelerator

eAccelerator can be installed both as Zend or PHP extension.

For eaccelerator > 0.9.1, if you have /etc/php.d directory, you should copy eaccelerator.ini inside and modify default value if you need.

If not, you need to edit your php.ini file (usually /etc/php.ini).

To install as Zend extension:

  zend_extension="/usr/lib/php4/eaccelerator.so"
  eaccelerator.shm_size="16"
  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="0"
  eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"

  If you use thread safe build of PHP you must use "zend_extension_ts" instead
  of "zend_extension".

To install as PHP extension:

  extension="eaccelerator.so"
  eaccelerator.shm_size="16"
  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="0"
  eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9" 

Step 4. Creating cache directory

  mkdir /tmp/eaccelerator
  chmod 0777 /tmp/eaccelerator


Configuration Options
---------------------

eaccelerator.shm_size
    The amount of shared memory (in megabytes) that eAccelerator will use.
    "0" means OS default. Default value is "0".

eaccelerator.cache_dir
    The directory that is used for disk cache. eAccelerator stores precompiled
    code, session data, content and user entries  here. The same data  can  be
    stored in shared memory also (for more quick access). Default value is
    "/tmp/eaccelerator".

eaccelerator.enable
    Enables or disables eAccelerator. Should be "1" for enabling  or  "0"  for
    disabling. Default value is "1".

eaccelerator.optimizer
    Enables or disables internal peephole optimizer which may  speed  up  code
    execution. Should be "1" for enabling or "0" for disabling. Default  value
    is "1".

eaccelerator.debug
    Enables or disables debug logging. Should be "1" for enabling or  "0"  for
    disabling. Default value is "0".

eaccelerator.check_mtime
    Enables or disables PHP file modification checking .  Should  be  "1"  for
    enabling or "0" for disabling. You should set it to "1"  if  you  want  to
    recompile PHP files after modification. Default value is "1".

eaccelerator.filter
    Determine which PHP files must be cached. You may specify  the  number  of
    patterns (for example "*.php *.phtml") which specifies to cache or not  to
    cache. If pattern starts with the character "!", it means to ignore  files
    which are matched by the following pattern. Default value is "" that means
    all PHP scripts will be cached.

eaccelerator.shm_max
    Disables putting large values into shared memory by " eaccelerator_put() "
    function. It indicates the largest allowed size in bytes (10240, 10K, 1M).
    The "0" disables the limit. Default value is "0".

eaccelerator.shm_ttl
    When eaccelerator fails to get shared memory for new script it removes all
    scripts which were not accessed  at  last "shm_ttl"  seconds  from  shared
    memory. Default value is "0" that means -  don't  remove  any  files  from
    shared memory.

eaccelerator.shm_prune_period
    When eaccelerator fails to get shared memory for new script  it  tryes  to
    remove  old  script   if   the   previous   try   was   made   more   then
    "shm_prune_period" seconds ago. Default value is "0" that  means  -  don't
    try to remove any files from shared memory.

eaccelerator.shm_only
    Enables or disables caching of compiled scripts on disk. It has  no  effect
    on session data and content caching. Default value is "0" that means -  use
    disk and shared memory for caching.

eaccelerator.compress
    Enables or disables cached content compression. Default value is  "1"  that
    means enable compression.

eaccelerator.compress_level
    Compression level used for content caching.  Default value is "9" which  is
    the maximum value

eaccelerator.name_space
    A string that's prepended to all keys. This allows two applications that
    use the same key names to run on the same host by setting this in .htaccess
    or in the main configuration file for the whole webserver.
   
eaccelerator.keys
eaccelerator.sessions
eaccelerator.content
    Determine where keys, session data and content will be cached. The possible
    values are:
    "shm_and_disk" - cache data in shared memory and on disk (default value)
    "shm"          - cache data in shared memory or on disk if shared memory
                     is full or data size greater then "eaccelerator.shm_max"
    "shm_only"     - cache data in shared memory
    "disk_only"    - cache data on disk
    "none"         - don't cache data

eaccelerator.allowed_admin_path
    The script paths that are allowed to get admin information and do admin
    controls

Control panel and disassembler
------------------------------

If you want to use the control-panel you need to compile eAccelerator with
    --with-eaccelerator-info which is the default value.
You need to copy the control.php file to your webroot and set the path to it
in the php.ini or eaccelerator.ini in the eaccelerator.allowed_admin_path
directive. If you don't do this you wont be able to see much information and
can't control eAccelerator.
You can set the username and password needed to access the control-panel in
the control.php file.

When you compile eAccelerator with --with-eaccelerator-disassembler you need
to place the dasm.php and PHP_Highlight.php file also in the same directory
as the control.php file. The disassembler requires PHP to be compiled with
tokenizer support (--enable-tokenizer).
You can set the username and password needed to access the disassembler at the
top of dasm.php.

eAccelerator API
----------------

API documentation can be found on this website: http://bart.eaccelerator.net/doc/phpdoc/

Contact us
----------
You can contact us with questions, patches or bugs, by sending an email to
Bart Vanbrabant

展开全文  
收起全文