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
Related
I am trying to update memory_limit in php.ini, but I don't see the value updated in phpinfo(). Here is the ini file path info from phpinfo():
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Updated /etc/php.ini and then ran:
systemctl restart httpd
I tried updating other values in ini file to see if anything gets updated, but nothing does.
I am on an AWS EC2 linux instance with wordpress.
Many modern PHP installations run PHP-FPM by default, instead of as an Apache module mod_php. PHP-FPM is itself a separate service that needs to be restarted via your operating system's preferred method. e.g.
$ sudo systemctl restart php-fpm
You mentioned you already knew which php.ini to modify from the phpinfo() output. For future readers, the PHP-FPM service may use a different php.ini. Consult the output from phpinfo() when loaded via the web to find out which php.ini to modify.
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
When i change content of "php.ini" file that placed in "Configuration File (php.ini) Path" in phpinfo() ,file had been changed but phpinfo() shows unchanged settings.
I'm using Elastix on centOS. This is caused after I install phpmyadmin and after that seseeions did not saved and I wanted to change session.savepath.
don't forget to restart your service
for example for Apache
/etc/init.d/apache2 restart
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 can't seem to get my max_upload_filesize to change despite updating the the php.ini file. Here is a screenshot of the loaded config file, upload_max_filesize in the phpinfo() and the php.ini open along side it:
https://drive.google.com/file/d/0B3b3kShpACJHcFV6YU9XMkdyR0E/view?usp=sharing
after updating the file I've tried:
sudo /etc/init.d/apache2 restart
and I've also tried to stop/start it:
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start
the phpinfo() says the config loaded is:
/etc/php5/apache2/php.ini
but when I run:
php -i | grep "php.ini"
it returns the following:
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
So I've updated this config file also to 100M and restarted apache, stop and started it again but yet my phpinfo() is still showing 2M max upload.
What could the problem be?
UPDATE! I have deleted both the php.ini files on my system in etc/php5/cli and etc/php5/apache2 and restarted but it still says its loading the config from etc/php5/apache2 hos is this possible when I've completely removed the file?
Your cli command php and your Webserver use different php.ini files. That why you have to change both of them.
And you have to change post_max_size in your php.ini, too. Otherwise you can't send enough data to your webserver.