I am using PHP-FPM with Apache and try to set custom php.ini settings inside a [PATH=...] directive. For example:
[PATH=/var/www/mysite]
memory_limit = 512M
I placed the file into /etc/php/7.4/fpm/conf.d/99-mysite.ini
According to phpinfo() the file is being parsed and everything works if I leave out the [PATH]-part or use a [HOST=...] directive. Solely [PATH=...] is not being activated. Triple checked the path is correct.
My test file is saved in /var/www/mysite/htdocs/php.php so I also tried [PATH=/var/www/mysite/htdocs] in case this doesn't work recursivly but still it has no effect at all.
Any ideas on why [PATH=] doesn't seem to work at all?
Related
I'm having the same problem this guy says he had: PHP still won't allow file uploads larger than 2 MB, although apparently he solved it.
I, however, cannot find a solution. I've edited the php.ini file to the following values:
upload_max_filesize = 20M
post_max_size = 20M
I've even tried raising them to 200M, but it still limits it at 2M, according to phpinfo().
Here are some of the variables per php.ini (name, local value, master value):
file_uploads On On
max_file_uploads 20 20
upload_max_filesize 2M 2M
I've restarted everything. The original value when I checked php.ini for upload_max_filesize was 10M anyway. It will upload smaller files, just nothing above 2MB.
Assicure that you have saved your php.ini.
Restart your webserver for example the service of Apache2 if you use it
Print again a page with phpinfo() and assicure that value has changed if not you haven't wrong file to edit.
Assure that html has attribute MAX_FILE_SIZE
Another way is to change in PHP this setting like:
ini_set('post_max_size', '20M');
ini_set('upload_max_filesize', '20M');
It is possible the file size limit is being overwritten in an .htaccess file, or in your PHP application, through ini_set() calls.
I will also remind you that when you change those values in php.ini, you probably need to restart Apache.
If this isn't something your webhost will let you do, you could always use ini_set() calls yourself, in your script. For example, place this near the top of your script:
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
I've had this issue before. If you are running certain versions of web servers, such as running php-fpm with nginx, your php.ini file won't be in the place you expect it. For example, I believe php-fpm doesn't follow the normal php.ini, but rather a www.conf located in it's conf.d directory.
Anyway, check and make sure that your configuration isn't being overridden by a separate php.ini or other config file. If you cannot fix it in this way, you may have luck doing what Richard and Alessandro suggest.
I ran into a similar problem. the setting post_max_size was set to 3M.
I fixed it in the php.ini file from the /wamp/apache/bin folder.
I Hope it helps.
Always ensure that it is the correct php.ini file that you are updating its values.
I spent 2 weeks reconfiguring IIS7 only to realize that there were 2 php.ini files on was in the C:\Program Files (x86)\PHP\v5.4 and the other was in C:\php... however the one that worked was: C:\Program Files (x86)\PHP\v5.4
To ensure that you are on the correct path to the php.ini file
create a phpinfo.php file (structure of file below)
phpinfo();
call the file in the browser like: http://servername/websitename/phpinfo.php
Check the lline shown in pic below to verify that you are indeed editing the correct php.ini file.
Hope this helps cause it helped me. PS. Don't forget to make the changes mentioned above to increase the upload size limit
I also had the same problem and also I did the same changes in the ini.php file
upload_max_filesize = 200M
post_max_size = 200M
But it doesn't solve my problem. So, I went to wamp server in the taskbar (where we can see the green 'W' sign) and left clicked on it
PHP > PHP SETTINGS > upload_max_filesize = 256M (as the changes i made in ini.php were actually not made).
Then it WORKED.
Flogvit pretty much answered my question. WAMP was using a different php.ini file than was listed in the WAMP PHP settings option. I looked at the wamp configuration file and it was just "php.ini." I changed it to the full path of the php.ini file I wanted to use (there was another in the IIS folder), I restarted it and nothing happened. However, after restarting the computer, it now works. For some reason ini_set() doesn't work, however the solution is this:
1) open wampmanager.conf
2) change "phpConfFile = " from php.ini to the full path of the php.ini file you'd like to use, putting it in double quotes.
3) restart the computer that WAMP is on.
Thanks again for the help. That was a pretty weird problem and I don't know why I couldn't just restart WAMP (which runs all the servers, including the Apache server). I'm guessing there was something running outside of WAMP that was being run by WAMP, which is a bit of a mystery to me.
That's because you are editing the wrong config file. Check where your config file is being loaded from and edit that one instead. You might be editing the one located at /etc/php/[version]/cli/php.ini.
In my case, my loaded config file is at /etc/php/7.3/apache2/php.ini
I am no longer trying to change upload_max_filesize with ini_set. I have seen those answers.
I found what I think is the real php.ini using the path from phpinfo(). I have edited the file changing the value from 2M to 10M.
In spite of this, ini_get('upload_max_filesize') still shows 2M and my upload is still failing because the file is larger than this.
What am I missing?
There are four things to check if experiencing an issue like this:
Ensure that the correct php.ini is being loaded by using phpinfo()
Ensure that no extra ini files are being loaded via the --with-config-file-scan-dir option
That you haven't used ini_set() anywhere in your code to override the setting
That you restarted your web server after making any changes to ini files
Less commonly, you can also configure PHP to be run with the -d or --define directive which can set this setting at runtime. This would also be shown in the phpinfo() results.
I've tried going through Network Solutions tech support but didn't get it resolved ("You need to talk to Signature Support, which is $50").
I'm running some sites off of a Net Sol VPS account and need to change the upload_max_filesize setting (which is apparently set to a paltry 2MB by default) for the php server. I've added:
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 6000
to the /httpdocs/cgi-bin/php.ini file (per NS's instructions), and then restarted apache, but when I run a phpinfo on that domain, the settings are not applied. It still says "2M" for the upload max.
I also tried adding this to the server root at /cgi-bin/php.ini as well, to no effect.
There is no /cgi-bin/.php/php.coalesced.ini file that I can see.
Any ideas? I'm losing my mind with this.
First thought is to check your phpinfo() output for the value listed in the "Loaded Configuration File" setting and make sure that it matches the file you've been editing.
You can't just litter PHP.ini files around and expect PHP to load them. If it's not been told to look for one in that cgi-bin directory, the file will just get ignored.
Check the phpinfo() output - the first section will tell you exactly what .ini files were located/parsed, and their location. e.g. on my home server:
Configuration File (php.ini) Path /etc/php5/apache2
Loaded Configuration File /etc/php5/apache2/php.ini
Scan this dir for additional .ini files /etc/php5/apache2/conf.d
Additional .ini files parsed /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/conf.d/gmp.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini
if your cgi-bin .ini file isn't listed, then PHP is NOT looking in that directory.
I know this is old but figured I'd share my experience. I tried adding a php.ini file to the /cgi-bin folder as I read was suggested, that didn't appear to work. My solution was to SSH onto the server and make a change to the real php.ini file and then restarting the server.
I am trying to change the max_memory parameter so I went into my php.ini and set max_memory = 500M For some reason, when I use phpinfo(), that setting still displays 128M (the default setting). I read that some hosts restrict max_memory. Is there a way to change this value manually, or override this option in a config file, or do I have to recompile php?
If you can recompile PHP, then you, obviously, have full control of the web server.
I would guess, as written in the comments, you:
Did not restart the Apache (or not the right Apache)
(as you found) You are editing the wrong ini file.
Your server simply don't have 500MB free memory
a few other things to check:
the report from phpinfo states that it is using the php.ini file that you're editing, not some more "specific" .ini file somewhere else
you haven't overridden the memory_limit variable through an apache .htaccess file or using ini_set in a PHP script somewhere
if you're in a shared environment, as Itay suggests, you may not have more than 128M available to your account, and you probably don't have access to reset apache either.
if that's the case, try making the value smaller to see if the changes you're making take effect. If they are, and you can't increase it above 128M, time to upgrade your hosting account.. otherwise, try making the change through .htaccess or ini_set in your script because those methods don't require an apache restart.
if you still can't get it to work, contact the host and ask them to make you a local copy of the global php.ini file for your account.
I have a wordpress blog. I made a custom page-template that allows users to upload files to my server. Just a simple php script which connects to my server with a form to select a file, blabla.. you know!
However the upload-feature doesn't make any sense with a max_upload_filesize of 20mb.
Now i want to change that. According to my hosting-provider it's REALLY EASY, but i think for normal people without experience in that field it's not. Anyway...
they told me i should create a .htaccess file where my upload-script is housed. So that's actually in my wordpess theme folder.
in the .htaccess file i should place "suPHP_ConfigPath" and the path to this directory.
so in my case this would be: (at least i think that's the path)
suPHP_ConfigPath /clientdata/n5200-2-dynamic/a/l/mydomain.com/www/wp-content/themes/mytheme/
Moreover i should create a php.ini file in the same directory that says:
upload_max_filesize = 500M ;
post_max_size = 500M ;
I did all of that and even created a info.php file in the same directory to check if the thing worked. However the php_info tells me still that the upload-size is set to 20mb.
Did I get anything wrong here? Do you guys have an idea what I'm doing wrong?
Does the php_info in that case even tell me the truth and the script should normally work? or should the php_info tell me that the size is set to the value I changed it to?
First of all, create a test.php file in the theme folder and put this into it;
<?php
phpinfo();
?>
Run http://mydomain.com/.../test.php in a browser and find 'Configuration File Path' on the page. If it does not match the one you mentioned in .htaccess, then the .htaccess is not working. Verify the name of .htaccess file and first make sure .htaccess is actually working first. If not, call your hosting support to help you out.
If the configuration path is showing as the one you specified in .htaccess, then
try putting these lines in the .htaccess file also and see if it works.
php_value upload_max_filesize "500000"
php_value post_max_size "500000"
If htaccess is working, also trying changing the value of the numbers in php.ini to 500000, instead of 500M.
I Hope your problem gets solved soon.
php_value upload_max_filesize 500000000
php_value post_max_size 500000000
instead of that very strange thing you put there
However, it would work only with Apache mod_php