I'm fairly new to Drupal (Drupal 8) and OPcode caching.
I hate to have warnings, and checked with my hosting provider who assured me that OPcode caching was enabled.
I configured my php.ini with the necessary information, and checked that my cache folder was indeed filling up with information from people visiting my site.
Yet the warning:
PHP OPcode caching Not enabled
PHP OPcode caching can improve your site's performance considerably. It is highly recommended to have OPcache installed on your server.
Still persists.
I have also checked my phpinfo from the status report, and it states (at the bottom):
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Why am I still getting a warning?
Comments
Opcache issue solved
Please add this line into your php.ini file location
[opcache]
zend_extension=php_opcache.dll
;Determines if Zend OPCache in enabled
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
its working for me, thanks
its working for me, thanks
Thanks u very much! That
Thank u very much! That worked for me too!
Thanks
Its working for me.
thanks
thank you alot .... i can fix my problem
Working!
First of all, thanks a lot for the code krishnakrgupta
The above code does work, but here's my additional findings:
php.ini can be found (on WAMP) by clicking on the wamp icon >> PHP >> php.ini
The code starts at line 1900.
It is not all in one block, but goes as far as 1950.
The lines are not needed to be added, just current code needs modifying.
When you have made these changes remember to save the file AND reset the apache connected with your PHP
Thanks,
It worked for me.
How to enable OPcache On Ubuntu & Windows
How to enable OPcache? - To increase site performance
On Ubuntu
Edit the php configuration file at /opt/lampp/etc/php.ini &
server file/etc/php5/apache2/php.ini
Go to opt/lampp/etc php.ini to enable opcache
Open file via terminal
->
sudo gedit /opt/lampp/etc/php.inif in the case file showing blank
->
suclick on enter and give machine password then add
->
sudo gedit /opt/lampp/etc/php.iniuncomment (remove colon)
;zend_extension = opache.sonow restart lampp
sudo /opt/lampp/lampp restartand check in phpinfo.php . We can see opcache is enabled and showing all the extension related to opcache .
To change the value of extension. Then add following lines under “zend-extension = opcahe.so”
zend-extension = opcahe.soopcache.memory_consumption=128opcache.max_accelerated_files=2500
opcache.interned_strings_buffer=8
opcache.revalidate_freq=60
opcache.fast_shutdown=1
- now restart lampp
sudo/opt/lampp/lampprestartand check in phpinfo.php. We can see all the change. Now we can install Drupal 8.
Please Refer to Url Ubuntu: http://php.net/manual/en/opcache.installation.php
On Windows
Edit the PHP configuration file at Window 7 C:\Xampp\php\php.ini
To enable opcache, We have to add following lines
- Add lines
zend_extension=php_opcache.dllopcache.memory_consumption=128opcache.max_accelerated_files=2500opcache.interned_strings_buffer=8
opcache.revalidate_freq=60
opcache.fast_shutdown=1
now restart xampp
Please Refer to Url windows: https://commaster.net/content/installing-php-fastcgi-and-zend-opcache-xampp-windows
For another Drupal Trick visite my blog http://toswebdeveloper.blogspot.in/
Best regards,
Omprakash Mankar
Senior Drupal Developer
Worked
Thank You krishnakrgupta, it works for me also.
Hamad ~ Deknows
Thanks it's Working :)
Thanks it's Working :)
Thanks
zend_extension=opcache.so
;Determines if Zend OPCache in enabled
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
OPCache issue
It works for me, Thanks!
+1 Thanks it worked
+1 Thanks it worked
Thanks, It's works for me.
Thanks, It's works for me.
Thanks, It worked for me!
Thanks, It worked for me!
On a Linux machine change the
On a Linux machine change the .dll to .so as in the following example:
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
PHP OPcode caching - Online and Local: UNIX vs Windows server
Potential respondents:
Especially for the benefit of day-one Drupal users, and other newbies like me, and because this page is the first drupal.org page from a Google search of 'PHP OPcode caching', I am hoping to get further clarification before I start hacking, to spare myself the all-too-familiar time/torture of trial-and-error Drupal solution attempts. Thanking you in advance from myself, and from the thousands of others who are likely to visit this page.
===
Current PHP version of my webhosting account (on a UNIX server):
I have the option in my webhosting Control Panel to set the version of PHP that is used across the entire account for all sites:
Hosting 'CPanel' > heading "programming" > icon "PHP Config"
Currently is it set on "PHP 5.6 (FastCGI)", and works fine for my Drupal 7 sites, which are each in a separate subfolder of 'public_html'.
I just installed my first Drupal 8.3 site, and it gave the error this page attends to, but I completed the installation anyway, by clicking the text-link reading something similar to, "Continue anyway".
Note to newbies:
When the PHP option is changed in the webhost Control Panel, the files "php.ini", and ".htaccess" in the account's root folder at "public_html/php.ini", and "public_html/.htaccess" are automatically updated (or are created in the rare case they are not existing). Also, a backup copy of the former files (as applicable) are also generated, time-stamped (of sorts, Eg.: ".htaccess.bak.1495181202"), and are placed in the same folder.
Other current webhosting PHP options include:
- "PHP 7.0 [Beta, ..."
- "PHP 7.0 (Single php.ini) [Beta, ..."
- "PHP 7.0 (FastCGI) [Beta, ..."
Because the drupal.org issue "Fully support PHP 7 in Drupal 7" (https://www.drupal.org/node/2656548) is still Not fully resolved, I am hesitant to change my webhost account to using PHP 7 for fear that it will adversely affect my D7 live 'production' sites, particularly since that might be in ways that are not immediately apparent to me.
I vaguely recall reading somewhere that 'OPcode caching' is already suppported in PHP 5.6.
---
Question 1:
Are the code recommendations above intended for sites running PHP 5.6, or for PHP 7.0, or for both?
...assuming that your solutions are designed to correct situations where the PHP configuration, of the version(s) you are targeting, simply does(do) not have 'OPcache' enabled by default. Or can OPcache generally be expected to be enabled by default with PHP 7.0?
Questions 2:
*.dll vs *.so
Am I correct in my assumption that the line of code in the first example above,
zend_extension=php_opcache.dllis intended for Windows servers only, and that I should instead use the second example above with the codezend_extension=php_opcache.sogiven that I am using an online shared webhosting account on a UNIX server? And, as an aside, if you know, is it possible that the *.dll might work for some people using UNIX?Question 3:
[opcache]I notice that the first example uses the code
[opcache], whereas the second example does not.Is that 'optional', 'actually required', or 'a problem if included'?
Questions 4:
What php.ini file?
Noting again that each of my D7 and D8 sites are all in separate unique subfolders of 'public_html':
Can your code be used in the existing PHP 5.6 php.ini file at "public_html/php.ini", without fear of it adversely affecting my D7 sites, and without adversely affecting other Drupal administrators who are running additional non-Drupal applications at their webhosts?
Or, does your code need to go into a php.ini file in the root of the D8 site at "[d8-root]/php.ini" (in a php.ini file of our creation, given that the default D8 'completed' installation does not include a php.ini file)?
And if your code can be, or were to be, used in "[d8-root]/php.ini", will it automatically be seen and used, or does the php.ini file then require being linked to by another file, as for example, the "[D8-root]/.htaccess" file?
Questions 5:
Where 'within' existing php.ini file?
Can your code be placed 'anywhere' in an existing 'php.ini' file (if and when it is pre-existing), or does it necessarily have to follow (or precede) certain other specific code declarations that a user may be using in their 'php.ini' file; and if so, what are those specific other code statements to be aware of, and should your solution precede or follow each of those fragments we should 'look out for'?
Question 6:
'Local' considerations
What other considerations, details, and specific instructions might you have for users who are developing 'locally'? ('locally': sites on a computer, instead of online at webhost)
Question 7:
Since I cannot restart my online server, as I have seen recommended/required for 'local' servers, what do I need to do instead, if anything, for my online situation?
Question 8:
On the Drupal 8 "Reports" > "Status report" page ([D8-root]/admin/reports/status) under the heading "Warnings found": "PHP OPcode caching", there is a link to the page "PHP:Installation - Manual" at php.net (http://php.net/manual/en/opcache.installation.php).
On that page under the heading "Recommended php.ini settings", the block of 'recommended' code includes one line at the bottom which is Not in the examples above:
opcache.enable_cli=1Can anyone who speaks PHP tell us lay-persons the relative benefits of using, vs. not using, that code.
===
Thanking you kindly in advance for your attention, time, patience, and help, and welcoming your answer to even a single question, if that is all you know, or if that is all you have the time for 'registering' and 'answering' here at drupal.org.
All the best; intended.
-Chris (great-grandpa.com)
___
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *
opcache.revalidate_freq
Also, please note that the
opcache.revalidate_freq=60directive can cause your PHP code to be put in cache for 60 seconds, which can be annoying if you're working on other (simpler) PHP projects. If a PHP file has been cached and you make changes to it, you won't see the changes in the browser for the next 60 seconds; very annoying if you're constantly moving back and forth between your PHP code and the browser.I'm not sure why 60 is suggested as a value for this directive, but I've changed it to 1 so I don't have this problem when working on smaller project (on my development machine, of course).
Awesome
Thanks Sprite, you saved me, I did not get the ";" and that's why it did not work for me. I repeat, Thanks!
Trials, Panic, Back-track, More Panic, Site recovery, [Solved]
This is strictly in reference to online Drupal 7, and 8 sites,
at a webhost (bluehost.com) that uses a third party Control Panel,
which might be the exact same Control Panel used by your webhost,
or, if nothing else, might use the same tool to modifify
the version of PHP used on your account.
---
Trials
I 'unsuccessfully' tried using the code above
at the bottom of my "public_html/php.ini" file;
and in a newly created php.ini file in the root folder
of my Drupal 8 site.
It did Not help to run 'update.php' or 'Clear all caches'
or 'Run cron'.
I switched my webhost account to
"PHP 7.0 (FastCGI) [Beta, ..."
at:
Hosting 'CPanel' > heading "programming" > icon "PHP Config"
It may take you a few minutes for the change to PHP 7.0
to take affect, but, in my case, the affect was immediate.
---
Panic
My freshly installed Drupal 8 site was rendered unusable,
and displayed the error:
Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /home2/greatgs5/public_html/[*SUBFOLDER*]/[*DRUPAL_8_ROOT*]/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php on line 134My Drupal 7 sites were also broken, displaying the error:
Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /home2/greatgs5/public_html/[*SUBFOLDER*]/[*DRUPAL_7_ROOT*]/includes/database/mysql/database.inc on line 56---
Back-track
At my webhost Control Panel, I set my PHP version
back to what it had been:
"PHP 5.6 (FastCGI)"
---
More panic
My Drupal 7 and 8 site remained broken with the same error,
and running 'update.php' did Not help the D7, or D8 sites.
Note:
Having repeated this entire nightmare again,
just to make sure-- before I post this tale--
I now believe that if I had waited a few minutes longer,
(the first time around)
a few minutes more, that is, than I already had,
the problem may have resolved itself,
but what I did next (the first time around)
seemed to immediately resolve the 'dead sites' issue.
---
Sites recovered
I deleted the webhost root 'php.ini' file at
"public_html/php.ini".
At the webhost Control Panel 'PHP Configuration' page,
I again selected the radio-button "PHP 5.6 (FastCGI)",
and again clicked the page-bottom button
"SAVE CHANGES".
My Drupal 7 and 8 sites immediately came back to life
as normal.
---
OPcache [Solved]
I opened the "public_html/php.ini" file
in the online 'Control Panel' 'File Manager' editor,
(though I could have edited it locally, and then uploaded it)
and I noticed that the very last line was:
;zend_extension=/usr/php/[*ARBITRARY-NUMBER*]/usr/lib64/php/modules/opcache.soI removed the ";" from the beginning of that line of code,
since the ";" is the character used at the beginning
of a PHP line of code to have it commented-out/ignored.
Success...
My Drupal 8 site no longer displays the 'Status report' warning
"PHP OPcode caching not enabled";
and, to repeat, my webhost account is now set at:
"PHP 5.6 (FastCGI)".
###
All the best; intended.
-Chris (great-grandpa.com)
___
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *
Good for you
I am running php 7
verified with the phpinfo and opcache is up and running
the funny/strange thing is that on My MainDomain both wordpress & drupal have problems with the opcache (means cannot access it)
But on an addondomain, which uses the same php.ini, but with a different domainname, opcache is selectable...
EDIT: I got in touch with my hosting provder, they helped me to solve the issue I had.
Apparently a RewriteEngine On in the htaccess was conflicting with opcache
I'll try now different ways to kee the Rewrite code in and keep opcache running.
OKAY: I can confirm now that HTACCESS CAN INTERFERE WITH OPCACHE
in the sense that:
Wordpress uses the htaccess for some Redirects and Rewrites.
If you have other Rewrite Command for your domain, not related to wordpress, they need to go after the wordpress htaccess code.
In my case they were before the wordpress code and this produced that neither drupal nor wordpress could use opcache.
Moved the other rewrites to the end and "Voilà".
thax
working for me
In what directory is php.ini in Drupal 8?
In what directory is php.ini in Drupal 8?
php.ini is the main configuration of your php configuration on t
php.ini is the main configuration of your php configuration on the hosting. It belongs de facto to the php installation, not to the drupal install
It normally can be found in the root webfolder (e.g. public_html or www)
Close, but not quite
duplicate, see below.
Close, but not quite
Indeed php.ini belongs to php, not drupal. Use phpinfo() in a script to find out which ini's are processed. Normally found in /etc or php folder.
When you make changes, web server needs to be restarted for them to take effect.
php.ini found in other folders are unlikely to be processed. By default per site ini's are named .user.ini, but the name is configurable (indeed, in the central php.ini or even in .htaccess). Again, check with phpinfo() for actual situation.
htaccess:
Thank you!
Thank you for the Code of krishnakrgupta. At first there was still the OPcache warning although i inserted the Code in the php.ini. But after hours and hours of searching what the problem might be i found out with phpinfo() that my PHP Installation has lots of additional php.ini files. With phpinfo() i found out that under "Additional .ini files parsed" there were approximatly 25 additional php.ini files, so there was also a file with the name "20-extension-opcache.ini" and i changed the code on line 3 from "opcache.enable=0" to "opcache.enable=1" and the warning was gone! I am using Mac 10.11 and PHP 7.2.2 (from php-osx.liip.ch). I guess this php installation is the reason why there are so many additional ini files. I worked very long on this problem and maybe it is helpful for somebody who has the same problems. So you should look at first with phpinfo() if there are additional .ini files and if they have to do with OPcache.
On a Mac OS machine
In php.ini file (located ../applications/XAMPP/xamppfiles/etc) the code line for PHP OPcode caching is already there, but silented with semicolon by default. (XAMPP on MacOS)
Therefore:
;zend_extension=opcache.sochange to
zend_extension=opcache.soRestart Apache Web Server. And an error is gone.
MAMP USERS - don't mess with php.ini
Done.
I'm afraid that this is still
I'm afraid that this is still a problem for me with Drupal 8.8.2. Bluehost insists that opcache is enabled on the server. I have added the lines for setting opcache, as set forth in comments for this topic. I have tried using the full path to a opcache.so file as well as merely "opcache.so". No mention of opcache is reported by phpinfo(). Perhaps it is just faulty reporting in my site status screen. Yet, I still get that warning.
Update: opcache was indeed not enabled on bluehost, at least not for any of the php 7 versions. The module is available for php 5.6, though. They couldn't tell me when they intend to enable it.
Can you please tell me what
Can you please tell me what exactly you see on your phpinfo.php. We have same issue :( Thanks.
phpinfo doesn't know anything about opcache
There is no mention of it in the readout. The exception here is that credits for it are mentioned at the bottom of the page, in the php credits section. Again, at least for me, opcache is not enabled on the bluehost server for any version of php 7.x. It does seem to be available for php 5.6.