Install eAccelerator PHP Cache, FastCGI, and zlib Compression On BlueHost

Here’s a tutorial I’ve written to help the web-optimization junkies out there get eAccelerator, FastCGI, and zlib compression working on their BlueHost accounts.

First of all, you’ll need to have SSH access to your account. If you don’t already have it, log into CPanel, click on SSH/Shell Access under the Security header, and submit a photo ID. I took a picture of my driver’s license and uploaded the file last night. BlueHost’s support department works quickly (even on the weekends) since I had my authentication as of this Sunday morning. 🙂

Next, for most users, FastCGI should be utilized. To do this, click on PHP Config under the Software/Services header of your CPanel. Click the bullet next to “PHP5 (Fast CGI)”, click “Save Changes”, and then click “Install php.ini Master File.” You should now have a file called “php.ini.default” under your “public_html” directory. Rename this file to php.ini.

Now we’re going to install eAccelerator. Using an SSH client (I use Coda for Mac, but many people use the free PuTTY client), log into your server. Your username and password are probably the same as what you use to log into CPanel. As soon as you login, you’re going to be in your “~” directory (the same place which has your public_html, public_ftp, ruby, tmp, and other directories). Now type the following:

cd ~
mkdir ea modules
mkdir /tmp/eaccelerator/
chmod 0777 /tmp/eaccelerator/
cd ea
wget https://kent.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.2.tar.bz2
bzip2 -d eaccelerator-0.9.5.2.tar.bz2
tar xvf eaccelerator-0.9.5.2.tar

Basically what you’ve done so far is create three directories (ea for the eAccelerator files, modules which will ultimately contain the eAccelerator module, and tmp/accelerator for the module to use). You’ve downloaded the eAccelerator file and extracted it. Now, continue:

cd eaccelerator-0.9.5.2
export PHP_PREFIX="/usr"
$PHP_PREFIX/bin/phpize

After typing this, you’ll see some lines come up. Here’s a sample:

PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519

So far, so good. Now you’ll be compiling the module. Type this:

./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config

You’ll see many lines scroll across the screen. Then type:

make

Again, you’ll see many lines scrolling as the module is compiled. This is the last SSH step, so if everything completed without errors, log out of your SSH session and log into your server with an FTP client. Navigate to your “/ea/eaccelerator-0.9.5.2/modules/” directory. If everything worked out in your SSH compilation steps, you should see a module called “eaccelerator.so” Move this module to the directory you created earlier: “~/modules” (the directory you created when you created your ea directory in the first SSH step).

Now, edit your /public_html/php.ini file (remember, you renamed it from php.ini.default). A simple text editor like TextEdit for Mac OS X or Notepad for Windows will suffice. You’re going to make the following modifications.

First, locate the variable: zlib.output_compression
If it’s “Off”, make sure you turn it “On” and adjust the level of compression. For example, you want to have something like this:

zlib.output_compression = On
zlib.output_compression_level = 2

This dramatically decreases the page size by gzipping content. Now we have to add the eAccelerator configuration. Locate the “Windows Extensions” section. Right above it, include the following after you CHANGE the third line with your CPanel user name:

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/home1/(CPANEL USER NAME)/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"

Now because we moved our eAccelerator module, we need to redefine the extensions_dir path. Locate extension_dir variable. It’s probably defined as something like

extension_dir = /usr/local/lib/php/extensions/no-debug-zts-20060613

Redefine it as follows by filling in the username with your CPanel username.

extension_dir = "/home1/(CPANEL_USER_NAME)/modules"
 

Now scroll to the bottom of your php.ini file and look for any additional extensions which may be loaded (ie, SQLLite). Remove these extensions since they’re no longer in the newly defined extension_dir path. Reupload the php.ini file into your public_html folder. You’re basically done now. What I did to “refresh” the settings is to go to my CPanel, go to Process Manager under the Advanced header, and force killed all my active processes. Then I navigated to my website, browsed around for a minute, and then viewed my php_info file. I was happy to be greeted by the following:

Since this really is my first true “tutorial”, please let me know if it worked out for you! As far as encountering errors along the way, I’m not sure how much of a help I’ll be, since I’m not an “expert” in these issues, but leave me a comment anyways, and I’ll see what I can do. 🙂

Related Articles

9 COMMENTS

  1. Hi, I’m very glad to read this artical. It helps me a lot. I’m wondering whether I can install both XCache and Eaccelerator. Does the two confict with each other?
    Then, another question. I’m using Hostmonster. Should the extension_dir be like /home/….. instead of /home1/…. ?
    Many thanks.

    • There’s no point in installing both eAccelerator and XCache on the same host (you’ll more than likely run into some sort of script caching error), so I’d just stick with following my XCache installation guide. As far as the extension_dir parameter, I would try both (first start with “home”).

      Glad you found the article helpful. 🙂

  2. Thanks so much for your help on this. I am a writer, not a programmer (and a lover, not a fighter) but I was able to use your instructions to install eaccelerator on my bluehost website.

    • I’m glad to hear that, David! Congrats! Perhaps you’d like to take it one step further and install XCache instead? I wrote up a similar article here. Let me know if you have any questions buddy! 🙂

  3. hello,
    after reading your tutorial i am really tempted to install eaccelerator on my bluehost shared server. The only thing refraining me from doing it is:

    1) you didnt provide a tutorial how to uninstall it in case it does not fit somebody’s need

    2) Is it compatible with wordpress and its plugin?

    3) the procedure you described is taking into consideration how to clear the cache from all of the gzipped files eaccelerator create?

    can you shed some light on these points? thanks!

    • Hey Frank, please consider installing XCache instead. I’ve used both eAccelerator and XCache, and the latter seems to be somewhat faster from my experiences on BlueHost and WordPress.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Try EchoTools - my free, iOS ultrasonography reference application!

Latest Articles