文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>安装php加速器eAccelerator

安装php加速器eAccelerator

时间:2008-04-13  来源:huzi1986


Installing from source
These steps help you compile eAccelerator on UNIX-like systems. eAccelerator has been reported to compile on Linux, FreeBSD, OpenBSD, Mac OS X, Solaris, AIX and HP-UX.
Requirements
php4 or php5
autoconf
automake
libtool
m4
1,要安装依赖的包---我的系统是centos 如果没有安装选择
#yum -y install autoconf automake libtool m4
eAccelerator only works with mod_php or php in fastcgi mode. It can't be used in cgi or cli because eAccelerator needs to set up shared memory, and this can only be done when all php instances that need to access it are forks of the first process.
Installation
Step 1. Compiling eAccelerator
You need to run these commands in the eAccelerator source directory. eAccelerator supports multiple php branches so you need to bootstrap eAccelerator first. This can be done with the phpize script. It very important that you use the phpize script of the php version for which you want to compile eAccelerator. The phpize and php-config scripts are available in the development packages of your distro. For fedora this is php-devel, for debian php-dev, other distribution should be similar.
When you have only one php install, it's safe to run these commands in the source directory: (进入安装目录,输入phpize 如果出现command not found 代表没有安装php-devel包
yum -y install php-devel)
#phpize
The phpize and php-config are the ones that are in your path. When you have more then one php install or the phpize and php-config scripts aren't in your path then you should follow this procedure. This example has php installed in /opt/php, this is the path of the --prefix option given to the php configuration script.
export PHP_PREFIX="/opt/php"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
For more information about the options for the configure script you should read the CompileConfiguration page.
After compilation, there should be a "eaccelerator.so" file in the modules subdirectory of the eAccelerator source directory.
Step 2. Installing eAccelerator
#make install
This will copy the previously created eAccelerator binary to the php extension directory. When this command ends, it will print out the directory in which eAccelerator has been installed.
Step 3. Configuring eAccelerator
eAccelerator can be installed both as Zend or PHP extension. When you install eAccelerator as a zend_extension you need to give the full path to the eaccelerator.so library.

把相关设置添加到php.ini 第一个设置是对于安装了zend的。。第二是没有安装zend的设置
If you have /etc/php.d directory, you should copy eaccelerator.ini to it and modify the default values. 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 a 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
One last very important step is creating the cache directory that you configured in the previous step. The default value is /tmp/eaccelerator It's easy because it's writable to everyone, but it isn't very smart because on a lot of systems this directory is cleaned on reboot. A better place would be /var/cache/eaccelerator. Create the directory and make sure it's writable for the user eAccelerator runs under (usually the user which you webserver runs as).
A safe bet is making it world writable. A safer and cleaner way would be to change the owner of the directory to the same user PHP runs as (most of the time the same user as Apache or Lighttpd) and set 0644 permissions.
The lazy way:
#mkdir /tmp/eaccelerator
#chmod 0777 /tmp/eaccelerator
Step 5. Checking if it works
You need to restart the webserver eAccelerator is running under. Usually this will be Apache, if using eAccelerator with Lighttpd and fastcgi, you need to kill the main PHP fastcgi server.



相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载