I've set magic_quotes_gpc = Off in php.ini,but I see it's still On in phpinfo();
First of all, you must be sure you modified the right php.ini file : there can be many files called php.ini -- and only one is "the right one".
You can see which php.ini file is used in the output of phpinfo() : there should be an entry called Configuration File (php.ini) Path that indicates the directory in which php.ini is looked for, and an entry called Loaded Configuration File that indicates the full path+name of the php.ini file that's used.
Then : don't forget to restart the webserver, so the modifications to php.ini are taken into account (Not sure that's necessary with IIS, but as it's required with Apache, I suppose it cannot hurt with IIS)
If that doesn't change a thing : what if you try to modify another directive : is the modification taken into account ?
As an alternative, you can disable it from your script too:
// disable magic_quotes_runtime
if (get_magic_quotes_runtime())
{
#set_magic_quotes_runtime(0);
}
You can check the php.ini file that was loaded via the php_ini_loaded_file function. Restart your web server.
On my installation the c:\php\php.ini file was named php ini. So phpmyinfo() was not loading it, despite the PATH environment variable including C:\php\. (Check this in a DOS prompt with SET PATH).
So rename it to php.ini.
It was difficult to spot in Windows Explorer.
Related
I have a Linux apache2 webserver with php version 7.0.22. It looks like the settings does not work at all :(
The .ini file is on the location: /etc/php/7.0/apache2/php.ini according to phpinfo(). When I look into the /etc/php/7.0/apache2 folder I see three files php.ini (the file that the settings are telling me that is in use),php.ini.save and php.ini.ucf-dist.
So I looked for allow_url_include and it was off, I change it to On and then allow_url_fopen = On. I did this to all of the .ini files saved them restarted apache2 and refreshed the phpinfo() page and nothing happened.
I tried to change another settings in all of the .ini files and did the same thing and nothing happened. I have permission 777 on all of the .ini files (not smart, but I'am just trying to get this thing working).
So is there maybe some other settings that I need to change so I can update the settings for real? Any idea?
UPDATE:
And this is in the Additional .ini files parsed field:
/etc/php/7.0/apache2/conf.d/10-mysqlnd.ini, /etc/php/7.0/apache2/conf.d/10-opcache.ini, /etc/php/7.0/apache2/conf.d/10-pdo.ini, /etc/php/7.0/apache2/conf.d/15-xml.ini, /etc/php/7.0/apache2/conf.d/20-calendar.ini, /etc/php/7.0/apache2/conf.d/20-ctype.ini, /etc/php/7.0/apache2/conf.d/20-dom.ini, /etc/php/7.0/apache2/conf.d/20-exif.ini, /etc/php/7.0/apache2/conf.d/20-fileinfo.ini, /etc/php/7.0/apache2/conf.d/20-ftp.ini, /etc/php/7.0/apache2/conf.d/20-gd.ini, /etc/php/7.0/apache2/conf.d/20-gettext.ini, /etc/php/7.0/apache2/conf.d/20-iconv.ini, /etc/php/7.0/apache2/conf.d/20-json.ini, /etc/php/7.0/apache2/conf.d/20-mbstring.ini, /etc/php/7.0/apache2/conf.d/20-mcrypt.ini, /etc/php/7.0/apache2/conf.d/20-mysqli.ini, /etc/php/7.0/apache2/conf.d/20-pdo_mysql.ini, /etc/php/7.0/apache2/conf.d/20-pdo_sqlite.ini, /etc/php/7.0/apache2/conf.d/20-phar.ini, /etc/php/7.0/apache2/conf.d/20-posix.ini, /etc/php/7.0/apache2/conf.d/20-readline.ini, /etc/php/7.0/apache2/conf.d/20-shmop.ini, /etc/php/7.0/apache2/conf.d/20-simplexml.ini, /etc/php/7.0/apache2/conf.d/20-sockets.ini, /etc/php/7.0/apache2/conf.d/20-sqlite3.ini, /etc/php/7.0/apache2/conf.d/20-sysvmsg.ini, /etc/php/7.0/apache2/conf.d/20-sysvsem.ini, /etc/php/7.0/apache2/conf.d/20-sysvshm.ini, /etc/php/7.0/apache2/conf.d/20-tokenizer.ini, /etc/php/7.0/apache2/conf.d/20-wddx.ini, /etc/php/7.0/apache2/conf.d/20-xmlreader.ini, /etc/php/7.0/apache2/conf.d/20-xmlwriter.ini, /etc/php/7.0/apache2/conf.d/20-xsl.ini, /etc/php/7.0/apache2/conf.d/20-zip.ini
They might have been overrewritten by .htaccess http://docs.php.net/manual/en/configuration.changes.php#configuration.changes.apache
or even in the php code http://php.net/manual/en/function.ini-set.php
You can try grep -r allow_url_include /etc/php/7.0 and see if that directive is defined anywhere else in your configuration path.
Also, make sure the setting in your ini file is not preceded by a semi-colon which is a comment. Depending on your distribution, this can be the case with defaults and it might read like this:
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
; allow_url_include = Off
So in addition to changing the setting to On, you'd need to remove the ;
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
allow_url_include = On
According to phpinfo() the following php.ini files are loaded:
Configuration File (php.ini) Path /etc/php5/cgi
Loaded Configuration File /var/www/vhosts/mywebsite.com/etc/php.ini
Scan this dir for additional .ini files /etc/php5/cgi/conf.d
I've made changes to php.ini found in /etc/php5/cgi - restarted server - NO Effect.
This file: /var/www/vhosts/mywebsite.com/etc/php.ini has the note:
DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY, SO ALL
YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
The server has these php.ini files
/etc/php5/cli/php.ini
/etc/php5/cgi/php.ini
/etc/php5/apache2/php.ini
/opt/psa/admin/conf/php.ini
/var/www/vhosts/mywebsite.com/etc/php.ini
Could you please tell me which php.ini file should I look for?
If you want to add something to php.ini (as xdebug properties, for example), then you should use /etc/php5/cgi/conf.d folder (create or edit one of that files).
As for php.ini located in cgi - seems right that you've done. However, there still exists a possibility, that you can edit these files, but they are overwritten by general configuration by your provider. I would advice to check it locally, if the same configuration would work.
EDIT: /opt/psa/admin/conf/php.ini looks like a possibility of this variant.
Also I would advice to edit apache's php.ini, but it looks more like a magic path.
I had a syntax error at 1. line!
It was :[php] instead of [php].
PHP ignored my config file because it couldn't see a php section
For me that fixed everything; Run php -c 'path-to-php.ini'. It will show you more information.
Debian-64 bit-6.0.3 ispcp
I have this on my server i want to increase upload_max_file i edited two php.ini files and reset the server but no changes, still same, should i move the php.ini into another directory or which php.ini should i edit, what is the proper directory of it ?
Additionly my purpose is to let users upload max 10mb pics on sql but it keeps saying max 2,048k even though i have edited php.ini files as 10M
With debian latest servers you have suhosin by default installed you might need to change the parameter in that, also check if you have set in .htaccess file, did you restarted the apache service after doing changes in php.ini, please check this link http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/ it might be helpful.
Thanks & Regards,
Alok Thaker
First, from the command line run :
php -i
Then search for :
Loaded Configuration File => /path/to/your/php.ini
Tip, for easier searching you can pipe grep like that : php -i | grep "php.ini"
Then you can edit your php.ini by changing the upload_max_file variable
You should be able to see which php.ini file it is using by adding a phpinfo file and calling it with domain/path/to/file.php
File contents should be:
<?php
phpinfo();
?>
When I see phpinfo(), it shows the path of php.ini file as: \apache2.2.22\bin\php.ini
But I want to load php.ini file from PHP executable folder. I tried to modify it from regedit but PHP is not available in regedit!
I am trying to create the php extension in c++ where I want to create extension for introduction.dll file. I copied this dll file in php/ext folder and set all the parameters in php.ini
But later I found that php.ini file loaded using phpinfo() was from apache!
Any idea?
Referring to http://php.net/manual/en/install.windows.apache2.php you can specify a "PHPIniDir" directive in your apache configuration (at least if you run it as a module).
How do I include a php.ini file in another php.ini file?
I don't think you can "include" .ini files from the main php.ini file.
One possible solution, though, might be to use this option on the configure line, when compiling PHP:
--with-config-file-scan-dir=PATH
Set the path where to scan for configuration files
If this option is used at compile-time, PHP will look for every .ini file in this directory, in addition to the "normal" php.ini file.
I suppose this is what is used by Ubuntu, for instance, which uses a different .ini file for each downloaded extension, instead of modifying php.ini.
The path to the php.ini file is being defined with this option, on the configure line:
--with-config-file-path=PATH
Set the path in which to look for php.ini [PREFIX/lib]
Still, it probably means you'll have to re-compile PHP -- which is not that hard, btw -- the hardest part being to get the dependencies you need.
And, here is a post on the internals# mailling-list that says the same thing as I do: config files and PHP_CONFIG_FILE_SCAN_DIR
One can also define the path in ~/.bashrc
export PHP_INI_SCAN_DIR=/usr/local/lib/php.d
I installed Memcached for php and wasn't sure how to make sure that its ini was included in my php.ini file, but as it turns out, it automatically is. You can validate what is being loaded by running php --ini.
php --ini
Configuration File (php.ini) Path: /opt/local/etc/php5
Loaded Configuration File: (none)
Scan for additional .ini files in: /opt/local/var/db/php5
Additional .ini files parsed: /opt/local/var/db/php5/memcached.ini
EDIT: My answer was mistaken. This only works in .conf files, which is not the question asked. Better testing showed that it won't work in php.ini files, where include statement is ignored.
I just tested it on DebianĀ 9 (Stretch) with PHP-FPM. From some .conf file, use this syntax:
include=/path/to/special-php.ini
or even
include=/path/to/special-dir-full-of-conf-files/*.conf
as it is used in
/etc/php/7.0/fpm/php-fpm.conf
include=/etc/php/7.0/fpm/pool.d/*.conf
By the way, this will be most useful if you split your settings by topic, and or if you want a set for development and another one for production. Then you could do it the Debian/Apache style like
/etc/php/conf-available/
/etc/php/conf-enabled/
with symliks from the second to the other and an include to that one.
It seems you cannot include one ini file into another so it gets referenced and loaded. But you can set php up to load several files by telling it which folders to look into.
When using a FastCGI setup (possibly in FPM, too, though I don't know that for sure) you can export environment variables from within the PHP wrapper.
There you could do:
export PHP_INI_SCAN_DIR=/etc/php5/cgi/conf.d:/var/www/mydomain.net/etc
/var/www/mydomain.net/etc is just an example. It's the folder where you put your additional ini files into. It seems this can be a : separated list.
Use a phpinfo.php (file called arbitrarily containing only <?php phpinfo();), open the corresponding URL in your browser and check the list of directories that are parsed and the list of files that get loaded in the top area of it.
/etc/php5/cgi/conf.d should always be included (I guess because it was compiled into the PHP executable) and possibly not really be needed.
You can't. Read online pages:
The configuration file
SUMMARY: The configuration file
(php.ini) is read when PHP starts up.
For the server module versions of PHP,
this happens only once when the web
server is started. For the CGI and CLI
version, it happens on every
invocation.
.user.ini files
SUMMARY: In addition to the main
php.ini file, PHP scans for INI files
in each directory, starting with the
directory of the requested PHP file,
and working its way up to the current
document root (as set in
$_SERVER['DOCUMENT_ROOT']). Only INI
settings with the modes PHP_INI_PERDIR
and PHP_INI_USER will be recognized in
.user.ini-style INI files.
You could try to simulate it making use of the ini_set function. But as the "man page" indicates, not all ini options can be changed using ini_set. It's definitely a useful function, though.