VPS is the CentOS system, PHP for Nginx+fastcgi,nginx installation directory/usr/local/nginx,php installation directory/usr/local/php, start in Linux install PHP accelerator eaccelerator Bar!
Pre-compiling installation Eaccelerator
Prepare before installation
Use need to install make and phpize prior to installation, skip this step if installed. Run the following command
The code is as follows |
Copy Code |
Yum Install make Php5-dev Ubuntu with the Apt-get
|
Install Eaccelerator
Then start downloading Eaccelerator, configure installation compilation:
The code is as follows |
Copy Code |
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2 Tar xjf eaccelerator-0.9.6.1.tar.bz2 CD eaccelerator-0.9.6.1 /usr/bin/phpize ./configure-enable-eaccelerator=shared-with-php-config=/usr/bin/php-config Make Make install
|
The eaccelerator will be installed in the PHP directory and the screen will display the eaccelerator.so path
For example:
The code is as follows |
Copy Code |
Installing shared extensions:/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/
|
Remember this path, which will be used in the configuration file that follows.
Configuring the Eaccelerator Cache path
The code is as follows |
Copy Code |
Mkdir/tmp/eaccelerator chmod 777/tmp/eaccelerator
|
Configure Eaccelerator
After installing eaccelerator, you need to configure to use OH ~ so we need to add eaccelerator configuration in php.ini, of course, you can also create a new configuration file, in php.ini to introduce a configuration file.
code is as follows |
copy code |
[eaccelerator" zend_extension= "/usr/local/webserver/php/lib/php/" Extensions/no-debug-non-zts-20060613/eaccelerator.so " eaccelerator.shm_size=" 8″ 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= "3600 ″ eaccelerator.shm_prune_period= "3600″ eaccelerator.shm_only=" 0″ eaccelerator.compress= "1″ Eaccelerator.compress_level= "9″ Eaccelerator.keys =" Disk_only " Eaccelerator.sessions =" Disk_only " Eaccelerator.content = "Disk_only" |
Several important configuration instructions
are installed as the above configuration for the Zend extension mode, and if you are installing PHP in thread safe mode, you must replace the second line with "Zend_extension_ts" zend_extension ", install the PHP extension mode as" extension ".
Cache_dir: The cached folder location is the path to our mkdir in the previous step.
Shm_size: The size of the cache, depending on your server's actual settings
Enable: Turn Eaccelerator on or off, "1″ is on," 0″ is off. The default value is 1″.
Optimizer: The internal optimizer is turned on or off to increase code execution speed. "1″ is turned on," 0″ is closed. The default value is 1″.
Check_mtime: Turn on or off PHP's file modification check, "1″ means open," 0″ means close. The default value is "1″."
Debug: Turn debug logging on or off. "1″ is turned on," 0″ is closed. The default value is 0″. Writes a cache hit record to the log.
Filter: Determines which PHP files must be cached. You can specify cached and not cached file types (such as "*.php *.phtml", and so on) if the arguments start with "!", the files that match those parameters are ignored for caching. The default value is "", that is, all PHP files will be cached.
Shm_max: Prevents large files from being stored in shared memory when the "eaccelerator_put ()" function is used. This parameter specifies the maximum value that is allowed to be stored, in bytes (10240, 10K, 1M). "0″ is not limited." The default value is 0″.
Shm_ttl: When the shared memory size that Eaccelerator obtains a new script fails, it deletes all script caches that were not accessed in the last "Shm_ttl" seconds from the shared memory. The default value is "0″," to remove any cached files from shared memory.
Shm_prune_period: When Eaccelerator has failed to get the shared memory size of the new script, he will attempt to remove cache scripts older than "Shm_prune_period" from shared memory. The default value is "0″," to remove any cached files from shared memory.
Shm_only: Allows or disables caching of compiled scripts on disk. This option is not valid for session data and content caching. The default value is 0″, which is cached for use with disk and shared memory.
Compress: Allows or disables the compression of content caching. The default value is "1″," to allow compression.
Compress_level: Specifies the compression level for the content cache. The default value is 9″, which is the highest level.
The code is as follows |
Copy Code |
Eaccelerator.keys = "Disk_only" Eaccelerator.sessions = "Disk_only" Eaccelerator.content = "Disk_only" |
The place where the content cache is stored can be set to:
Shm_and_disk in shared cache and hard disk (default)
SHM shared memory exists by default, if shared memory is full or size exceeds "Eaccelerator.shm_max" value, save to hard drive
shm_only only stored in shared memory
Disk_only is only stored on the hard drive
None does not cache data
Restart related services
# Restart Nginx
/etc/init.d/nginx restart
# Restart PHP-CGI
/etc/init.d/php-fastcgi restart
View Eaccelerator operation
Eaccelerator installation package has a control.php file, copy it to any directory of the site, and then add the path to the configuration file, you can use it to view and manage the eaccelerator, this must be specified, otherwise see the cached content will be error, Access time default Username is: admin, Password: eaccelerator, username and password can be modified in control.php:
Eaccelerator.allowed_admin_path = "/data/wsdata/wwwroot"
This allows us to view the eaccelerator hit rate by accessing control.php, as well as cleaning the cache directory online to see the configured cache space usage.