The accepted answer is incorrect mentioning transparent huge pages and the kernel compile option for the same.
PHP OPcache has nothing to do with Transparent Huge Pages, it's about older, explicit huge pages mechanism.
As such, enabling huge pages in OPCache via opcache.huge_code_pages=1 is not sufficient alone, there must be some changes done in kernel settings, e.g. vm.nr_hugepages = 128 in /etc/sysctl.conf (to allot 256 MB of explicit huge pages, as long as your huge page size is 2MB).
Even this may not be sufficient, depending on OS. In CentOS 7, those pages are mounted like the following:
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
And that is enough. In other distros, you might have to mount them manually, see here for details.
More details about transparent vs explicit huge pages in the context of OPCache / web servers can be found here.
It's easy to tell which is what using this logic:
- Transparent huge pages are really as per naming - transparent. That is, you don't have to do any configuration on the side of the apps to have them enabled. It is seamless to all apps.
- Explicit huge pages need to be configured/enabled both in and outside of a particular app. Meaning there is extra code/configuration in the app itself to support them, as well as having to ensure that the OS will enable those huge pages. This is the exact case of OPCache, and why OPCache has got a special directive for it.
So this is about other directives potentially missing from OVH kernel. From the kernel docs:
the Linux kernel needs to be built with the CONFIG_HUGETLBFS
(present under "File systems") and CONFIG_HUGETLB_PAGE (selected
automatically when CONFIG_HUGETLBFS is selected) configuration
options.