| 1 |
eAccelerator for PHP |
|---|
| 2 |
===================== |
|---|
| 3 |
|
|---|
| 4 |
What is eAccelerator? |
|---|
| 5 |
---------------------- |
|---|
| 6 |
eAccelerator is a free open source PHP accelerator, optimizer, encoder and |
|---|
| 7 |
dynamic content cache for PHP. It increases performance of PHP scripts by |
|---|
| 8 |
caching them in compiled state, so that the overhead of compiling is almost |
|---|
| 9 |
completely eliminated. Also it uses some optimizations to speed up execution |
|---|
| 10 |
of PHP scripts. eAccelerator typically reduces server load and increases the |
|---|
| 11 |
speed of your PHP code by 1-10 times. |
|---|
| 12 |
|
|---|
| 13 |
eAccelerator is a fork of TurckMMCache |
|---|
| 14 |
( http://sourceforge.net/project/turckmm-cache/ by Dmitry Stogov ) |
|---|
| 15 |
|
|---|
| 16 |
eAccelerator stores compiled PHP scripts in shared memory and executes code |
|---|
| 17 |
directly from it. It creates locks only for short time, while searching |
|---|
| 18 |
compiled PHP script in the cache, so one script can be executed simultaneously |
|---|
| 19 |
by several engines. Files that can't fit in shared memory are cached on disk |
|---|
| 20 |
only. |
|---|
| 21 |
|
|---|
| 22 |
eAccelerator contains a PHP encoder and loader. You can encode PHP scripts |
|---|
| 23 |
using encoder.php in order to distribute them without sources. Encoded files |
|---|
| 24 |
can be run on any site which runs PHP with eAccelerator. The sources of |
|---|
| 25 |
encoded scripts can't be restored because they are stored in a compiled form |
|---|
| 26 |
and the encoded version doesn't contain the source. Of course, some internals |
|---|
| 27 |
of the scripts can be restored with different reverse engineering tools |
|---|
| 28 |
(disassemblers, debuggers, etc), but it is not trivial. |
|---|
| 29 |
|
|---|
| 30 |
eAccelerator is compatible with Zend Optimizer's loader. Zend Optimizer must |
|---|
| 31 |
be installed after eAccelerator in php.ini. If you don't use scripts encoded |
|---|
| 32 |
with Zend Encoder then we do not recommend you install Zend Optimizer with |
|---|
| 33 |
eAccelerator. |
|---|
| 34 |
|
|---|
| 35 |
eAccelerator does not work in CGI mode but it does work in Fast-CGI mode with |
|---|
| 36 |
webservers like lighttpd. |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
Here are some other products that provide the same functionality: |
|---|
| 40 |
|
|---|
| 41 |
- Zend Performance Suite (http://www.zend.com/) |
|---|
| 42 |
- PHP Accelerator (http://www.php-accelerator.co.uk/) |
|---|
| 43 |
- Alternative PHP Cache (http://pecl.php.net/package/APC) |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
Where is eAccelerator already used? |
|---|
| 47 |
----------------------------------- |
|---|
| 48 |
The following you will find a list of sites that use eAccelerator. If you want |
|---|
| 49 |
to be added, please send e-mail to frankalcantara at users.sourceforge.net |
|---|
| 50 |
|
|---|
| 51 |
- The Slovenian National RTV Station (http://www.rtvslo.si) |
|---|
| 52 |
The Slovenian National RTV Station and its news/misc portal with forums. |
|---|
| 53 |
Over 3500 users and more than 37000 forum messages in a year. |
|---|
| 54 |
Two round-robin servers for the masses, and an administrator server. |
|---|
| 55 |
6 000 000 pageloads monthly. |
|---|
| 56 |
|
|---|
| 57 |
- An other game oriented french website (http://www.mondespersistants.com) |
|---|
| 58 |
An other game oriented french website with 6 000 000 pageloads monthly. |
|---|
| 59 |
http://guildes.mondespersistants.com is a full PHP5 oo development. |
|---|
| 60 |
Theses websites are running under freebsd/apache 1.3/php 5.0.3/eaccelerator 0.9.2 |
|---|
| 61 |
|
|---|
| 62 |
- Andrew Hutchings - Linux Guru ( http://www.domaincity.co.uk/) |
|---|
| 63 |
Andrew Hutchings - Linux Guru - Just a quick message to say we are now using |
|---|
| 64 |
eaccelerator as a replacement for mmcache on 2 of our 3 node round robin |
|---|
| 65 |
clusters, 2.5million hits per day. We will be doubling this in the next few week, |
|---|
| 66 |
as well as implementing new clusters. |
|---|
| 67 |
|
|---|
| 68 |
- elearning server (http://www.ets-online.de) |
|---|
| 69 |
Denny Reeh - System Developer - The e/t/s didactic media provides an elearning |
|---|
| 70 |
server (Distance Learning System) written in PHP. We are hosting the systems |
|---|
| 71 |
for our customers mainly by ourself. So we have 5 live-servers |
|---|
| 72 |
(freebsd, apache2, php4, eaccelerator) with 5.5 million hits per month. |
|---|
| 73 |
First without eAccelerator we should have installed more servers for good |
|---|
| 74 |
performance and secondly we improve the customer convenience by quartering |
|---|
| 75 |
the medium response time of a script. |
|---|
| 76 |
|
|---|
| 77 |
- Browser game (http://www.mafia-inc.de) |
|---|
| 78 |
The Mafia-Incorporated is a succesfull Browser game with around 2.500.000 |
|---|
| 79 |
pages impressions each day and over 5000 user. |
|---|
| 80 |
(GNU Linux(debian) / Apache 2.0.53 / PHP 4.3.10-9 / eAccelerator 0.9.2a) |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
Download |
|---|
| 84 |
-------- |
|---|
| 85 |
Latest eAccelerator versions can be downloaded at the sourceforge page: |
|---|
| 86 |
http://sourceforge.net/projects/eaccelerator/ |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
Requirements |
|---|
| 90 |
------------ |
|---|
| 91 |
apache 1.3, mod_php 4.1, autoconf, automake, libtool, m4 |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
Compatibility |
|---|
| 95 |
------------- |
|---|
| 96 |
eAccelerator has been reported working with php4 and php5 but php 5.1 support |
|---|
| 97 |
hasn't been integrated yet. It is being used on Linux, FreeBSD, MacOS X, |
|---|
| 98 |
Solaris and Windows with apache 1.3 and 2, lighttpd and IIS. |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
Quick install |
|---|
| 102 |
------------- |
|---|
| 103 |
|
|---|
| 104 |
You can find more information about installation on eAccelerator website. |
|---|
| 105 |
http://eaccelerator.sourceforge.net/ |
|---|
| 106 |
|
|---|
| 107 |
Note(1): for Microsoft Windows installation, please refer to README.win32 file. |
|---|
| 108 |
|
|---|
| 109 |
Step 1. Compiling eAccelerator |
|---|
| 110 |
|
|---|
| 111 |
export PHP_PREFIX="/usr" |
|---|
| 112 |
|
|---|
| 113 |
$PHP_PREFIX/bin/phpize |
|---|
| 114 |
|
|---|
| 115 |
./configure \ |
|---|
| 116 |
--enable-eaccelerator=shared \ |
|---|
| 117 |
--with-php-config=$PHP_PREFIX/bin/php-config |
|---|
| 118 |
|
|---|
| 119 |
make |
|---|
| 120 |
|
|---|
| 121 |
You must specify the real prefix where PHP is installed in the "export" |
|---|
| 122 |
command. It may be "/usr" "/usr/local", or something else. |
|---|
| 123 |
|
|---|
| 124 |
Step 2. Installing eAccelerator |
|---|
| 125 |
|
|---|
| 126 |
make install |
|---|
| 127 |
|
|---|
| 128 |
Step 3. Configuring eAccelerator |
|---|
| 129 |
|
|---|
| 130 |
eAccelerator can be installed both as Zend or PHP extension. |
|---|
| 131 |
|
|---|
| 132 |
For eaccelerator > 0.9.1, if you have /etc/php.d directory, you should copy eaccelerator.ini inside and modify default value if you need. |
|---|
| 133 |
|
|---|
| 134 |
If not, you need to edit your php.ini file (usually /etc/php.ini). |
|---|
| 135 |
|
|---|
| 136 |
To install as Zend extension: |
|---|
| 137 |
|
|---|
| 138 |
zend_extension="/usr/lib/php4/eaccelerator.so" |
|---|
| 139 |
eaccelerator.shm_size="16" |
|---|
| 140 |
eaccelerator.cache_dir="/tmp/eaccelerator" |
|---|
| 141 |
eaccelerator.enable="1" |
|---|
| 142 |
eaccelerator.optimizer="1" |
|---|
| 143 |
eaccelerator.check_mtime="1" |
|---|
| 144 |
eaccelerator.debug="0" |
|---|
| 145 |
eaccelerator.filter="" |
|---|
| 146 |
eaccelerator.shm_max="0" |
|---|
| 147 |
eaccelerator.shm_ttl="0" |
|---|
| 148 |
eaccelerator.shm_prune_period="0" |
|---|
| 149 |
eaccelerator.shm_only="0" |
|---|
| 150 |
eaccelerator.compress="1" |
|---|
| 151 |
eaccelerator.compress_level="9" |
|---|
| 152 |
|
|---|
| 153 |
If you use thread safe build of PHP you must use "zend_extension_ts" instead |
|---|
| 154 |
of "zend_extension". |
|---|
| 155 |
|
|---|
| 156 |
To install as PHP extension: |
|---|
| 157 |
|
|---|
| 158 |
extension="eaccelerator.so" |
|---|
| 159 |
eaccelerator.shm_size="16" |
|---|
| 160 |
eaccelerator.cache_dir="/tmp/eaccelerator" |
|---|
| 161 |
eaccelerator.enable="1" |
|---|
| 162 |
eaccelerator.optimizer="1" |
|---|
| 163 |
eaccelerator.check_mtime="1" |
|---|
| 164 |
eaccelerator.debug="0" |
|---|
| 165 |
eaccelerator.filter="" |
|---|
| 166 |
eaccelerator.shm_max="0" |
|---|
| 167 |
eaccelerator.shm_ttl="0" |
|---|
| 168 |
eaccelerator.shm_prune_period="0" |
|---|
| 169 |
eaccelerator.shm_only="0" |
|---|
| 170 |
eaccelerator.compress="1" |
|---|
| 171 |
eaccelerator.compress_level="9" |
|---|
| 172 |
|
|---|
| 173 |
Step 4. Creating cache directory |
|---|
| 174 |
|
|---|
| 175 |
mkdir /tmp/eaccelerator |
|---|
| 176 |
chmod 0777 /tmp/eaccelerator |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
Configuration Options |
|---|
| 180 |
--------------------- |
|---|
| 181 |
|
|---|
| 182 |
eaccelerator.shm_size |
|---|
| 183 |
The amount of shared memory (in megabytes) that eAccelerator will use. |
|---|
| 184 |
"0" means OS default. Default value is "0". |
|---|
| 185 |
|
|---|
| 186 |
eaccelerator.cache_dir |
|---|
| 187 |
The directory that is used for disk cache. eAccelerator stores precompiled |
|---|
| 188 |
code, session data, content and user entries here. The same data can be |
|---|
| 189 |
stored in shared memory also (for more quick access). Default value is |
|---|
| 190 |
"/tmp/eaccelerator". |
|---|
| 191 |
|
|---|
| 192 |
eaccelerator.enable |
|---|
| 193 |
Enables or disables eAccelerator. Should be "1" for enabling or "0" for |
|---|
| 194 |
disabling. Default value is "1". |
|---|
| 195 |
|
|---|
| 196 |
eaccelerator.optimizer |
|---|
| 197 |
Enables or disables internal peephole optimizer which may speed up code |
|---|
| 198 |
execution. Should be "1" for enabling or "0" for disabling. Default value |
|---|
| 199 |
is "1". |
|---|
| 200 |
|
|---|
| 201 |
eaccelerator.debug |
|---|
| 202 |
Enables or disables debug logging. Should be "1" for enabling or "0" for |
|---|
| 203 |
disabling. Default value is "0". |
|---|
| 204 |
|
|---|
| 205 |
eaccelerator.check_mtime |
|---|
| 206 |
Enables or disables PHP file modification checking . Should be "1" for |
|---|
| 207 |
enabling or "0" for disabling. You should set it to "1" if you want to |
|---|
| 208 |
recompile PHP files after modification. Default value is "1". |
|---|
| 209 |
|
|---|
| 210 |
eaccelerator.filter |
|---|
| 211 |
Determine which PHP files must be cached. You may specify the number of |
|---|
| 212 |
patterns (for example "*.php *.phtml") which specifies to cache or not to |
|---|
| 213 |
cache. If pattern starts with the character "!", it means to ignore files |
|---|
| 214 |
which are matched by the following pattern. Default value is "" that means |
|---|
| 215 |
all PHP scripts will be cached. |
|---|
| 216 |
|
|---|
| 217 |
eaccelerator.shm_max |
|---|
| 218 |
Disables putting large values into shared memory by " eaccelerator_put() " |
|---|
| 219 |
function. It indicates the largest allowed size in bytes (10240, 10K, 1M). |
|---|
| 220 |
The "0" disables the limit. Default value is "0". |
|---|
| 221 |
|
|---|
| 222 |
eaccelerator.shm_ttl |
|---|
| 223 |
When eaccelerator fails to get shared memory for new script it removes all |
|---|
| 224 |
scripts which were not accessed at last "shm_ttl" seconds from shared |
|---|
| 225 |
memory. Default value is "0" that means - don't remove any files from |
|---|
| 226 |
shared memory. |
|---|
| 227 |
|
|---|
| 228 |
eaccelerator.shm_prune_period |
|---|
| 229 |
When eaccelerator fails to get shared memory for new script it tryes to |
|---|
| 230 |
remove old script if the previous try was made more then |
|---|
| 231 |
"shm_prune_period" seconds ago. Default value is "0" that means - don't |
|---|
| 232 |
try to remove any files from shared memory. |
|---|
| 233 |
|
|---|
| 234 |
eaccelerator.shm_only |
|---|
| 235 |
Enables or disables caching of compiled scripts on disk. It has no effect |
|---|
| 236 |
on session data and content caching. Default value is "0" that means - use |
|---|
| 237 |
disk and shared memory for caching. |
|---|
| 238 |
|
|---|
| 239 |
eaccelerator.compress |
|---|
| 240 |
Enables or disables cached content compression. Default value is "1" that |
|---|
| 241 |
means enable compression. |
|---|
| 242 |
|
|---|
| 243 |
eaccelerator.compress_level |
|---|
| 244 |
Compression level used for content caching. Default value is "9" which is |
|---|
| 245 |
the maximum value |
|---|
| 246 |
|
|---|
| 247 |
eaccelerator.keys |
|---|
| 248 |
eaccelerator.sessions |
|---|
| 249 |
eaccelerator.content |
|---|
| 250 |
Determine where keys, session data and content will be cached. The possible |
|---|
| 251 |
values are: |
|---|
| 252 |
"shm_and_disk" - cache data in shared memory and on disk (default value) |
|---|
| 253 |
"shm" - cache data in shared memory or on disk if shared memory |
|---|
| 254 |
is full or data size greater then "eaccelerator.shm_max" |
|---|
| 255 |
"shm_only" - cache data in shared memory |
|---|
| 256 |
"disk_only" - cache data on disk |
|---|
| 257 |
"none" - don't cache data |
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
eAccelerator API |
|---|
| 261 |
---------------- |
|---|
| 262 |
|
|---|
| 263 |
eaccelerator_put($key, $value, $ttl=0) |
|---|
| 264 |
puts the $value into shard memory for $ttl seconds. |
|---|
| 265 |
|
|---|
| 266 |
eaccelerator_get($key) |
|---|
| 267 |
returns the value from shared memory which was stored by eaccelerator_put() |
|---|
| 268 |
or null if it is not exists or was expired. |
|---|
| 269 |
|
|---|
| 270 |
eaccelerator_rm($key) |
|---|
| 271 |
removres the $key from shared memory |
|---|
| 272 |
|
|---|
| 273 |
eaccelerator_gc() |
|---|
| 274 |
removes all expired keys from shared memory |
|---|
| 275 |
|
|---|
| 276 |
eaccelerator_lock($lock) |
|---|
| 277 |
creates a lock with specified name. The lock can be released by function |
|---|
| 278 |
eaccelerator_unlock() or automatic on the end of request. |
|---|
| 279 |
For Example: |
|---|
| 280 |
<?php |
|---|
| 281 |
eaccelerator_lock("count"); |
|---|
| 282 |
eaccelerator_put("count",eaccelerator_get("count")+1)); |
|---|
| 283 |
?> |
|---|
| 284 |
|
|---|
| 285 |
eaccelerator_unlock($lock) |
|---|
| 286 |
release lock with specified name |
|---|
| 287 |
|
|---|
| 288 |
eaccelerator_set_session_handlers() |
|---|
| 289 |
install the eaccelerator session handlers. |
|---|
| 290 |
Since PHP 4.2.0 you can install eaccelerator session handlers |
|---|
| 291 |
in "php.ini" by "session.save_handler=eaccelerator". |
|---|
| 292 |
|
|---|
| 293 |
eaccelerator_cache_output($key, $eval_code, $ttl=0) |
|---|
| 294 |
caches the output of $eval_code in shared memory for $ttl seconds. |
|---|
| 295 |
Output can be removed from cache by calling mmcach_rm() with the same $key. |
|---|
| 296 |
For Example: |
|---|
| 297 |
<?php eaccelerator_cache_output('test', 'echo time(); phpinfo();', 30); ?> |
|---|
| 298 |
|
|---|
| 299 |
eaccelerator_cache_result($key, $eval_code, $ttl=0) |
|---|
| 300 |
caches the result of $eval_code in shared memory for $ttl seconds. |
|---|
| 301 |
Result can be removed from cache by calling mmcach_rm() with the same $key. |
|---|
| 302 |
For Example: |
|---|
| 303 |
<?php eaccelerator_cache_output('test', 'time()." Hello";', 30); ?> |
|---|
| 304 |
|
|---|
| 305 |
eaccelerator_cache_page($key, $ttl=0) |
|---|
| 306 |
caches the full page for $ttl seconds. |
|---|
| 307 |
For Example: |
|---|
| 308 |
<?php |
|---|
| 309 |
eaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30); |
|---|
| 310 |
echo time(); |
|---|
| 311 |
phpinfo(); |
|---|
| 312 |
?> |
|---|
| 313 |
|
|---|
| 314 |
eaccelerator_rm_page($key) |
|---|
| 315 |
removes the page which was cached by eaccelerator_cache_page() with the same |
|---|
| 316 |
$key from cache |
|---|
| 317 |
|
|---|
| 318 |
eaccelerator_encode($filename) |
|---|
| 319 |
returns the encoded bytecode of compiled file $filename |
|---|
| 320 |
|
|---|
| 321 |
eaccelerator_load($code) |
|---|
| 322 |
loads script which was encoded by eaccelerator_encode() |
|---|
| 323 |
|
|---|
| 324 |
WEB interface |
|---|
| 325 |
------------- |
|---|
| 326 |
eAccelerator can be managed through web interface script eaccelerator.php. So |
|---|
| 327 |
you need to put this file on your web site. For security reasons it is |
|---|
| 328 |
recommended to restrict the usage of this script by your local IP. |
|---|
| 329 |
|
|---|
| 330 |
Since version 2.3.18 admin interface may be protected by password. To generate |
|---|
| 331 |
password run the eaccelerator_password.php from command line and follow the |
|---|
| 332 |
instruction. |
|---|
| 333 |
|
|---|
| 334 |
$ php -q eaccelerator_password.php |
|---|
| 335 |
Changing password for eAccelerator Web Interface (eaccelerator.php) |
|---|
| 336 |
|
|---|
| 337 |
Enter admin name: admin |
|---|
| 338 |
New admin password: eaccelerator |
|---|
| 339 |
Retype new admin password: eaccelerator |
|---|
| 340 |
|
|---|
| 341 |
Add the following lines into your php.ini and restart HTTPD |
|---|
| 342 |
|
|---|
| 343 |
eaccelerator.admin.name="admin" |
|---|
| 344 |
eaccelerator.admin.password="$1$0ScD9gkb$nOEmFerNMvQ576hELeLrG0" |
|---|
| 345 |
|
|---|
| 346 |
If you use eaccelerator.php in directory that is password-protected by HTTPD |
|---|
| 347 |
then eaccelerator's admin name and password must be the same. |
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 |
Contact us |
|---|
| 351 |
---------- |
|---|
| 352 |
You can contact us with questions, patches or bugs, by sending an email to |
|---|
| 353 |
Bart Vanbrabant <zoeloelip at users.sourceforge.net> |
|---|