| home | forums |
resources |
search |
news | join | members: 6375 |
Hiveminds | Thu, 2007-08-30 07:33 tags: PHP, Tutorials, Web Developer EAccelerator is a free open-source PHP accelarator, optimizer, and dynamic content cache. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelarator typically reduces server load and increases the speed of your PHP code by 1-10 times. This is the second part of a series on how to install PHP on a shared web host and optimize it with a cache handler. Here we take a look at installing eAccelarator. eAccelarator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelarator code is still based on his work. eAccelarator is still under development. The latest release, 0.9.5, supports PHP 4 and all PHP 5 releases including 5.2. In older releases, the encoder will only work with PHP versions from the 4.x.x branch. eAccelarator will not work with any other versions of PHP. Get started by saving the following code to *.sh. FTP upload the script to your account root. Then set the permissions via FTP to 755. Start putty or whatever shell gui you are using and run the script in your shell by typing ./nameofscript.sh. If problems are encountered the script will stop. Fix the problems and run the script again. I have run this script several times without any errors. But is perfect. This is a much better and less time consuming way of using SHELL. Typing line by line and troubleshooting along the way is only for the sadistic. #!/bin/sh
# Abort on any errors
set -e
# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!*** We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source
# And where should it be installed?
INSTALLDIR=${HOME}/php5/
# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist
# Pre-download clean up!!!!
rm -fr $SRCDIR $DISTDIR
# Update version information here.
AUTOCONF="autoconf-2.61"
AUTOMAKE="automake-1.9.6"
EAC="eaccelerator-0.9.5"
# What PHP features do you want enabled?
EACFEATURES="--prefix=${INSTALLDIR} \
--enable-eaccelerator=shared \
--with-php-config=$PHP_PREFIX/bin/php-config"
# ---- end of user-editable bits. Hopefully! ----
# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH
#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}
# Get all the required packages
wget -c http://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz
wget -c http://ftp.gnu.org/gnu/automake/${AUTOMAKE}.tar.gz
wget -c http://bart.eaccelerator.net/source/0.9.5/${EAC}.tar.bz2
echo ---------- Unpacking downloaded archives. This process may take several minutes! ----------
cd ${SRCDIR}
# Unpack them all
echo Extracting ${AUTOCONF}...
tar xzf ${DISTDIR}/${AUTOCONF}.tar.gz
echo Done.
echo Extracting ${AUTOMAKE}...
tar xzf ${DISTDIR}/${AUTOMAKE}.tar.gz
echo Done.
echo Extracting ${EAC}...
tar -xjf ${DISTDIR}/${EAC}.tar.bz2
echo Done.
export PATH=${SRCDIR}/bin:$PATH
export PHP_PREFIX=${INSTALLDIR}/bin
# Build them in the required order to satisfy dependencies.
#AUTOCONF
cd ${SRCDIR}/${AUTOCONF}
./configure --prefix=${SRCDIR}
# make clean
make
make install
#AUTOMAKE
cd ${SRCDIR}/${AUTOMAKE}
./configure --prefix=${SRCDIR}
# make clean
make
make install
#EAC
cd ${SRCDIR}/${EAC}
$PHP_PREFIX/phpize
./configure --enable-eaccelerator=shared --with-eaccelerator-info --with-php-config=$PHP_PREFIX/php-config
# make clean
make
#copy config file
cp modules/eaccelerator.so ${INSTALLDIR}/lib/php/extensions/eaccelerator.so
mkdir -p ~/tmp/eaccelerator
rm -fr $SRCDIR $DISTDIR
echo ---------- INSTALL COMPLETE! ----------
Now to set up your PHP. You only need to make additions to the php.ini. Since you should be running PHP in FCGI mode there is no restarting of Apache needed. [eaccelerator] extension="eaccelerator.so" eaccelerator.allowed_admin_path="/home/user/www.domain.co.uk" 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 everything is fine then you should be seeing eAccelerator information as shown in these images ![]() ![]() Many that install eAccelarator immediately look in the temp file directory expecting to see files. They take this as a sign that eAccelerator is working. But this is not the way to check because eAccelarator stores compiled PHP scripts in shared memory and executes code directly from it. It creates locks only for a short time, while searching for a 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. If you look at the above image you can see that the shared memory is very close to being used up. At the point that this happens then it would be possible to look at the server disk and check for cache files. Next we'll take a look at installing another popular caching system, APC. eAccelarator is a caching extension for PHP. It requires that PHP be run in FCGI mode. Rather than changing the name on the binary I create two of them in the same directory so switching back and forth is easy. But you can just rename your present php.cgi to php.fcgi as long as it has support for FCGI. To turn on FastCGI at Dreamhost and use PHP as FastCGI you will first have to go into the control panel and set the domain properties for FastCGI. ![]() Then use the following in your .htaccess file for that domain. # PHP 5, Apache 1 and 2 Options +ExecCGI AddHandler fastcgi-script fcg fcgi fpl AddHandler php5-fastcgi .php Action php5-fastcgi /cgi-bin/php5.fcgi
This article brought to you by the
Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously |
Silverlight London Hotels
Silverlight Laptop Reviews
Wordpress Just Dial International Calls
Content Management Systems Excel Training Courses
Wordpress excel courses in london
ASP.NET Data Recovery
Adobe Flex
|
||||||
NewsletterGet updates on Hiveminds services, articles and downloads by signing up for the newsletter. |
Editor's choiceSome of the better articles, stories and tutorials found at Hiveminds. |
Find moreFind more of Hiveminds articles, stories, tutorials and user comments by searching. |
Picked linksHand picked websites and articles from around the web that provide quality reading. |