Skip to content

Instantly share code, notes, and snippets.

@dcyou
Created June 16, 2020 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcyou/a1965c3c419245d3e745ffe11299985c to your computer and use it in GitHub Desktop.
Save dcyou/a1965c3c419245d3e745ffe11299985c to your computer and use it in GitHub Desktop.
Image upload settings to be run on a standard Laravel Homestead box

These will directly zap your php.ini file with the settings you want.

sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.1/fpm/php.ini

sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.1/fpm/php.ini

sudo sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.1/fpm/php.ini

Then, we need to set a proper client_max_body_size in the nginx.config file:

sudo nano /etc/nginx/nginx.conf

and add

client_max_body_size 100m;

within the http {} block.

To restart nginx and php:

sudo service nginx restart

sudo service php7.1-fpm restart

Ok, but here's the thing - the nginx.conf edit done above doesn't seem to take unfortunately. So, what you'll have to do is go to your site directly and edit the config file there. To do this, first cd to the proper folder:

cd /etc/nginx/sites-available/

From there, sudo nano your project's .app file and add

client_max_body_size 1000m

inside the server {} block. That should do you just fine.


I found this a little strange that while everything has been very elegant while using Homestead - I wasn't able to easily set my upload_max_filesize and post_max_size settings. Would have figured it would be configuarble in the yaml file. Anyways - just ssh into you box and run these commands. In the future you may need to may need to adjust the paths or whatever (if something like the PHP version changes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment