Apache and Symfony date.timezone error - php

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.

Related

Windows, XAMPP, PHP 7 and opcache

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

Symfony2.8 : installation not complete

I downloaded Symfony2 et when I create a project /var/www/html# php ../symfony.phar new MyProject 2.8
At the end, I have this message :
Preparing project...
✕ Symfony 2.8.2 was successfully installed but your system doesn't meet its
technical requirements! Fix the following issues before executing
your Symfony application:
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
After fixing these issues, re-check Symfony requirements executing this command:
php Projet_miage/app/check.php
Then, you can:
* Change your current directory to /var/www/html/Projet_miage
* Configure your application in app/config/parameters.yml file.
* Run your application:
1. Execute the php app/console server:run command.
2. Browse to the http://localhost:8000 URL.
* Read the documentation at http://symfony.com/doc
But why ?
(I have xampp and I am on Ubuntu)
Because to make your application working properly, Symfony need some specific PHP configuration.
Find your php.ini by running:
php --ini
This will output something like :
Configuration File (php.ini) Path: /path/to/php
Loaded Configuration File: /path/to/php/php.ini
Then, open it:
nano /path/to/php/php.ini
Find the line date.timezone and change it to :
date.timezone = "Europe/Paris"
Of course, if "Europe/Paris" is not your timezone, you can replace by yours.
Please set the timezone in your php.ini
date.timezone = " Europe/Paris"
Restart xampp after that

PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini

When i am trying to start Apache, the following error appears in the Apache error log:
PHP Fatal error: [ionCube Loader] The Loader must appear as the first
entry in the php.ini file in Unknown on line 0
From the error message itself its clear what is the error. Please do some research before posting on stackoverflow.
Zend extensions can be loaded directly from /etc/php.ini file or included from /etc/php.d/ directory.
In the following example, this ioncube line must appear before any Zend configuration sections. These sections usually begin with [Zend] so they should be easy to see:
zend_extension=/usr/lib/ioncube/php_ioncube_loader_lin_X.X.so
If extensions are loaded from /etc/php.d, they are loaded in alphabetical order. Usually the ioncube file is named /etc/php.d/ioncube.ini and zend is /etc/php.d/zend.ini. In this scenario, it should not present a problem.
Finally, make sure that ioncube is loaded only once. The following command should only return one result:
grep 'zend_extension.ioncube' /etc/php.ini /etc/php.d/
If you make any configuration changes, always be sure to restart Apache:
/etc/init.d/httpd restart
https://mediatemple.net/community/products/dv/204404974/resolve-apache-error:-%22php-fatal-error:-%5Bioncube-loader%5D%22
Came to this thread when looking for this error, as #Hari Swaminathan said.
If extensions are loaded from /etc/php.d, they are loaded in alphabetical order
I got the error on a docker setup. So naming ini file like 00-ioncube.ini solved the problem
This error occurs because of an incorrect extension order in PHP configuration. Read this website may help you.
You must load ioncube with higher priority.
Had the same issue on a docker local development
Was able to ADD a ioncube specific ini file and module file
# Add ioncube
ADD etc/ioncube_loader_lin_7.2.so $PHP_EXT_DIR/ioncube_loader_lin_7.2.so
# Add php overrides
ADD etc/docker-php-ext-ioncube.ini $PHP_INI_DIR/conf.d/docker-php-ext-ioncube.ini
Thanks #davidmpaz

Symfony date.timezone error on Yosemite

I've created a new Symfony project with
$ symfony new my_project
This is now in a folder called /Symfony/my_project
At this point I get this:
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php on line 262
✕ Symfony 2.7.3 was successfully installed but your system doesn't meet its
technical requirements! Fix the following issues before executing
your Symfony application:
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
Than says
Then, you can:
* Change your current directory to /Users/[username]/Dropbox/private/dbx/Symfony/my_project
* Configure your application in app/config/parameters.yml file.
* Run your application:
1. Execute the php app/console server:run command.
2. Browse to the http://localhost:8000 URL.
At this point I don't know where is the php.ini file in Yosemite. I've looked around and found an answer on this but the php.ini used is not the one I edited.
Which and where is the php.ini file to edit?
Try to modify the real php.ini, you can find it running php -i | grep "php.ini" on Terminal.
Remember that sometimes you'll find only a file called php.ini.default so you have to copy the file php.ini.default in a new php.ini file using sudo cp php.ini.default php.ini
Once you create the new php.ini file you have to change the permission in order to be able to modify the content:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Now you can open the file php.ini and modify the date.timezone line.
NOTE: Remember to remove the comment if the line is commented.
If this doesn't work try to add the init function to your AppKernel.php file (code below), this really helped me.
<?php
class AppKernel extends Kernel
{
// Other methods and variables
// Append this init function below
public function init()
{
date_default_timezone_set( 'Europe/Paris' );
parent::init();
}
}
Since this is Terminal-based run and not browser based you can easily find that out. From your Terminal, run this:
php -i | grep "php.ini"
This will output the location of php.ini used. Then edit the file via any text editor (graphic or otherwise) and set the approprite time zone.
Hope this helps.

Call to undefined function openssl_random_pseudo_bytes() XAMPP [duplicate]

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' );

Categories