Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changes to upload_max_filesize in Ubuntu php.ini will not take effect

Tags:

php

I have been trying for two days to increase the max filesize for file uploads via php to 10M from the default 2M. I change the php.ini file that is referenced by phpinfo to no avail.

I saw a few articles stating that there is a syntax error around line 109 of the php.ini file, but I don't know what the syntax error is or how to correct it. users stated that because the upload_max_filesize is AFTER this error in the config file it is being ignored. Please help.

like image 375
Steven Benavides Avatar asked Jan 14 '13 21:01

Steven Benavides


People also ask

Do I need to restart after changing PHP INI?

PHP-FPM you need to restart to avoid configuration inconsistency. Some workers will lay dormant and keep the old configuration, while new workers will get the new configuration.

Where is upload_max_filesize in PHP INI?

The upload_max_filesize directive itself is located in the php. ini file, which is the default server configuration file for applications that require PHP. Those two things – upload_max_filesize and php.

What is upload_max_filesize PHP?

The upload_max_filesize directive is a PHP variable set in the system and local php. ini files and user. ini files. These determine the PHP interpreter's baseline configuration. As you might expect, upload_max_filesize limits the maximum allowable size of an uploaded file.


1 Answers

This message helped me:

The newest php version installed on server does not allow global settings (such as execution time, max upload filesize, max post file size, etc.) to be changed.

Folow these steps to resolve the issue:

  1. Eval phpinfo();
  2. Search for 'Scan this dir for additional .ini files' text in phpinfo() output
  3. It will be something like this /etc/php5/apache2/conf.d
  4. Create your user.ini file inside the dir. (/etc/php5/apache2/conf.d/user.ini)
  5. Use this ini file for custom settings.
  6. Restart the server

File /etc/php5/apache2/conf.d/user.ini

post_max_size = 90M upload_max_filesize = 50M 

Update 2018.06

If you are using nginx + php-fpm your path will be something like this (use your php version in path). Create file using:

nano /etc/php/7.0/fpm/conf.d/user.ini 

There are a lot of other .ini files in the conf.d directory. If you want your config to be the last included - use prefix.

For example: 30-user.ini.

After file creation don't forget to restart fpm:

sudo service php7.0-fpm restart 
like image 192
Jekis Avatar answered Sep 29 '22 01:09

Jekis