# php opcache



## balanga (Feb 11, 2017)

When installing Drupal 8 a msg suggests:


> It is *highly recommended* to have OPcache installed on your server.



I have never heard of opcahe - there is some info about it here:-
http://php.net/manual/en/opcache.installation.php

Has anyone used it, and is it worth installing?


----------



## gkontos (Feb 11, 2017)

Yes, we are using it, not for drupal though. Link --> https://www.freebsd.org/cgi/ports.cgi?query=OPcache&stype=all


----------



## linux->bsd (Feb 11, 2017)

balanga said:


> Has anyone used it, and is it worth installing?



Which version of PHP are you running on that server? OPCache worked so well that it was integrated into PHP v5.5 and greater.

For those unfamiliar, "[a]n opcode cache is a system to cache the result of the PHP code compilation to bytecode. This allows to use the bytecode instead of compiling on every request." [1]


----------



## balanga (Feb 12, 2017)

I'm using PHP v5.65....Does that mean I don't need to think about OPCache?


----------



## masteroman (Feb 12, 2017)

If you're not using any other opcode caching mechanism then enabling opcache will definitely improve things.

You need to enable opcache separately. First you need to install it. If you're using binary packages install phpXY-opcache where XY is PHP version (56, 71). Then you'll need to specify additional parameters in your php.ini files like:


```
opcache.memory_consumption=32M
opcache.validate_timestamps=0
```

and there are many more. You can verify those settings by simply creating php info file with:


```
<?php
phpinfo();
?>
```

and calling it from your browser.


----------



## linux->bsd (Feb 13, 2017)

balanga said:


> I'm using PHP v5.65....Does that mean I don't need to think about OPCache?



My experience is with Debian and CentOS servers running Apache + PHP, so if masteroman has personal experience with OPCache on *BSDs, I'd go with his instructions.

On Linux, servers running PHPv5.5+ don't need to install new packages, they just need to enable the module. I assumed that's the case with *BSD as well.

Search for your .../mods-available/ directory and see if it's already there. Or run `php -i | grep -i cache` to see if it's listed as 'disabled.'


----------

