Reputation: 311
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.
Upvotes: 30
Views: 30514
Reputation: 11
Changes to Ubuntu php.ini will not take effect.
Steps to resolve this issue in Ubuntu 18.04 with Nginx 1.18.0.
php -v
sudo php-fpm7.4 -t
(change to the version you are running).sudo systemctl restart php7.4-fpm
(change to the version you are running).My results: PHP: syntax error, unexpected END_OF_LINE, expecting '=' in /etc/php/7.4/fpm/php.ini on line 2
In my case it was a "w" before the [PHP] which must have happened when I was using Ctrl w for searching with nano.
Upvotes: 1
Reputation: 2104
After reading great @Jekis's answer, I solved the same issue for Fedora distribution (it's the same thing, just different path):
After evaluting phpinfo();
output I found out that other .ini
files are stored in: /etc/php.d
directory
In /etc/php.d
I created a new file - 40-user.ini
. I added upload_max_filesize
and other settings that I wanted to change
Then I restarted apache (httpd)
And then changes were picked up.
Upvotes: 1
Reputation: 3915
I had a very strange experience which caused the same symptom like this.
The point is that my php.ini file contained an old-style comment (starting with hashmark) which, as of php 7.0, is not a comment any more. The incorrect comment confused the ini-parser.
The solution was to replace all # comment symbols with semicolon (;) which is the only standard way for writing comments.
For further details, please read my comment here:
https://serverfault.com/a/1012262/494670
Upvotes: 1
Reputation: 103
I had exactly the same problem and solved it using these steps:
When running the following command on my server
php --ini
I got the following path of my php.ini
Loaded Configuration File: /etc/php/7.0/cli/php.ini
I kept on making changes in this php.ini file, but none of the changes took effect. I then created a file called info.php in my /var/www/html directory and added the following code
<?php
phpinfo();
?>
Then I opened the file in my browser http://example.com/info.php, where I saw that the actual loaded php.ini file was in a different directory
Loaded Configuration File /etc/php/7.0/apache2/php.ini
When I made changes to the php.ini file inside of this directory, all the changes took effect. In summary make sure that you run the phpinfo(); function to make sure of the actual php.ini file which php uses.
Upvotes: 3
Reputation: 279
Maybe you find 2 directories for php.ini files.
If you search where php.ini is using cli like php --ini
maybe it show you /etc/php/7.1/cli/php.ini
, but thereis another folder to php-fpm
found in /etc/php/7.1/fpm/php.ini
and you need to create your new ini file under conf.d
folder like /etc/php/7.1/fpm/conf.d/30-user.ini
and if you need a ini file to cli command line you need to put your ini file under /etc/php/7.1/cli/conf.d/30-user.ini
Upvotes: 1
Reputation: 4685
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:
phpinfo();
phpinfo()
output/etc/php5/apache2/conf.d
/etc/php5/apache2/conf.d/user.ini
)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
Upvotes: 88
Reputation: 4512
If you php.ini resides somewhere like /etc/php/7.*/fpm/php.ini
- then modify it as needed and instead of sudo service apache2 restart
go with service php7.1-fpm restart
Upvotes: 18
Reputation: 3349
service apache2 reload
needs to be run as root, even if it does not appear to fail without root. Running sudo service apache2 reload
works. This is in Ubuntu 14.04.
Upvotes: 1
Reputation: 28235
You might also need to increase the maximum size of a post:
post_max_size=10M
Try that.
Upvotes: 3
Reputation: 1430
Have you restarted apache2?
sudo service apache2 restart
The new php.ini configuration is only applied when apache starts.
Upvotes: 6