Good day to you,
I am trying to upload larger files than 2M in my wordpress.
It's created from the one click deployment solution in Compute Engine.
In order to achieve it, I mostly tried to different things.
First, I wasn't really fan, updating the file /var/www/html/wp-config.php and adding these lines :
@ini_set( 'upload_max_filesize' , '128M' );
@ini_set( 'post_max_size', '128M');
@ini_set( 'memory_limit', '256M' );
@ini_set( 'max_execution_time', '300' );
@ini_set( 'max_input_time', '300' );
It didn't worked.
On a local version (on premise) of this wordpress, I did it modifying php.ini and it worked.
On GCP, I tried this :
$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/' /etc/php/8.1/apache2/php.ini
$ sudo sed -i 's/post_max_size = 8M/post_max_size = 100M/' /etc/php/8.1/apache2/php.ini
$ grep -n "upload_max_filesize\|post_max_size" /etc/php/8.1/apache2/php.ini
703:post_max_size = 100M
855:upload_max_filesize = 100M
$ sudo service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-10-11 09:00:38 UTC; 7min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 385 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 559 (apache2)
Tasks: 10 (limit: 2353)
Memory: 32.2M
CPU: 242ms
CGroup: /system.slice/apache2.service
├─559 /usr/sbin/apache2 -k start
├─587 /usr/sbin/apache2 -k start
├─588 /usr/sbin/apache2 -k start
├─589 /usr/sbin/apache2 -k start
├─590 /usr/sbin/apache2 -k start
├─591 /usr/sbin/apache2 -k start
├─691 /usr/sbin/apache2 -k start
├─699 /usr/sbin/apache2 -k start
├─704 /usr/sbin/apache2 -k start
└─705 /usr/sbin/apache2 -k start
Oct 11 09:00:30 foxy-pleasure-review-vm systemd[1]: Starting The Apache HTTP Server...
Oct 11 09:00:38 foxy-pleasure-review-vm systemd[1]: Started The Apache HTTP Server.
$ sudo service apache2 stop
$ sudo service apache2 start
After that, I even tried to restart the VM, I still have in the http://mydns//wp-admin/media-new.php the "Maximum upload file size: 2 MB." message.
I can't upload more.
What am I missing ?
Thanks for your help 🙏
Solved! Go to Solution.
So in short :
$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/' /etc/php/8.1/fpm/php.ini && sudo sed -i 's/post_max_size = 8M/post_max_size = 100M/' /etc/php/8.1/fpm/php.ini
$ sudo service php8.1-fpm restart && sudo service apache2 restart
Hi @PapaRenard,
Welcome to the Google Cloud Community!
Can you also try editing the upload_max_filesize
and post_max_size
in the php.ini
file inside the CLI or FPM directory [1]?
These files are typically located at /etc/php/<php version>/fpm/php.ini
and /etc/php/<php version>/cli/php.ini
, but the exact location may vary depending on your system configuration.
You can view the following threads for more information on how to do this:
Make sure to restart your Apache service after you make the edits.
I hope this answers your question. Thank you.
[2]. https://wordpress.org/support/topic/how-to-increase-maximum-upload-file-size-from-2mb/
Thank for your welcome and your proposition.
to be honest, I tried this :
sudo sed -i 's/upload_max_filesize = 100M/upload_max_filesize = 2M/' /etc/php/8.1/{cgi,cli,fpm,apache2}/php.ini && sudo sed -i 's/post_max_size = 100M/post_max_size = 8M/' /etc/php/8.1/{cgi,cli,fpm,apache2}/php.ini
Because after having it not working on apache2, I tried every other php.ini file that I could find using locate command.
So yes, I made that.
Unfortunately, it's not enough.
I've followed several tutorial before going here but without luck to find something working.
So actually, after the sed, I have this
paparenard_reviews@foxy-pleasure-review-vm:~$ grep "post_max_size\|upload_max_filesize" /etc/php/8.1/{cgi,cli,fpm,apache2}/php.ini
/etc/php/8.1/cgi/php.ini:post_max_size = 100M
/etc/php/8.1/cgi/php.ini:upload_max_filesize = 100M
/etc/php/8.1/cli/php.ini:post_max_size = 100M
/etc/php/8.1/cli/php.ini:upload_max_filesize = 100M
/etc/php/8.1/fpm/php.ini:post_max_size = 100M
/etc/php/8.1/fpm/php.ini:upload_max_filesize = 100M
/etc/php/8.1/apache2/php.ini:post_max_size = 100M
/etc/php/8.1/apache2/php.ini:upload_max_filesize = 100M
Checking for a new pid after restart (but I could have reload instead of restart)
paparenard_reviews@foxy-pleasure-review-vm:~$ sudo service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-10-11 09:08:44 UTC; 1 day 22h ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 908 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Process: 65851 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Main PID: 912 (apache2)
Tasks: 11 (limit: 2353)
Memory: 69.8M
CPU: 1min 45.651s
CGroup: /system.slice/apache2.service
├─ 912 /usr/sbin/apache2 -k start
├─72847 /usr/sbin/apache2 -k start
├─72863 /usr/sbin/apache2 -k start
├─72886 /usr/sbin/apache2 -k start
├─72925 /usr/sbin/apache2 -k start
├─72928 /usr/sbin/apache2 -k start
├─72929 /usr/sbin/apache2 -k start
├─72936 /usr/sbin/apache2 -k start
├─73044 /usr/sbin/apache2 -k start
├─73046 /usr/sbin/apache2 -k start
└─73048 /usr/sbin/apache2 -k start
Oct 11 09:08:44 foxy-pleasure-review-vm systemd[1]: Starting The Apache HTTP Server...
Oct 11 09:08:44 foxy-pleasure-review-vm systemd[1]: Started The Apache HTTP Server.
Oct 12 00:00:03 foxy-pleasure-review-vm systemd[1]: Reloading The Apache HTTP Server.
Oct 12 00:00:04 foxy-pleasure-review-vm systemd[1]: Reloaded The Apache HTTP Server.
Oct 13 00:00:09 foxy-pleasure-review-vm systemd[1]: Reloading The Apache HTTP Server.
Oct 13 00:00:10 foxy-pleasure-review-vm systemd[1]: Reloaded The Apache HTTP Server.
paparenard_reviews@foxy-pleasure-review-vm:~$ sudo service apache2 restart
paparenard_reviews@foxy-pleasure-review-vm:~$ sudo service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-10-13 07:12:37 UTC; 3s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 73260 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 73264 (apache2)
Tasks: 6 (limit: 2353)
Memory: 15.5M
CPU: 119ms
CGroup: /system.slice/apache2.service
├─73264 /usr/sbin/apache2 -k start
├─73265 /usr/sbin/apache2 -k start
├─73266 /usr/sbin/apache2 -k start
├─73267 /usr/sbin/apache2 -k start
├─73268 /usr/sbin/apache2 -k start
└─73269 /usr/sbin/apache2 -k start
Oct 13 07:12:37 foxy-pleasure-review-vm systemd[1]: Starting The Apache HTTP Server...
Oct 13 07:12:37 foxy-pleasure-review-vm systemd[1]: Started The Apache HTTP Server.
But in the media gallery (or while I'm dragging drop in a new post), I still have a 2Mb limit for upload
I found a partially working workaround using "Big File Uploads"
Partial because it allows me to upload in gallery but not directly from post.
It's better than nothing but it's driving me mad. Using a plugin for a configuration issue... And not knowing why it doesn't work... 😡
I mean, I only have php8.1 installed on this VM so it should be something I have to make in the apache2 directory because it's what apache is using for php interpretation.
paparenard_reviews@foxy-pleasure-review-vm:~$ ls /etc/php/8.1/
apache2/ cgi/ cli/ fpm/ mods-available/
So I tried to create a php_info.php file at /var/www/html/ in order to check values given by apache2.
Still not what I want
I even tried to create a
$ sudo cat /etc/php/8.1/apache2/conf.d/upload.ini
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
And in despair, I tried to modify this also
grep "post_max_size\|upload_max_filesize" /usr/lib/php/8.1/php.*
/usr/lib/php/8.1/php.ini-development:post_max_size = 100M
/usr/lib/php/8.1/php.ini-development:upload_max_filesize = 100M
/usr/lib/php/8.1/php.ini-production:post_max_size = 100M
/usr/lib/php/8.1/php.ini-production:upload_max_filesize = 100M
/usr/lib/php/8.1/php.ini-production.cli:post_max_size = 100M
/usr/lib/php/8.1/php.ini-production.cli:upload_max_filesize = 100M
It's just as if apache2 won't care of it's own configuration...
(Text Removed by Staff)
I had to restart php8.1-fpm 🤣
Chat GPT helped me on this one...
But thanks @lawrencenelson for your help
So in short :
$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/' /etc/php/8.1/fpm/php.ini && sudo sed -i 's/post_max_size = 8M/post_max_size = 100M/' /etc/php/8.1/fpm/php.ini
$ sudo service php8.1-fpm restart && sudo service apache2 restart
You uploaded this to the php.ini file?
I am facing a similar issue with a plugin that uses table to look up price and discount. I have a very big csv file. The issues is that the plugin tries to upload the file all at once and process it as array at the same time. No option to upload in batches or multiple files. So every product the tables just keep growing larger and larger.
Any help would be greatly apperciated,
Thomas