For a localhost environment I am trying to setup the default date in /etc/php.ini.
Running $ php -i shows date.timezone => America/New_York => America/New_York
phpinfo() is still giving me the "It is not safe to rely on the system's timezone settings."
I've tried deleting and copying the php.ini.default and restarting apache multiple times.
Adding the php.ini file to a project folder also doesn't set a default value. But setting date_default_timezone_set('ZONE') works. I'd prefer to set it globally.
Environment
PHP Version 5.5.31
Apache 2.4.18
$ php --ini results:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
phpinfo() results:
Configuration File (php.ini) Path /etc
Loaded Configuration File (none)
Scan this dir for additional .ini files /Library/Server/Web/Config/php
Within the httpd-vhosts.conf file I defined a PHPIniDir value for a local server address.
After removing that line, the default values loaded in again. Now I'm running into a different issue (per directory ini files), but defining the date.timezone's default value has been resolved. Other settings can be overridden using the directory's .htaccess
Related
First of all, please forgive me for my poor English skills.
After installing the compilation of Apache, php5.3 on CenOs 7,
we have a problem with the path to set up php.ini
First of all, look at the setting value here.
Shell
PHP -r "phpinfo();"
Configuration File (php.ini) Path: /usr/local/php53/etc/php.ini
Loaded Configuration File: (none)
Scan for additional .ini files in: /usr/local/php53/etc/php.d
Additional .ini files parsed: (none)
Web
<? phpinfo(); ?>
Configuration File (php.ini) Path
/usr/local/php53/lib
Loaded Configuration File
(none)
Scan this dir for additional .ini files
/usr/local/php53/etc/php.d
Additional .ini files parsed
(none)
Found the php ini-production file in the source file.
Changed the asp_tag value in the php.ini file to On.
By changing the name to php ini.
Move to
/usr/local/php53/lib/php.ini
path
I started the Apache again, but the settings haven't changed.
I want to know how to change php.ini
Please reply.
Thank you for reading.
I installed php 5.6.6 as an apache 2.4 module.
When loading a page with < ? phpinfo(); ?>, it said :
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File (none)
So, as the doc suggests, I edited httpd.conf to point php.ini configfile (in C:\php56).
I also added C:\php56 to PATH and PHPRC environnment variable.
As I don't have any php.ini file in this folder, I copied and renamed the "php.ini-production" one, and edited path to extensions.
When I display the page again, it stays blank ...
here is the "php --ini" command result :
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\php56\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Which step am I missing ?
Is it possible that the phpinfo function is disabled in your php.ini configuration (disable_functions option)?
If that is not the case try swapping to the development .ini file which by default reports more errors.
I installed MAMP for windows
I have this error since several hours...
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: date_default_timezone_get(): 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 me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.
In the php.ini concerned (C:/MAMP/conf/php5.5.19/php.ini), I changed the line DATE like this:
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Paris"
And in my phpinfo(), the path loaded is :
Loaded Configuration File C:\MAMP\conf\php5.5.19\php.ini
When I do in the consol the command php --ini I have this :
C:\Users\Thomas>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Why Configuration File (php.ini) Path: is "C:\Windows" and not C:\MAMP\conf\php5.5.19\. Can I change this Path ?
I don't know what to do now...
thanks !
I had the same error. I had no clue where it was coming from, but with some trial and error I figured out it had something to do with the special character in my htdocs folder:
htdocs/Exámple
By changing that character to a normal character (thus changing to htdocs/Example), I no longer got the error and the site would load normally.
The problem is that your xAMP server and cli access uses different php configuration.
One is C:\Windows\php.ini for CLI
Second is C:\MAMP\conf\php5.5.19\php.ini for web server
Make sure you have updated both files.
Secondly do not forget to restart xAMP server, as apache do not reload libapache2-mod-php5 configs automatically.
When you set configuration in MAMP it only affects PHP which is loaded in Apache module handler mode (mapped as module inside Apache process). If you want to set PHP CLI you need to set this separately from web server configuration.
Open command prompt from Windows (cmd.exe from Start button)
enter ECHO %PATH%
this command will list your current PATH variable with all paths. For example, something like this:
C:>echo %PATH%
C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\binaries\php\php_runningversion
;C:\ProgramData\Oracle\Java\javapath;C:\Perl\site\bin;C:\Perl\bin
...
now enter following command
SET PATH=%PATH%;c:\mamp\bin\php\php5.6.0\;
This will going to add path to php5.6.0 version from MAMP folder.
you can now test your PHP CLI by entering following command :
php -v
then try to initialize configuration from MAMP for version PHP5.6.0 file:
C:>php -c "c:\mamp\conf\php5.6.0\php.ini" --ini
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\MAMP\conf\php5.6.0\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
You can use command -c from PHP CLI to set path to configuration file; and "c:\mamp\conf\php5.6.0\php.ini" is path to PHP ini file for version 5.6.0.
If you do not want to always add path to configuration file with -c command, just copy php.ini file from C:\MAMP\conf\php5.6.0\ to C:\MAMP\bin\php\php5.6.0\
Off course, this will going to set PHP CLI only in currently opened command prompt. To add this path permanently, you need to modify System Environment variable, or to use MAMP PRO as it already have this feature on PHP options page.
TL:DR - Make sure to edit both the ..\MAMPPRO\conf\php[version].ini and the ..\MAMP\bin\php\php[version]\php.ini with your correct/approved php timezone.
So while I was going through my setup, I had the same issue.
I was taking a look at my phpinfo() and it was giving me a path to my "Loaded Configuration File" that was located in my ..\MAMPPRO\conf\php[version].ini so I was editing that file with approved timezone from http://php.net/manual/en/timezones.php making sure to avoid any from http://php.net/manual/en/timezones.others.php.
After a few restarts and no success I started to dig a little further into where MAMP Pro was pulling that ini.
I found the solution in ..\MAMP\bin\php\php[version]\php.ini. If I edited this file IN ADDITION TO editing the MAMP Pro ini everything worked properly.
Hopefully this can help you out!
At the beggining of your web/app_dev.php and web/app.php you can add:
date_default_timezone_set('Europe/Paris');
I set up a new environment using OSX Yosemite.
I'm using the built-in PHP.
I'd like to change some config in php.ini such as date.timezone but none of the modifications are working despite restarting the apache server (sudo apachectl restart).
phpinfo() is giving a different path than php --ini command.
phpinfo():
Configuration File (php.ini) Path /usr/local/php5/lib
Loaded Configuration File /usr/local/php5/lib/php.ini
Via commands :
which php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
So I guess I have to tell somewhere where I should set the default php.ini to be used.
Any ideas, hints?
move the configuration file to the right spot and update the timezone.
$ sudo cp /etc/php.ini.default /etc/php.ini
Open the config file /etc/php.ini, find the line that sets your timezone and update it correspondingly.
date.timezone = Europe/Berlin
Do not forget to remove the ; at the beginning.
Restart the Apache server to have PHP load the new .ini file.
sudo apachectl restart
SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
http://php.net/manual/en/configuration.file.php
Try changing PHPIniDir in httpd.conf.
On mac sierra with php7.1, edit /usr/local/etc/php/7.1/php.ini won't work, you can edit like this:
1) cp /etc/php.ini.default php.ini
2) edit php.ini to add
date.timezone = Europe/Berlin
then restart your apache,
Short answer: If you're on mac and you have the file /usr/local/php5/php.d/99-liip-developer.ini then edit timezone there and it will effect php-cgi (web-browser)
Long answer:
n mac system for few settings like timezone php.ini file (showing loaded in phpinfo) don't work. Because sometimes we unknowingly install php packaged by Liip. That's why apache picks up few settings from liip-developer.ini config file which is usually located at /usr/local/php5/php.d/99-liip-developer.ini
I have done this before so I'm not sure why it's not working, but I am trying to create a custom php.ini file and I have placed this within a specific directory.
For example, the default php.ini is located at:
C:\xampp\php\php.ini
My custom one is located at:
D:\Codebase\Somedir\123\php.ini
I placed a PHP file inside the above directory and did output with phpinfo() and it still reports it as using C:\xampp\php\php.ini.
I have restarted Apache as well.
What am I doing wrong here!?
You can see which php.ini file is loaded running php.exe --ini. On my computer it output:
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\tools\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
If it is the wrong php.ini there, have a look to http://php.net/configuration.file
If you're using XAMPP you can change the configuration file it loads PHP with by opening the properties.ini file in the
C:\xamp
directory and editing the php_configuration_directory field to
D:\Codebase\Somedir\123\
Then restart apache for the changes to take effect.
If PHP is running as an apache module you could also edit httpd.conf on your apache setup and add this variable:
PHPIniDir "D:\Codebase\Somedir\123\"