Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Again: Zend OPcache API is restricted by "restrict_api" configuration directive

apache first-time gpm

Solved by Andy Miller View solution

Started by Traumschule Riebau 9 years ago · 10 replies · 6619 views
9 years ago

Hey,

this topic reappears in 1.3.3, although it should be fixed:

_"Zend OPcache API is restricted by "restrictapi" configuration directive"

in

user/plugins/admin/themes/grav/templates/register.html.twig

TWIG
{% embed 'partials/register.html.twig' with {title:'Grav Register Admin User', classes:'wide'} %}

Cache is disabled in system/config/system.yaml.

This is on a shared hosting so Zend is beyond our control.

(more references had to be removed because of discourse's limitation for new users)

9 years ago

Same with the development branch:

"An exception has been thrown during the rendering of a template ("Zend OPcache API is restricted by "restrict_api" configuration directive")."

in user/themes/antimatter/templates/partials/base.html.twig:54:
{% include 'partials/navigation.html.twig' %}

9 years ago

Hi, i've been hit by this as well. And like others, i'm also on shared hosting, so no real control over my php environment. I got it working though.

In addition to this @-prefixed opcache line mentioned in previous posts:
grav/system/src/Grav/Common/File/CompiledFile.php

... i also found another opcache line in my /www tree:
vendor/twig/twig/lib/Twig/Cache/Filesystem.php

I've @-prefixed the opcached line in there and now my site is up again. I have no clue of what i'm doing actually and what fallout there might be from that change, but for now, it works

👍 1
8 years ago

Just a note — I got this error after enabling PHP 7.2 on my server, reverting to 7.1 fixed it.

8 years ago

Same here, running Serverpilot on Linode — changing to php 7.2 throws this error

An exception has been thrown during the rendering of a template ("Zend OPcache API is restricted by "restrict_api" configuration directive").

Change back to 7.1 / 7.0 and no problems...

8 years ago

same here Grav 1.4.2, no matter the php 7.* version
the @ helped though (@opcache_invalidate($file->filename(), true);)

but kinda stupid to change the core

8 years ago Solution

OK, there is a proper fix, that I came across while trying to solve this on a serverpilot controlled digital ocean droplet:

The error is caused by a configuration in php.ini for opcache: http://php.net/manual/en/opcache.configuration.php

To resolve, simply edit this setting in your php.ini (or relevant configuration file) for opcache settings. In my case I had an /etc/php7.2-sp/conf.d/opcache.ini file that contained:

TXT
opcache.restrict_api=1

I just changed this to:

TXT
opcache.restrict_api=

and restarted PHP FPM with: sudo service php7.2-fpm-sp restart

8 years ago

I just updated to latest Grav v1.4.4 - Admin v1.7.2
and the problem is back
/grav/vendor/twig/twig/lib/Twig/Cache/Filesystem.php
adding @ on line 70 like in previous case solved the issue.

7 years ago

I've same problem when i update my serverpilot php from 7.2 to 7.3
How can i fix it ?
Thanks

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 80 10 hours ago
General · by pamtbaau, 15 hours ago
1 51 15 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago