Issue with increase local memory_limit [duplicate] - php

I have a clean install of a CentOs with php 5.2.13.
In php.ini that is loaded and present in the header of phpinfo() I have
safe_mode=off
in the phpinfo() information I have
// local value - safe_mode: On
// master value - safe_mode: off
the php file has only a phpinfo() function.
I am still looking for vhost file to see if any directives are there overwriting this, but still then any sugggestions?

Look for "Additional ini files parsed" in phpinfo() output. This setting can also be changed in the Apache config (including .htaccess files).

"Master Value" (from php.ini) could be overridden with "Local Value" in httpd.conf, .htaccess or other Apache configuration with php_value directive.

I found the problem/solution to be in the extra config file that is added in the vhosts folder.
The file is named httpd.include and it has this line
php_admin_flag safe_mode on
PS. I really hate when other systems create files on the fly like this, especially with values they want.

Related

phpinfo shows allow_url_fopen is Off. It is On in php.ini

I'm trying to run a php website with nginx using php8.1 and php8.1-fpm, in a Ubuntu 20.04 vps.
phpinfo reports that the config file in use is: /etc/php/8.1/fpm/php.ini
It also reports that allow_url_fopen is Off (both Local Value and Master Value).
Examining /etc/php/8.1/fpm/php.ini shows:
allow_url_fopen = On
I suppose that's the default setting. But I need this value to reflect in phpinfo and I can't get that to work.
I've tried changing the value, restarting nginx and fpm, changing it back and restarting again, but nothing works. Feels like phpinfo is getting its values elsewhere. I've checked all files in /etc/php/8.1/fpm/conf.d (the config folder reported by phpinfo) and there is no allow_url_fopen in any of those.
How do I get allow_url_fopen to be On?
Type “php --ini” command to find the location of the PHP configuration file.
On the above server, you can see that the PHP configuration file is in location “/usr/local/lib/php.ini”
Edit the php.ini file to enable allow_url_fopen.
root#server [~]# vi /usr/local/lib/php.ini
allow_url_fopen = On
Change the line “allow_url_fopen = Off” to “allow_url_fopen = On”
Save the php.ini file after changing allow_url_fopen to On.
Restart the apache service after enabling allow_url_fopen.
Now, allow_url_fopen is enabled globally for all domains on your Server. allow_url_include = On
On some systems there's a file /etc/php.d/security.ini or /etc/php/8.1/fpm/conf.d/99-security.conf in which allow_url_fopen is turned of. If present it overrides the settings in php.ini system wide.
Unfortunately this file isn't listed by php_ini_scanned_files().

EasyApache Php configuration on LAMP server with WHM

With EasyApache3 and Php5.4, the server was setup whereby the parameter values in the master php.ini file could be adjusted per account using a local php.ini file located in the account root. Having upgraded to EasyApache4 and Php 5.6 this configuration structure does not seem to be working, the local php.ini file shows as loaded in phpinfo.php but the parameters set do not change the master values eg:
post_max_size 20M
And ideas please?
With EA4 by default there's one server-wide php.ini located at /opt/cpanel/ea-php56/root/etc/php.ini but when the MultiPhp Editor is used I believe it creates ini files at /opt/cpanel/ea-php56/root/etc/php.d/local.ini, public_html/php.ini, and public_html/.user.ini where the hierarchy is:
php.ini > local.ini > .user.ini
So .user.ini over-rides local.ini which over-rides the server-wide php.ini
Although the MultiPhp editor creates it, public_html/php.ini seems not to be used as long as user_ini.filename is not set, since the default for user_ini.filename is .user.ini, and as long as there is not a directive in .htaccess
Ref: https://forums.cpanel.net/threads/ea4-php-ini-local-ini-behavior.559871/

custom php.ini / php_value : which takes precedence?

We could override the default php.ini settings using the
PHPINIDir /var/www/web1
directive in <VirtualHost> decription.
But I have seen php_value statements which is applied to all the sites in the httpd.conf files. For example :
php_value upload_max_filesize somevalue
Will the general settings like above override the custom php.ini settings?
Pardon me that I don't have an environment to test this out at present.
PHP configuration precedence order is as follows:
The php.ini
The conf.d directory. On some distros, there is a modularized conf.d directory. values specified in there override php.ini
The directive PHPINIDir /var/www/web1 replaces 1 and 2 with your custom php.ini
Apache virtual host configuration. e.g. "php_value error_reporting " overrides any php.ini
.htaccess files placed inside your webspace override the above configuration
Source code values specified in the source code override all other configuration
Some (security critical) options can only be set in higher level config files

Cannot Set date.timezone In php.ini file

I'm using php5.5 and getting this error whenever I used the date function in PHP:
Warning: phpinfo(): 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 /var/www/info.php on line 1
the loaded configuration file is here:
/etc/php5/apache2/php.ini
so I changed the date.timezone setting into this:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Jakarta
; http://php.net/date.default-latitude
;date.default_latitude = 31.7667
; http://php.net/date.default-longitude
;date.default_longitude = 35.2333
; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333
; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333
Then I restart the server:
sudo /etc/init.d/apache2 restart
but still getting this error, I tried to check the .ini file in the Additional ini file location but none of it is overriding the date.timezone setting
I've checked the php.ini file permission, but still not working
please guide me to solve this problem, thanks..
Try this:
date.timezone = "Asia/Jakarta"
Edit:
Let's locate the correct php.ini. Fire this within apache / nginx / whatever web server deamon your using (because the command line version may be different by the one used by it).
<?php
phpinfo();
?>
What's the .ini in the output? Still the same?
Edit2:
After the php.ini edit, just restart the webserver (apache or nginx) ...
finally solved my problem,
this is my Loaded Configuration File:
/etc/php5/apache2/php.ini
modified the date.timezone here but it's not working.
So, I check the "Scan this dir for additional .ini files " values in phpinfo() which point to:
/etc/php5/apache2/conf.d
then I search date.timezone from all files in that folder but found none.
this is my Additional .ini file parsed value in phpinfo():
/etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-xdebug.ini, /etc/php5/apache2/conf.d/30-mcrypt.ini
I modified /etc/php5/apache2/conf.d/20-xdebug.ini, and appended this line:
date.timezone = Asia/Jakarta
very weird but this solved my problem !!!
You should check out by locate php.in, if there somewhere has another one.
for me. there should have CLI for command line interface:
/etc/php5/cli/php.ini
/etc/php5/fpm/php.ini
change the /etc/php5/cli/php.ini
It works for me now.
Another solution for me after compiling PHP from source was to check php.ini was actually loading a config file. From command line
php --ini
returns
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Find it.
find -name "php.ini" #it was in /usr/local/php/php.ini
cp /usr/local/php/php.ini /usr/local/lib/php.ini
Restart php (in my case, /etc/init.d/php-fpm stop, /etc/init.d/php-fpm start) and it works fine. For some reason it got copied wrong.
Distro: Centos 7
Web Server: Nginx
Type: EC2 Instance
I've faced the same issue recently with PHP 5.6.4.
PHP 5.6.4 behaves strange
PHP 5.6.11 behaves normally as expected
When I put the date.timezone configuration option under [PHP] section in the configuration file it works fine for PHP 5.6.4. For example I've added the option at the very beginning of the php.ini file
[PHP]
date.timezone = "Europe/Stockholm"
But when I put the configuration option how this is shown in the example under [Date] section it does not work as expected, it looks like the option is ignored
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; this does not work for me for PHP 5.6.4 but works fine for PHP 5.6.11
date.timezone = "Europe/Stockholm"
When I add option to the 20-xdebug.ini like it is suggestion in the accepted answer https://stackoverflow.com/a/20731466/2111430 the option is accepted because this file has only [PHP] section. Out of curiosity I tried other included ini files and it looks like I can use any one.
One more time, the issue happened for me only with PHP 5.6.4. When I changed the option on the server with PHP 5.6.11 it behaved exactly like I expected.
In my case I had 2 date.timezone= records in the php.ini file and the last one was overriding the first one. removing one of them solved my problem.
Also don't forget you need to restart the web server process.
It worked for me when I noticed that the date.timezone entry in php.ini was commented out. After removing the semicolon the timezone was set correctly.
If you set the date.timezone value in php.ini but it does not work (ie. local value and master value are different) then you might need to update something like this in your apache configuration file:
<IfModule mod_php5.c>
php_value date.timezone "Europe/Paris"
</IfModule>
Check for the conflicting settings in you php.ini, I had same issue and in my case xdebug settings defined before date.timezone causing this thing: For more detail refer: PHP Xdebug issue - date.timezone & session.save_path undefined
some command line php application installer (like the symfony installer, or even when php scripts are run from cli), use the ini file inside the php-cli directory
/etc/php5/cli/php.ini
this solved my similar issue in dependency checking process while installing Symfony.
I fixed this in Mac OSX El Captain creating a folder structure: /Library/Server/Web/Config/php and then creating a php.ini inside this new php folder just with the date.timezone directive.
Iam using PHP 7.3.6.
open xampp/php/php.ini
go to line 1967
set line date.timezone=Asia/Jakarta
Restart Apache
Hope answer your question

phpinfo() difference between master and local value

I have a clean install of a CentOs with php 5.2.13.
In php.ini that is loaded and present in the header of phpinfo() I have
safe_mode=off
in the phpinfo() information I have
// local value - safe_mode: On
// master value - safe_mode: off
the php file has only a phpinfo() function.
I am still looking for vhost file to see if any directives are there overwriting this, but still then any sugggestions?
Look for "Additional ini files parsed" in phpinfo() output. This setting can also be changed in the Apache config (including .htaccess files).
"Master Value" (from php.ini) could be overridden with "Local Value" in httpd.conf, .htaccess or other Apache configuration with php_value directive.
I found the problem/solution to be in the extra config file that is added in the vhosts folder.
The file is named httpd.include and it has this line
php_admin_flag safe_mode on
PS. I really hate when other systems create files on the fly like this, especially with values they want.

Categories