I am trying to enable Opcache, but for some reason, after editing my php.ini file and restarting apache (even rebooting the server), it still does not get enabled. Running a test I can see that that the php files location:
Loaded Configuration File /etc/php5/apache2/php.ini
Within that file I have added:
zend_extension=/usr/lib/php5/20121212/opcache.so
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.enable_cli=1
The location of the zend extension was defined by locate opcache.so. This did not work. I then noticed that php was loading an additional file /etc/php5/apache2/conf.d/05-opcache.ini. In that file it looks like:
; configuration for php ZendOpcache module
; priority=05
zend_extension=opcache.so
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.enable_cli=1
However, after restarting apache it still will not enable. The following is in my phpinfo() output:
Opcode Caching Disabled
How can I get it to enable?
In the output from phpinfo(), have a look at the .ini files listed under:
Additional .ini files parsed
There may be something like
/usr/local/php5/php.d/20-extension-opcache.ini
Make sure opcache.enable=1 is set in this file.
If everything else fails, you could try:
sudo yum install php-opcache
Solved the issue on my PHP 7.2 version for Fedora.
Turns out I didn't have opcache installed (a key giveaway was the lack of a .ini file on the "Additional .ini files parsed" section of phpinfo()).
You might be looking for the ini file location
cat /etc/php.d/10-opcache.ini
check the [opcache] section in php.ini
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=0
Common Misunderstanding
Theres settings for PHP Cli and PHP-FPM
What you are seeing is that Opcache is disabled for CLI
Create a php file in your server (should be accessible from web). i named it phpi.php, add the following:
<?php
phpinfo();
?>
Open it from a browser http(s)://your_ip_or_domain/path/to/phpi.php
Scroll down and look for Zend OPcache
if you see Opcode Caching up and running, then its enabled
First do this
sudo apt-get install libpcre3-dev
then
sudo pecl install zendopcache-beta
Related
I'm trying to install laravel on windows 10. I installed composer to install laravel but it gives me below error.
[Composer\Exception\NoSslException] The openssl extension is
required for SSL/TLS protection but is not availab le. If you can
not enable the openssl extension, you can disable this error , at
your own risk, by setting the 'disable-tls' option to true.
Command doesn't matteri it gives above error with all commands...
I checked out this question and used solutions but it didin't work for me..
I tried these solutions
composer config -g -- disable-tls true
extension=php_openssl.dll // open openssl extension in php.ini file. - I restarted apache after that but nothing changed
I had the same issue. I did the following things to make sure the composer works out.
Find the php.ini which corresponds to where you issue the command from.
php --ini
sample output before correction:
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
This C:\WINDOWS here is a hoax. When I looked in the php installation directory, I found out there is NO php.ini. There are two files php.ini-development and php.ini-production. Just rename one to php.ini
Then you should see the correct ini path when you do php --ini
Set the extensions directory
Afterwards, open the php.ini file and uncomment the following line
;extension_dir = "ext"
should be
extension_dir = "ext"
Enable extensions
Then uncomment the extensions the same way. The following are usually required. (But please find out what you need from the messages you see from composer commands)
extension=fileinfo
extension=gd2
extension=mbstring
extension=openssl
I was running php7.2.x on my Windows 10 machine before I upgraded to PHP 7.4.10 (cli)
When I first pulled up the php.ini file, to my surprise, it was empty.
To be sure that I was looking at the right file, I did
php --ini
I was looking at the correct file.
I looked at the php folder of XAMPP and noticed two files:
php.ini-production.ini
php.ini-development.ini
I copied the contents of the first file and pasted in my php.ini file.
Then after a restart, I saw a ton of other modules were not being loaded.
I then went in to my php.ini file's Dynamic Extensions sections and had to uncomment all the following extensions:
extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
extension=pdo_firebird
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop
And then restarted Apache server agan, after saving my php.ini file.
This time, everything worked!
I'm using the standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. However, it appears that this version doesn't have Opcache enabled even though it should come as standard with PHP 7. It's even listed in phpinfo() under "Module Authors", but no section showing it's actually installed. Calling opcache_get_status gives a fatal error.
I've installed the extension via Homebrew, and linked the opcache.so file. It appears to be working on the CLI but not in Apache. For some reason the CLI and web are using different ini files:
/usr/local/etc/php/7.1/php.ini for CLI
/etc/php.ini for web
The CLI is parsing the addition files including /usr/local/etc/php/7.1/conf.d/ext-opcache.ini, and php -i shows Opcache. But phpinfo() in the browser does not - no additional ini files are parsed.
I currently have this in /etc/php.ini:
[opcache]
zend_extension="/usr/local/opt/php71-opcache/opcache.so"
opcache.enable=1
But still nothing. I followed the exact same process for xdebug and it worked fine. What am I missing?
I wonder if it would be easier to use the Homebrew version of PHP. But I don't appear to have the required .so file. Various tutorials say to put this in Apache's httpd.conf:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
But the libexec directory does not exist. There is lib but neither this nor any other directory has any .so file.
For me it worked by these steps:
Search extension_dir in "phpinfo()" page, I got a path
/usr/lib/php/extensions/no-debug-non-zts-20160303
By execute ls -lh /usr/lib/php/extensions/no-debug-non-zts-20160303, I found "opcache.so" , I guess it's installed when upgraded to "High Sierra"
Create "/etc/php.ini" (by copy "/etc/php.ini.default"), and modify:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
Restart apache, module "opcache" is enabled
EDIT / CONCLUSION
Since "opcache extension" is installed on Mac OS High Sierra by default, the solution of enabling opcahe on Mac OS High Sierra is:
Create "/etc/php.ini" if you don't have one, by simply copy the default configuration: sudo cp /etc/php.ini.default /etc/php.ini
Add zend_extension = opcache.so to /etc/php.ini and set "opcache" enable:
php.ini opcache section looks like:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
I am finding it tricky to enable OPcache on my MacOS Sierra (10.12.6) system.
php --ini shows the ini file used:
Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File: /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.0/conf.d/ext-pdo_pgsql.ini
My php.ini looks like this:
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
However, when I look at phpinfo() it shows the following:
I've restarted Apache after making the change to my php.ini to include opcache, but it doesn't appear to be recognised.
I installed PHP with Homebrew, not MAMP although I do have MAMP install but unused.
I got to the bottom of this eventually...
In the output from phpinfo(), have a look at the .ini files listed under:
Additional .ini files parsed
There may be something like
/usr/local/php5/php.d/20-extension-opcache.ini
Make sure opcache.enable=1 is set in this file.
I've made the possible changes to the php.in at /etc/php.ini. I didn't had php.ini so took a copy of php.ini.default. The changes I've made are
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=64
When I print phpinfo() and see the result, I tried to find opcache and it is not showing up. I'm using Mac Sierra.
Make sure you have edited the correct php.ini (it can be seen in the phpinfo() result).
Check, if the files listed in "Additional ini files parsed" does not override your settings. (e.g.: opcache.enable=0 somewhere override your php.ini setting)
If you are using PHP-FPM, that need a restart / reload to pick up the changes.
I installed php5.5 to my CentOS DirectAdmin server.
I used this http://help.directadmin.com/item.php?id=567 to install OPcache en set it to yes.
I did enable OPcache also in my php.ini file with opcache.enable=1.
But when I check my phpinfo() it is displayed like this:
So is it enabled now or not, because Opcode Caching is disabled but opcache.enable is On?
All changes I made in the php.ini file, are saved and I see them in my phpinfo(). But Opcode Caching is still disabled.
maybe you edited wrong php.ini file!
try to find your php.ini file with this command /usr/local/bin/php -i | grep 'Loaded Configuration File'