Here is a short tutorial on compiling and installing
eaccelerator for PHP. First off, you need root access to the
server to install eaccelerator. If you do not have root access
but want to use eaccelerator send your host a link to this page
and explain to them why you need eaccelerator. A decent host
would install it for you.
eaccelerator is an opcode cacher (caches the compiled version of php scripts so php does not have to compile it for each request of the page). It has the ability to cache in shm (shared memory) making access to this cache very fast. eaccelerator can also handle sessions (see php code below).
First step: change directory to /usr/local/src and download the latest source tarball. Make sure you get the latest. When writing this the latest was 0.9.5.3. Get the latest from http://bart.eaccelerator.net/source/
Step 2: untar the downloaded file and change directory to inflated directory
Step 3: phpize if phpize is not in your PATH find where phpize is (locate phpize or whereis phpize) and type in its full path
Step 4: configure eaccelerator. In the example given, eaccelerator is built with session support as well as shm support
Step 5: build binary
Step 6: install binary
*Note you have to be in /etc/sudoers (usually wheel group) to sudo, otherwise "su root" then "make install"
Step 7: Create eaccelerator tmp directory and set permissions
Step 8: Edit php.ini (locate php.ini to find your php.ini) (if nano is not installed, type "vi" in place of "nano")
Add the following settings: MUST BE BEFORE Zend settings
Final step: restart web server (example is apache)
*Note you might have to restart it twice. I really have no explanation for this but sometimes the first restart does not work.
Everything together (good for copy and paste into terminal):
Finally, check if eaccelerator is installed correctly. You can do this by running php with the flag -i. To filter output to what WE want to see, pipe the output to grep and search for eAccelerator
If no output is produced, then eaccelerator was not installed successfully.
Alternatively create a page called phpinfo.php containing:
and go to http://your.site/phpinfo.php to view it. In the box that says "This program makes use of the Zend Scripting Language Engine:" it should also say "with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator" if it is installed successfully.
On another note, to use eaccelerator for sessions use the following PHP code:
eaccelerator is an opcode cacher (caches the compiled version of php scripts so php does not have to compile it for each request of the page). It has the ability to cache in shm (shared memory) making access to this cache very fast. eaccelerator can also handle sessions (see php code below).
First step: change directory to /usr/local/src and download the latest source tarball. Make sure you get the latest. When writing this the latest was 0.9.5.3. Get the latest from http://bart.eaccelerator.net/source/
Bash Code:
cd /usr/local/src wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
Step 2: untar the downloaded file and change directory to inflated directory
Bash Code:
tar jfxv ./eaccelerator-0.9.5.3.tar.bz2 cd ./eaccelerator-0.9.5.3
Step 3: phpize if phpize is not in your PATH find where phpize is (locate phpize or whereis phpize) and type in its full path
Code:
phpize
Step 4: configure eaccelerator. In the example given, eaccelerator is built with session support as well as shm support
Bash Code:
./configure --with-eaccelerator-sessions --with-eaccelerator-shared-memory
Step 5: build binary
Bash Code:
make
Step 6: install binary
Bash Code:
sudo make install
*Note you have to be in /etc/sudoers (usually wheel group) to sudo, otherwise "su root" then "make install"
Step 7: Create eaccelerator tmp directory and set permissions
Bash Code:
mkdir /tmp/eaccelerator chown nobody:nobody /tmp/eaccelerator chmod 777 /tmp/eaccelerator
Step 8: Edit php.ini (locate php.ini to find your php.ini) (if nano is not installed, type "vi" in place of "nano")
Bash Code:
nano /usr/local/lib/php.ini
Add the following settings: MUST BE BEFORE Zend settings
.ini config file Code:
extension="eaccelerator.so" eaccelerator.shm_size="32" 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"
Final step: restart web server (example is apache)
Bash Code:
/usr/local/apache/bin/apachectl restart
*Note you might have to restart it twice. I really have no explanation for this but sometimes the first restart does not work.
Everything together (good for copy and paste into terminal):
Bash Code:
cd /usr/local/src wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2 tar jfxv ./eaccelerator-0.9.5.3.tar.bz2 cd ./eaccelerator-0.9.5.3 ./configure --with-eaccelerator-sessions --with-eaccelerator-shared-memory make sudo make install mkdir /tmp/eaccelerator chown nobody:nobody /tmp/eaccelerator chmod 777 /tmp/eaccelerator nano /usr/local/lib/php.ini /usr/local/apache/bin/apachectl restart
Finally, check if eaccelerator is installed correctly. You can do this by running php with the flag -i. To filter output to what WE want to see, pipe the output to grep and search for eAccelerator
Bash Code:
php -i | grep eAccelerator
If no output is produced, then eaccelerator was not installed successfully.
Alternatively create a page called phpinfo.php containing:
PHP Code:
<?php phpinfo(); ?>
and go to http://your.site/phpinfo.php to view it. In the box that says "This program makes use of the Zend Scripting Language Engine:" it should also say "with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator" if it is installed successfully.
On another note, to use eaccelerator for sessions use the following PHP code:
PHP Code:
<?php // check to make sure that the function exists if( function_exists('eaccelerator_set_session_handlers') ) { // use eaccelerators function to set the session handlers eaccelerator_set_session_handlers(); } // setting the session handlers MUST MUST MUST come before session_start(); session_start(); ?>
No comments:
Post a Comment