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'
Related
I need to change upload limit to 2GB on php 7.2 Ubuntu 16.04.
As a first step, when I check /etc/php/7.2 folder I can see cli and
fpm folders.
So to make sure the ini location I have print the php info using
echo phpinfo()
And I got the output
Server API : FPM/FastCGI
Virtual Directory Support : disabled
Configuration File (php.ini) Path : /etc/php/7.2/fpm
Loaded Configuration File : /etc/php/7.2/fpm/php.ini
And I have edited /etc/php/7.2/fpm/php.ini with
upload_max_filesize = 2048M
And restarted the apache but using phpinfo() still it print
upload_max_filesize 2M
So I have tried with command php -i | grep -i "loaded configuration file" but it print different configuration file,
Loaded Configuration File => /etc/php/7.2/cli/php.ini
On this file also I have changed upload_max_filesize to 2048 and restarted the Apache and still the result is same.
What could be the problem, any help will appreciated.
I got the problem resolved by the answer here Changes to upload_max_filesize in Ubuntu php.ini will not take effect.
Instead of restarting the apache I have to restart the php using
sudo service php7.2-fpm restart
You should also change in php.ini:
post_max_size=2Gb
first at all you should remove all older php version on your ubuntu.
what is your cli php version?
are you sure that you find correctly php.ini location?
please run this command " locate php.ini "
Sometimes due to error in php.ini files the configuration files are not loaded after that specific error line. In that case you have to thoroughly check the php.ini file and fix the errors.
Alternatively you can download fresh php.ini files for your php version and replace your existing file with the new one.
After making changes in the new file restart your server using service apache2 restart .
If changing /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini still does not work out, try changing /etc/php/7.2/apache2/php.ini. Please note that you might have to restart the apache2 server using sudo service apache2 restart. (This solution is tested on server with Ubuntu installed. )
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 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
I've installed Apache 2.4.x webserver on Ubuntu and also PHP5.5.x from sources. I go to php installation folder and do find . -name "opcache.so". Then, to php.ini (same as in phpinfo()), I add zend_extension=/php5/lib/php/extensions/no-debug-zts-x/opcache.so, and opcache.enable=On (or 1) and restart Apache with apachectl restart. Then I check phpinfo() but opcache does not get enabled! Please help.
I think a wrong php.ini file might be used, but in phpinfo() it shows the path to file which I do edit. When I change maximum upload filesize from 2M to 4M in the php.ini, and restart Apache, it does not get changed in phpinfo()
Turns out, after compilation PHP would look for the ini file in /usr/local/lib rather than where I installed it despite
--with-config-file-path=PATH
Set the path in which to look for php.ini [PREFIX/lib]
To check it, you can run php --ini to see if the file has been read fine.
But now I'm seeing white screen when trying to load php files :)
Hope it helps.
I'm running the latest php-cgi from Arch Linux's repos. I enabled the BCMath module on php.ini and it works when I run php, php-cgi and php in Apache. However, when dev_appserver.py runs php, somehow it loses the configuration I set in php.ini. Causing both BCMath, soap and my locale settings to not load, causing:
dev_appserver.py --php_executable_path /usr/bin/php-cgi appengine-try-php
PHPEnvironmentError: The PHP runtime requires the "bccomp" function, which is not defined.
php-cgi -i | grep -i bcmath returns BCMATH enabled.
php -i | grep -i bcmath returns BCMATH enabled.
php -r "echo bccomp('1.0001', '1', 5);" returns 1.
Is there any way to make dev_appserver.py load the module or php.ini?
Here's the code that fails - we check if the function exists.
if (!function_exists('bccomp')) {
echo "The PHP runtime requires the \"bccomp\" function, which is not ";
echo "defined.\n";
echo "If you built PHP using \"configure\" then please rebuild with:\n";
echo ' ./configure --enable-bcmath';
exit(1);
}
I don't know why you'd have the extension enabled but the function not existing. Probably try listing the functions that are available to double check it's there.
php -r 'print_r(get_defined_functions());' | grep -i bccomp
google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php/runtime.py
Supports loading a php.ini file from the project directory, as such you can just drop a php.ini file in the project directory. It will by default ignore the php.ini file in /etc/php/php.ini unlike all other instances of php. Here is the php.ini script I'm using. It likely has extra modules and modules that are missing compared to the production App Engine.
date.timezone = America/New_York
extension=bcmath.so
extension=bz2.so
extension=curl.so
extension=gd.so
extension=gettext.so
extension=mcrypt.so
extension=mysqli.so
extension=mysql.so
extension=openssl.so
extension=pdo_mysql.so
extension=soap.so
extension=zip.so
Happy Apping.