|Where possible, use OpCache instead of APC:|
If you're using PHP-FPM, see the forum.
For FastCGI (mod_fcgi), use this guide, but see below for exceptions/changes.
A common optimization that can be done for php to improve performance is to install Alternative PHP Cache (APC).
What it does, is it caches php files in memory in their parsed and compiled state.
This removes the need for re-reading, parsing, and compiling for each request, thus greatly lowering your system load.
The cost of using this mosulde is increased memory usage, since that's where the cache lives.
Note - This won't work with suPhp, since each call to php is with a seperate binary call, and doesn't share the same memory. CLI is always running in memory, hence can shared the same memory, which is why it works.
1) To install it with the default CLI version of php, use the following:
2) Then, we needed to edit the php.ini to add the code:
If your server does not have enough ram to cache all PHP files, you must reduce the number of cached files. Use filters option or play with cache_by_defaut option to specify wich files to be cached. A tip is to set apc.cache_by_default=0 in php.ini, and then apc.cache_by_default=1 in the .htaccess of websites requiring APC optimisation.
3) as well as change the php.ini line from:
extension_dir = "./"to be:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"but, this may vary per system. The "make install" command will tell you where the apc.so was installed to (Installing shared extensions:).
Note that this is a 3rd party module, and would be beyond our technical support for any issues that arise.
APC provide a tool to check memory use. It's a php page that you will find in /usr/local/directadmin/custombuild/APC-3.1.14/apc.php. Copy it to a web folder and open it in browser. In a correctly configured APC installation memory chart must remains stable over time.
Note: It's been observed that with APC enabled, php may not install on the "make install" step. The error it produces is as follows:
Fatal error: Class 'PEAR' not found in phar://install-pear-nozlib.phar/index.php on line 24
The install is mostly the same, but some paths and options vary:
1) The phpize and configure lines will be different, eg, if you're using 5.4 with FastCGI:
2/3) In our tests, we used these options in the php.ini
extension_dir = "/usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/"
The "make install" part of APC should spit out what this path should be.
|Installing php OpCache with CustomBuild 2.0|
© 2018 JBMC Software, Suite 173 3-11 Bellerose Drive, St Albert, AB T8N 1P7 Canada. Mon-Fri 9AM-5PM MST