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:
mkdir ea modules
chmod 0777 /tmp/eaccelerator/
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:
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:
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:
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:
eaccelerator.cache_dir="/home1/(CPANEL USER NAME)/tmp/eaccelerator"
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. 🙂