Eaccelerator Accelerated PHP Program

Source: Internet
Author: User
Tags echo date install php php script php tutorial safe mode

Eaccelerator Accelerated PHP Tutorial Program

What is Eaccelerator

Concept:
Eaccelerator is a free and open source PHP accelerated, optimized, compiled, and dynamically cached project that can

By caching the PHP code after compiling the results to improve the performance of the PHP script, making it always very complex and away from our

The remote PHP script compilation problem is completely resolved. By using Eaccelerator, you can optimize your PHP generation

Code execution speed, reduce server load, can improve PHP application execution speed up to 10 times times.

Principle:
Eaccelerator by caching the compiled PHP code into shared memory and when the user accesses it

It can be called directly to play an efficient acceleration effect. It's very efficient, from creating shared memory to finding a

The translated code is completed in a very short time, and for files and code that cannot be cached in shared memory,

Eaccelerator can also cache them on the system disk.
Eaccelerator also supports the compilation and interpretation of PHP code, and you can use the encoder.php script

To compile the PHP code to protect the code, the compiled code must run in the installation

Eaccelerator in the environment. Eaccelerator compiled code can not be decompile, it is not like the other one

Some compile tools that can be decompile, which makes the code more secure and efficient.
Note: When searching for compiled PHP programs in shared memory, some locks are generated in a very short period of time.

So a program can be executed concurrently by multiple processes. Files that do not fit into shared memory will be cached to a hard

On the plate

Eaccelerator installation Configuration

1. Support Platform
Because Aaccelerator provides most of the shared memory based APIs, the *nix platform will get more

Good support, although it also releases the binary version based on Windows platform, but I am here to provide only based on

*nix platform Configuration and description, currently can support the platform includes Linux, FreeBSD, OpenBSD, Mac

OS X, Solaris, Aix en-UX.

2, system requirements
PhP4 or PHP5
Autoconf
Automake
Libtool
M4
Eaccelerator only supports PHP installed using mod_php or fastcgi mode

3, installation
First go to the Eaccelerator official download the latest version of the source package:

#tar-ZXVF./eaccelerator-0.9.5-beta2.tar.bz2
#cd Eaccelerator-0.9.5-beta2
#export php_prefix= "/usr/local" (Import the PHP installation directory into the environment variable, FreeBSD

Known as/usr/local)
# $php _prefix/bin/phpize
#./configure--enable-eaccelerator=shared--with-php-

config= $php _prefix/bin/php-config
#make
#make Install
4. ini file configuration
The installation is complete, the php.ini file is configured below, and Eaccelerator provides two ways to configure and invoke

were as follows.

Install as Zend Extension mode:

zend_extension= "/usr/local/lib/php/20050922/eaccelerator.so"
Eaccelerator.shm_size= "16"
Eaccelerator.cache_dir= "/tmp/eaccelerator"
eaccelerator.enable= "1"
Eaccelerator.optimizer= "1"
Eaccelerator.check_mtime= "1"
eaccelerator.debug= "0"
Eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
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 you use the thread safe mode to install PHP, you must use "Zend_extension_ts" for

Change the "Zend_extension" of the first line.

Install as PHP extension mode: (This is the most used way)

extension= "Eaccelerator.so"
Eaccelerator.shm_size= "16"
Eaccelerator.cache_dir= "/tmp/eaccelerator"
eaccelerator.enable= "1"
Eaccelerator.optimizer= "1"
Eaccelerator.check_mtime= "1"
eaccelerator.debug= "0"
Eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
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"
For detailed configuration instructions on the php.ini file, refer to the Readme documentation for the source directory or visit the official document

After completing the installation configuration, we will finally create the cache directory

#mkdir/tmp/eaccelerator
#chmod 777/tmp/eaccelerator

Test

Use eaccelerator acceleration in PHP code

Here's a test code that you can test for eaccelerator powerful power: (The code in

may not be valid in CLI mode)

<?php
Class Test_cache {
  var $pro = ' Hello ';
 
  function Test_cache () {
     echo "Object created!<br>/n";
 }
  function func () {
    echo ', the world! ';
 }
  function Now ($t) {
    echo date (' y-m-d h:i:s ', $t);
 }
}
 
$tt = Eaccelerator_get ("Test_tt");
if (! $tt)
{
  $TT = new Test_cache
  eaccelerator_put ("Test_tt", $tt);
  echo no CAC hed!<br>/n ";
}
Else {
  echo "cached<br>/n";
}
 
Echo $tt->pro;
$tt->func ();
$tt->now (Time () + 86400);
?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.