Alternative PHP Cache (APC) saves compiled PHP scripts (opcode) in a cache and reduces computing time when the script invoked again 3). This increases SoSci Survey's performance significantly.
The following manual describes how to install APC on a Linux system with Debian distribution and Apache 2.
Note: PHP 5.5 contains the „Zend Optimizer+“ opcode cache by default. No additional installation is required.
Note: Before you begin installation, access the Server Management → Server Maintenance → PHP Information in SoSci Survey. If an „apc“ section is already there then your server already uses the plugin.
Note: There are a whole range of other caching modules, including the commercial ZEND Server, that achieve additional acceleration by optimizing code even more.
If your Linux distribution recognizes the php-apc
or php5-apc
packet, then APC installation is particularly easy. Simply try to install the packet as follows on the Linux console. After installation is complete, the PHP/Apache configuration will reload automatically and you will find the „apc“ entry in PHP Information.
# The packet will be called something different, depending on the distribution sudo apt-get install php5-apc sudo apt-get install php-apc
Afterwards, the web server has to be restarted
sudo service apache2 restart
Tip: This solution has the advantage that the APC will be updated automatically in the distribution. You have to update APC manually after the PHP update if you use the other solutions.
APC is also available as a PECL plugin, which needs PEAR to be installed. More details can be found in Installation Manual for APC.
sudo apt-get install php-pear
In order for the pecl install
command to work, PHP developer packages are needed. The first line is enough if you are using PHP 5. If you cannot find php5-devel
, try php-devel
.
sudo apt-get install php5-dev
In addition, the installation routine is still missing the pcre.h
file. This can be obtained with the following command.
sudo apt-get install libpcre3-dev
Everything is now ready to install APC via PECL 4).
sudo pecl install apc
It is likely that the installation routine cannot find the PHP.INI
file and will ask for the file to be changed manually:
> configuration option "php_ini" is not set to php.ini location > You should add "extension=apc.so" to php.ini
You can find the active PHP.INI
with the phpinfo() PHP command, which can be accessed in Server Management → Server Maintenance → PHP Information. Request „php.ini“.
Warning: PHP uses PHP.INI
files that are likely to be different. If you start PHP from the command line, you will find a different file 5).
php -r "phpinfo();" | grep php.ini
In the PHP.INI used by your web server, please enter the „apc.so“ plugin. Request „Dynamic Extensions“, in order order to find the right position for this.
extension=apc.so
The web server now has to be restarted so that PHP uses the new PHP.INI
. If projects already are already running on your server, temporarily block the server in Server Management → Server Maintenance → Block Server. The simplest way to perform the restart is by using the following commands:
sudo service apache2 restart sudo /etc/init.d/apache2 restart sudo service httpd restart sudo /etc/init.d/httpd restart
Finally, you should check in PHP Information to see if APC was enabled and to remove the server block.