provides software and services that enable enterprises
Live Chat 1-888-673-6564

Open Source Software Technical Articles

  • Home
  • Search
  • Contact Us
  • Products and Support
  • Services
  • Enterprise OSS Blog
  • Wazi Technical Blog
  • About Wazi
  • Attributions and Licensing
  • Supply Chain Compliance
  • How to Contribute
  • Contributors
  • Resources Library
  • Cloud Services
  • Partners
  • Customers
  • Community
  • Company
  • Careers
  • News and Events

Subscribe to Wazi by Email

Your email:


Enterprise Developer Support 24 x 7, Get a Support Quote Now!


click-here-to-chat-with-an-online-representative

download-oss-discovery

Latest Posts

  • The secret to great reporting with Drupal 7
  • A more colorful LibreOffice unveiled
  • Toward a more colorful LibreOffice
  • Flexible administration with Puppet's Facter and templates
  • Knock for OpenSSH
  • Get more out of phpMyAdmin
  • Image annotation in GIMP, Dia, and OpenOffice Draw
  • Solr, Drupal 7, and faceted search
  • Using FreeNAS' new full disk encryption for ZFS
  • Create distributed storage with Gluster

Connect with Us!

Current Articles | RSS Feed RSS Feed

Improve PHP performance with PHP eAccelerator

Posted by Aditya Patawari on Mon, Sep 24, 2012
  
Email This Email Article  
Tweet  
  

Today, most websites of any complexity incorporate PHP code in their HTML. PHP eAccelerator can help you improve the performance of your PHP scripts by up to 10 times by caching PHP scripts in their compiled state, reducing the overhead incurred by compiling the scripts every time a user requests them. The compiled scripts are stored in and executed from shared memory, though if a script is too big, PHP eAccelerator can store it on disk. PHP eAccelerator supports PHP5 and is lighter and faster than any other optimizer I have come across.

Installing PHP eAccelerator is easy. For CentOS or Red Hat, you can install its binary package from the Extra Packages for Enterprise Linux (EPEL) repository. If you don't already have the EPEL repository, its FAQ explains how to add it to your system. You can then install eAccelerator with the command yum install php-eaccelerator.

If PHP eAccelerator is not available in a binary package for your Linux distribution, you can build it from source. Download the PHP eAccelerator source and extract it using the command tar -xzvf master. Run phpize in the source directory, then run ./configure and make to compile it, and install it with make install. When the software is installed, you should see the new file eaccelerator.so in your PHP modules directory – usually /usr/lib64/php/modules/ for 64-bit servers.

Configuring PHP eAccelerator

If you install PHP eAccelerator using yum, it creates the file eaccelerator.ini in your /etc/php.d/ directory, and you're ready to run. If you did a source install, append the following lines to your php.ini file:

; Name of the extension
extension="eaccelerator.so"

; shared memory size in magabytes
eaccelerator.shm_size="16"

; the directory to be used as disk cache
eaccelerator.cache_dir="/tmp/eaccelerator"

; "1" to enable the eaccelerator, 0 to disable it
eaccelerator.enable="1"

; "1" to enable the code optimizer, 0 to disable it
eaccelerator.optimizer="1"

; "1" to enable the php file modification checking, 0 to disable it
eaccelerator.check_mtime="1"

; "1" to enable the debug logging, 0 to disable it
eaccelerator.debug="0"

; Determine which PHP files must be cached. You can give wild cards here.
eaccelerator.filter=""

; When eAccelerator fails to get shared memory for new script it removes all scripts which were not accessed at last "shm_ttl" seconds from shared memory.
eaccelerator.shm_ttl="0"

; When eAccelerator fails to get shared memory for new script it tries to remove old script if the previous try was made more then "shm_prune_period" seconds ago.
eaccelerator.shm_prune_period="0"

; Enables or disables caching of compiled scripts on disk.
eaccelerator.shm_only="0"

You can find a complete list of all the program's options with detailed explanations in the project's wiki.

Make sure that the directory you specified for eAccelerator's cache exists. If you have to create it, make sure it is writable by the user that runs your webserver – usually apache or nobody or www-data. To start eAccelerator, restart your web server, then verify that eAccelerator is really loaded by executing the command php -v . The last line in the output of that command should indicats that eAccelerator has been loaded and is ready for action.

If you want a more detailed check, you can run phpinfo() in a PHP script. To do that, create a file with the contents below and move it to your website:

<?php
  phpinfo(); 
?

Open the file on your site and you should see an entire section of details on eAccelerator.

eaccelerator resized 600

Similar PHP optimizers

PHP eAccelerator should make a noticeable difference in the performance of any busy PHP-based website. Many benchmarks suggest that it is the fastest of all the optimizers out there – but it's not your only option.

APC, the Alternative PHP Cache, provides another framework for caching and optimizing PHP intermediate code. It may not be as fast as PHP eAccelerator, and it has a larger memory footprint, but it is better maintained; it is developed by PHP project volunteers themselves, and has a better chance of long-term support.

If you use lighttpd as your web server, look at XCache PHP Optimizer, which is developed by one of lighttpd's core developers. The project generally puts out new releases of XCache quickly after a new version of PHP comes out.

Other optimizers include ionCube PHP Accelerator (PHPA) and Zend Optimizer+, which is a part of Zend Server.

However, if you plan to run your website on PHP 5.x and need a small memory footprint, you're willing to make do with only community support, and you're not afraid to experiment, I strongly suggest that you go for PHP eAccelerator. The performance improvement should make your website's users happy.

Follow @openlogic
Follow @OSCloudServices

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.
Tags: PHP, Technical

Comments

g
Posted @ Sunday, April 07, 2013 1:18 AM by nikoleta
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics

Loading...
Error sending email
Email sent successfully

Email article
Email To : 
Your name : 
Message : (maximum 200 characters)
Home | Search | Contact Us | Products and Support | Services | Enterprise OSS Blog | Wazi Technical Blog | Resources Library | Cloud Services | Partners | Customers | Community | Company | Careers | News and Events
Products
OpenLogic Exchange (OLEX)
License Compliance Module
OSS Discovery
OSS Deep Discovery
OpenUpdate
Services
Open Source Support
CentOS Support
Scanning & Compliance
Open Source Training
Professional Services
Solutions
Support & Indemnification
Open Source Governance
Open Source Scanning
Open Source Provisioning
Consulting & Training
Contact Us
1-888-673-6564


© 2013 OpenLogic, Inc. All rights reserved.
Site Map  |  Privacy Policy