I'm programming in php on my machine where I freshly installed:
Centos 6: centos-release-6-10.el6.centos.12.3.x86_64
Php 7 - PHP 7.0.31 (cli) (built: Jul 17 2018 15:40:48) ( NTS ) (Zen Engine 3.0.0)
Apache 2 - Server version: Apache/2.2.15 (Unix)
As fresh install nothing were logged. (first time this happens)
My php info tell me I have /etc/php.ini configuration file, where I have:
error_reporting = E_ALL
display_errors = Off
display_startup_errors = On
log_errors = On
log_errors_max_len = 0
html_errors = On
error_log = /var/log/httpd/php-error.log
On php info I see correct variables as wrote here.
In httpd.conf
ErrorLog "/var/log/httpd/error_log"
LogLevel debug
There is no ovewrite configuration in my virtualhost. I just tried debug to fix this issue, but nothing.
To make sure for me that anything can have access to log path, I used chmod 777 on the folders /var, /var/log, /var/log/httpd, and on error.log apache file. I didn't on php error file since it's not present, and as far as I know, Apache (or php) sould create it on it's own.
My php has eveident errors, and on different environment (with php 5) is naturally logged on apache log file.
I obviously restarted apache service at any change.
I searched really a lot before asking, and nothing that was suggested has never worked.
Am I really missing something?
Thanks. Riccardo
Update: After the best badge I could have earned: "Tumbleweed", I want to update with something more I tried:
I tried with code inside the php file:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
And nothing was logged.
display_errors = on in php.ini
This didn't work either
I'm really struggling programming without a error log...
Thanks to anyone.
Finally I got what was the problem.
Well.. maybe it is just MY problem...
By the way, with php 7.0 I had a php.ini corrupted file, I didn't see it had a lot of strange character.
I had to correct all the file and everything worked as a charme.
Hope anyone else could benefice from this.
Related
A simple php_curl example isn't working anymore on my Windows 10 laptop. It was working before.
Fatal error: Uncaught Error: Call to undefined function curl_init() in C:\Users\path\curl.php:3 Stack trace: #0 {main} thrown in C:\Users\path\curl.php on line 3
My C:\php7\php.ini has extension=C:\php7\ext\php_curl.dll
php_curl.dll exists in C:\php7\ext
PHP Version 7.0.30
Windows 10 Pro Version 1607 Build 14393.2189
But my loclahost/phpinfo.php does not have cURL. How come all of a sudden it disappeared ?
PS : The script worked in the command line. It's just that Apache is not loading the extension.
don't know why it suddenly stopped working, but first run <?php phpinfo(~0); , and check which php.ini file that is actually loaded (this avoids editing the wrong php.ini file to no avail) (in this example, it is /etc/php/7.0/fpm/php.ini), then edit that php.ini file, if that file actually has the extension=C:\php7\ext\php_curl.dll line, then some combination of the following settings are set wrong:
display_startup_errors is Off, change it to On
display_errors is Off, change it to On
error_reporting is not E_ALL, change it to error_reporting=E_ALL (and nothing else, not like error_reporting= E_ALL & ~E_NOTICE or whatever, just E_ALL)
html_errors is Off, change it to On
then restart apache, again check the phpinfo() page, and verify that the new configuration options are actually loaded, then run <?php curl_init();, and it should show an error about why the curl extension could not be loaded.
I came across some links on other StackOverflow answers (will post the links here if I trace them again). I had Apache 2.4.23 Win64 - I reinstalled Apache to the latest one - 2.4.33 Win64 - and now cURL is working.
I have a weird situation where Wordpress PHP some errors are not showing up neither in my MAMP error logs, nor in my per-host error log.
When I tail -f /Application/MAMP/logs/*error* the MAMP error logs I see:
[Wed Apr 18 00:18:23 2018] [error] [client ::1] FastCGI: incomplete headers (0 bytes) received from server "/Applications/MAMP/fcgi-bin/php5.4.45.fcgi"
Nothing when I tail -f <local-site-host-path>/*error* I see no updates whatsoever, even tho I have added a php.ini and .user.ini (just in case) to log errors, have chmod 777 all error_log files, and have this in both .ini files:
log_errors = On
error_reporting = 8589934592
error_log = /<local-site-host-path>/error_log
display_errors = 1
NOTES:
if I intentionally make a PHP code typo, I see the errors in the MAMP logs but not in the host logs.
MAMP installed on a Macbook,
Running a few Wordpress sites (latest 4.9.5) with all plug-ins up to date) (error is not showing up for all of them).
The actual 500 server error is happening ƒor /wp-admin/* ONLY for a site (wp 4.9.5) and partially for another site (wp 4.9.5); Yet a third site's /wp-admin/* (wp 4.9.2) works just fine (!?!?!?)
Or am I being hacked (as Ripul Kumar points out here, but with no further information on what symptoms were present that showed him he was hacked: MAMP Pro doest no log PHP errors) => I ACTUALLY REINSTALLED MAMP + MAMP Pro to see if that made any difference. NO, it didn't. EXACT SAME result.
THANK YOU
I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache, so I enabled it in php.ini.
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
With that change now, and with almost every page refresh, I'm getting this error from Apache:
AH00428: Parent: child process 3748 exited with status 3221226356 -- Restarting.
So, page is loading, and loading... waiting to Apache start again. When I'm turning opcache off (by setting opcache.enable=0), Apache is not restarting and everything works fine (omitting the slower web application topic, of course).
Everything works fine while loading app on XAMPP having PHP 5.6 with enabled opcache.
EDIT (added GIF image):
As you can see, sometimes page refreshes like it should. But sometimes it's refreshing much longer, and Apache is restarting in that moment.
EDIT:
To be honest, I gave up with this application and working with PHP on Windows (was working on it for around 10 years with PHP <= 5.6). It's very hard/impossible (for now) to make PHP 7.x work on that OS (with Opcache). Decided to go with Ubuntu and server created with Docker. Everything is easier to configure (especially with Docker) and works faster. I advise everyone to do the same ;).
Your php_opcache.dll path seems wrong, you need write it like below, it works for me.
[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=2000
More details
If your XAMPP comes with PHP 5.5+ by default, opcache already included in the bundle, you will just need to enable it. To enable the extension:
Open php.ini (by default it should be located here: C:\xampp\php\php.ini).
Add this line at the end of the file:
zend_extension=C:\xampp\php\ext\php_opcache.dll
Restart Apache server.
open a php.ini file
Change the ;opcache.enable=1 to opcache.enable=1
Add opcache dll path at the end of the file zend_extension = "C:\xampp\php\ext\php_opcache.dll"
Restart apache
for more reference check this video https://www.youtube.com/watch?v=GvWrNoRDjUY
In case of Xampp, just put the below lines next to [opcache]
zend_extension="C:\xampp\php\ext\php_opcache.dll"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
To be honest - do not use xammp. Right now we have a bit better tech stack, to run PHP on Linux servers.
Docker
https://docs.docker.com/docker-for-windows/
Vagrant:
https://www.vagrantup.com/
Both of them are based on linux systems, where most of xammp problems will not have place.
First at all:
This is 2022 and I had a similar problem too with PHP-7.2, not on Xamp, but similar server.
How I've got my problem solved?
If you're here because of that, at first try to go with a default "opcache configuration options". And just above opcache.enable=1 put zend_extension=opcache. Your PHP is smart enough to find the extension. And yeah, there's no need to define the full path if you have defined it here extension_dir = [YOUR PATH] (in php.ini). Of course you can use the full path too, if you want too. The path, probably, it's not a problem if your extension is there (in the folder with all PHP extensions). Did you checked, is it there, your extension?
My problem was in this two options:
opcache.memory_consumption
opcache.interned_strings_buffer
I have no idea why, but I guess this two option should have some balance, because both of them is about memory usage.
So, this had my Apache useless, because it didn't wanted to start
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32 ;this one BAD
next one works fine!
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 16
this one is works fine too!
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 32
So, as I said, at first try to go with a default values of "opcache configuration options", and later do experiments.
How to check everything works on PHP?
var_dump ( zend_version() );
var_dump ( extension_loaded("opcache") ); // bool(false) cuz it's ZEND
var_dump ( extension_loaded("Zend OPcache") ); // bool(true)
// Next one will give you a lot of data about current opcache usage,
// but of course, only if your extension is enabled.
print_r ( opcache_get_status() );
Default OPcache configuration options you can find here:
https://www.php.net/manual/en/opcache.configuration.php
Creeating directory with appropriate permissions and setting it php.ini worked!
opcache.file_cache=d:\xampp\htdocs\opcache
ThreadStackSize 8388608
Helped me in the similar case. This is a httpd option.
on php.ini add more
zend_extension=opcache
remove comment
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.max_accelerated_files=10000
restart apache
I am trying to install Symfony with my Apache (Ubuntu) but I get this error:
Set the "date.timezone" setting in php.ini* (like Europe/Paris)
Using phpinfo() in my browser it says that the configuration file is in /etc/php5/apache2/php.ini So I modified it wtih
date.timezone = "Europe/Paris"
I also modified the file /etc/php5/cli/php.ini
I also run php app/console cache:clear as it was suggested in this question Fixing requirements in Symfony2 but with no results. I restarted the server every time.
What else can I try?
Thanks!
Try removing double quotes
date.timezone = Europe/Paris
Please see David Jacquel correct solution below !
I leave this answer for historical purposes...
In sf1, I ran through this and got it fixed with a
date_default_timezone_set('Europe/Madrid');
in the bootstrap (that was ProjectConfiguration.class.php).
In sf2 you may modify the web/app.php file to insert the same piece of code. It is a bit hackyish, but will get you up and running.
I spent three hours but I did not find anything; I'm unable to connect to a SSL enabled server. I want to list what i did:
First checked my PHP extensions directory was in order; extension wasn't there, php_openssl.dll
Then I opened my php.ini file but I could not see any extension=php_openssl.dll line to uncomment.
Also, I searched on Google and saw people with the same problem.
http://www.apachefriends.org/f/viewtopic.php?p=162623
However, I also have
OPENSSL_CONF C:/xampp/apache/bin/openssl.cnf
...
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8l 5 Nov 2009
OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009
no lines . What should I do? Please share your suggestions.
Yes, you must open php.ini and remove the semicolon to:
;extension=php_openssl.dll
If you don't have that line, check that you have the file (In my PC is on D:\xampp\php\ext) and add this to php.ini in the "Dynamic Extensions" section:
extension=php_openssl.dll
[PHP_OPENSSL]
extension=php_openssl.dll
This is the answer.
Things have changed for PHP > 7. This is what i had to do for PHP 7.2.
Step: 1: Uncomment extension=openssl
Step: 2: Uncomment extension_dir = "ext"
Step: 3: Restart xampp.
Done.
Explanation: ( From php.ini )
If you wish to have an extension loaded automatically, use the following syntax:
extension=modulename
Note : The syntax used in previous PHP versions (extension=<ext>.so and extension='php_<ext>.dll) is supported for legacy reasons and may be deprecated in a future PHP major version. So, when it is possible, please move to the new (extension=<ext>) syntax.
Special Note: Be sure to appropriately set the extension_dir directive.
So, what did we do to make openssl_pkey_new() and all the other openssl_ functions in PHP work...
Enabled the extension php_openssl.dll in the (right/active) php.ini. Checked.
Checked that there exists a openssl.cnf in xampp\apache\conf\ (and also in two other directories within XAMPP). Checked.
Added the environment variable OPENSSL_CONF in the Windows system settings with the full path to the above openssl.cnf. Checked.
Restarted Apache (and after that did not work restarted the computer several times...). Checked.
Still does not work, and throwing errors such as
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:02001002:system library:fopen:No such file or directory
error:2006D080:BIO routines:BIO_new_file:no such file
Okay, here are another two more things to check.
1. Trouble with the environment
Run phpinfo() from a PHP script, and go to the "Apache Environment" section. Check the value of OPENSSL_CONF.
Surprise. This is not what we have set in the windows system settings.
The solution is simple. Set the environment variable in the PHP script.
putenv('OPENSSL_CONF=C:\xampp\apache\conf\openssl.cnf');
2. Trouble with relative filenames
Now, openssl_pkey_new() will work, but openssl_pkey_export_to_file() does still not work and returns false without any further explanation?
Check the filename that you have specified as output filename. It will not work in Windows as long as you do not specify the full path.
$folder = realpath('../keyring');
$outfile = $folder.'/private.pem';
openssl_pkey_export_to_file($key, $outfile);
I use xampp. Beforehand I tried the example file "test_smtp_gmail_basic.php" in phpMailer (you can download phpMailer here: https://github.com/Synchro/PHPMailer), but I got the following error:
Mailer Error: The following From address failed: xxx#gmail.com
After I commented out ; extension=php_openssl.dll in php.ini, it is working now.
In xampp, if "extension=php_openssl.dll" is not present in your php.ini file then add it in the "Windows Extensions" section of your php.ini file
and restart your apache.
It works for me..
You will need to edit your php.ini. It's 4 easy steps.
Find your php.ini file.
$inipath = php_ini_loaded_file();
Enable openssl in the file:
extension=php_openssl.dll
Turn allow_url_fopen on
allow_url_fopen = On
Restart apache and you are done!
STEP 1: On your php.ini comment out ;extension=php_openssl.dll
STEP 2: Copy libeay32.dll and ssleay32.dll from your PHP root folder and paste it your Apache/bin folder
STEP 3: Restart Apache
I am assuming that this question is for those using a windows based system.
After making sure that the extension extension=php_openssl.dll in your php.ini file does not have a semicolon.
Then make sure that you have added C:/xampp/apache/bin into your environment path in order to use openssl without having move the command prompt to that directory C:/xampp/apache/bin
Although not related to this question but as the WP migrate Pro docs link to this question I though I would post an answer here.
If your having problems with DB Migrate Pro activating instead of enabling SSL you can just add a line of code to your wp-config
define( 'WPMDB_LICENCE', 'XXXXXXXXXXx' );