Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just installed php5-fpm. All sources say that apc module has been replaced with OPcache and it's compiled by default but not enabled.

How can I enable this module. I can not find opcache.so file on my server

I have checked /usr/lib/php5 and /etc/php5 but can not find it.

php -v
PHP 5.4.4-14+deb7u4 (cli) (built: Aug 23 2013 14:37:41)
share|improve this question

You can update PHP like shaun m says, or if you don't want to do that you can install zendopcache from PECL

Check for latest version here, this installs version 7.0.3.

Install "pecl" via php-pear

`sudo apt-get install -y php-pear`

Install build dependencies

sudo apt-get install -y build-essential php5-dev

Install Zend OpCache

sudo pecl install zendopcache-7.0.3

Find the location of opcache.so

sudo find / -name 'opcache.so'

Mine is

/usr/lib/php5/20100525/opcache.so

Now create opcache.ini

sudo vim /etc/php5/mods-available/opcache.ini

Add this info

zend_extension=/usr/lib/php5/20100525/opcache.so # File path from above
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Now create a symlink for the conf file

sudo ln -s /etc/php5/mods-available/opcache.ini /etc/php5/conf.d/20-opcache.ini

Restart services

sudo service php5-fpm restart
sudo service apache2 restart

Confirm install

php -v

It should give mention of

Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Then (optionally) finish by cleaning up

sudo apt-get remove --purge build-essential php5-dev

Reference

share|improve this answer

OPCache is only enabled and compiled in by default in the new PHP 5.5, not the 5.4 that comes with Wheezy. If you'd like to use OPCache and PHP 5.5 in Debian, you'll have to add the dotdeb repos (see below) and install from there.

deb http://packages.dotdeb.org wheezy-php55 all 
deb-src http://packages.dotdeb.org wheezy-php55 all
share|improve this answer

You can install APC whit pecl

pecl install apc

php-pear en php-dev is needed for install it.

Or you can install whit apt-get

apt-get install php5-apc
share|improve this answer

To add to Jeremy Davis' answer...

In case your /tmp directory is mounted as "noexec" (preventing execution of scripts written there, which is common on public-facing servers), the pecl install command will fail like this:

shtool at '/tmp/pear/temp/zendopcache/build/shtool' does not exist or is not executable.
Make sure that the file exists and is executable and then rerun this script.

To avoid this, you can remount the /tmp partition as exec, then pecl install, hen remount as noexec, like this:

mount -o remount,exec /tmp
pecl install zendopcache
mount -o remount,noexec /tmp

After checking with our sysadmin that this was alright, I tried it on a server in production and it worked perfectly fine (you will have to restart your PHP profcess (be it FPM or an Apache module) after that anyway, so probably not a good idea on a very high load server, but for mildly used public servrs, the whole process seems to work just fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.