If you are looking for a way to speed up your PHP pages on Apache, this is the software you want to install. Huge performance gains can be had when using this software to precompile and cache your PHP pages, and it is very simple to install.
– Download the RPM from DAG’s repository here to your CentralPointe Server box.
— For CentralPointe Server 3.0, use the rpm built for Fedora Core2.
— For CentralPointe Server 3.1 & 3.2, use the rpm built for Red Hat EL 4
– Install the software with the following command:
rpm -Uvh php-eaccelerator*
– Restart the webserver with the following command:
service httpd restart
– eAccellerator can be configured by changing the values in the /etc/php.d/eaccelerator.ini file and then restarting the httpd service for those changes to take effect.
All the eAccelerator settings are described here. Every setting can be ommited from the configuration (except the load directive of course), in which case the default value will be used.
You must uncomment one (and only one) line from the following to load the eAccelerator extension.
extension="eaccelerator.so" zend_extension="/usr/lib/php4/eaccelerator.so" zend_extension_ts="/usr/lib/php4/eaccelerator.so" extension="eaccelerator.dll" zend_extension_ts="c:\php4\eaccelerator.dll" zend_extension="c:\php4\eaccelerator.dll"
Take a look at the InstallFromSource page for how you should be determine where eAccelerator is installed, and which of the lines to uncomment.
This setting will allow you to control the amount of shared memory eAccelerator should allocate to cache PHP scripts. The number sets the amount of memory in megabytes. Setting this value to 0 will use the default size.
eaccelerator.shm_size = "0"
On Linux the maximum amount of memory a process can allocate is limited by the number set in /proc/sys/kernel/shmmax. Allocating more than this value will result in eAccelerator failing to initialise. The size in this file is given in bytes. You can raise this amount with:
echo value > /proc/sys/kernel/shmmax
Where value is the size in bytes you want to use. This value is reset to the default value evertime you reboot, but you can raise it permanently by adding the amount you need in /etc/sysctl.conf. This is done by adding:
kernel.shmmax = value
This directory is used for the disk cache. eAccelerator stores precompiled code, session data, content and user entries here. The same data can be stored in shared memory (for quicker access). The default value is “/tmp/eaccelerator”.
eaccelerator.cache_dir = "/tmp/eaccelerator"
This is easy because that directory is easily writable to everyone, and mounted with noexec. However, it isn’t the best because on a lot of systems this directory is cleared on reboot. A better place is /var/cache/eaccelerator. Create the directory and make sure it’s writable to the process eAccelerator runs under.
A safe bet is making it world writeable, a safer and cleaner way is making the user php runs under (most of the time the same user as apache or lighttpd) the owner and set 0644 permissions.
The lazy way:
mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator
With this setting you can enable or disable eAccelerator. This may seem like a pretty stupid setting, but it can be very useful. For example this setting can also be used in the vhost section of the Apache configuration. It allows you to disable eAccelerator for a certian vhost by placing php_admin_value eaccelerator.enable 0 in the vhost section.
Setting this value to “1″ enables eAccelerator, which is also the default value. Setting it to “0″ will disable eAccelerator.
eaccelerator.enable = "1"
Enables or disables the optimizer which may speed up code execution. Setting it “1″ will enable eAccelerator, “0″ disables it. By default the optimizer is enabled. The optimizer will only run when the script is compiled before it’s cached.
eaccelerator.optimizer = "1"
Enables or disables debug logging. Setting this to 1 will print information to the log file about the cache hits of a file. This is only useful when debugging eAccelerator for bug reports.
eaccelerator.debug = 0
Set the log file for eaccelerator. When this option isn’t set then the data will be logged to stderr, when using PHP with Apache these lines will be added to the Apache error log.
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
When using the user cache api for storing data in shared memory, all keys are prepended by the hostname used for the current request. This hostname equals the ServerName? set in the vhost section of apache. This is done to avoid duplicate keys between vhosts. Sometimes this behaviour is desired to share data between vhosts. When setting this option this namespace is used to prepend to each key. By default this is set to “” which instructs eAccelerator to use the hostname as namespace.
When setting this in the main PHP configuration file this namespace will be used by all vhosts. This value can also be set in the vhost section or even in a .htaccess file to allow sharing of data between only two vhosts.
eaccelerator.name_space = ""
On every hit eAccelerator will check the modification time of a script to see if it changed and needs to be recompiled. Although this is a lot faster then opening the file and compiling it, this still adds some overhead because a stat call needs to be done every time. This setting allows you to disable this check. The downside of disabling this check is that you need to manually clean the eAccelerator cache when you update a file.
By default this check is enabled.
eaccelerator.check_mtime = "1"
Determine which PHP files can be cached. You can specify the pattern (for example “*.php *.phtml”) the PHP script filename needs to match. If a pattern starts with “!”, the files that match that pattern are excluded from the cache. Default value is “” which will cache all scripts PHP compiles.
Please note that eaccelerator.filter doesn’t work on a URL basis but rather on the absolute filesystem path, so a filter of !/home* would exclude all scripts in /home from being cached.
Multiple patterns need to be seperated by spaces or tabs, but not commas.
eaccelerator.filter = ""
By default there is no limit on the maximum size a user can put in shared memory with functions like eaccelerator_put, the maximum size is controlled by this setting. This value is the maximum size that can be put in the cache, the size is given in bytes (10240, 10K, 1M). The default value is “0″ which disables the limit.
This setting doesn’t affect the maximum size for a script”’
eaccelerator.shm_max = "0"
When eAccelerator doesn’t have enough free shared memory to cache a new script it will remove all scripts from shared memory cache that haven’t been accessed in at least shm_ttl seconds. By default this value is set to “0″ which means that eAccelerator won’t try to remove any old scripts from shared memory.
eaccelerator.shm_ttl = "0"
When eAccelerator doesn’t have enough free shared memory to cache a script it tries to remove old scripts if the previous try was made more then “shm_prune_period” seconds ago. Default value is “0″ which means that eAccelerator won’t try to remove any old script from shared memory.
eaccelerator.shm_prune_period = "0"
Enable or disable caching of compiled scripts on disk. This has no effect on session data and content caching. Default value is “0″ which allows eAccelerator to use disk and shared memory cacche for scripts.
eaccelerator.shm_only = "0"
When using the eaccelerator_content_* api eAccelerator can compress the content before saving it to memory. By default this is set to “1″, to disable compression set it to “0″.
eaccelerator.compress = "1"
Compression level used for content caching. Default value is “9″ which is the maximum compression level.
eaccelerator.compress_level = "9"
These settings control the places eAccelerator may cache user content. Possible values are:
- shm_and_disk cache data in shared memory and on disk (default value)
- shm cache data in shared memory or on disk if shared memory is full or data size greater then “eaccelerator.shm_max”
- shm_only cache data in shared memory
- disk_only cache data on disk
- none don’t cache data
eaccelerator.keys = "shm_and_disk" eaccelerator.sessions = "shm_and_disk" eaccelerator.content = "shm_and_disk"
eAccelerator can be managed through a webinterface. From version 0.9.5 this webinterface has been fully implemented in php so the settings have been changed.
You need the eaccelerator.php script from the source. For security reasons it’s recommended to restrict the usage of this script by your local IP. You also need to set a user and password. The password setting is a md5 hash of your password. You can create this with the eaccelerator_password.php script from the source.
To create the eAccelerator password type:
php -q eaccelerator_password.php
This control panel uses some admin functions to control eAccelerator. These functions can only be run from scripts that match the path set in eaccelerator.allowed_admin_path. It works in the same way as the open_basedir setting of PHP.
eaccelerator.allowed_admin_path = "/var/www/html/controlpanel"