How to change default WordPress 2MB Upload on Self Hosted VPS php.ini

WordPress comes with 2MB upload size limit by default which needs to be increased if you want to upload files larger than that amount. The limit is set by your hosts php.ini file.

Login to your VPS via SSH and change your upload_max_filesize to something bigger such as 10Mb. 

You can customize this script to suit your needs:

#!/bin/bash -ex
#change the path an create a variable or hardcode it below.
#phpfilepath=/etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 200M/' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/' /etc/php.ini

Restart your Apache2 or Nginx services.

Check php info or login to WordPress and test it.

Leave a comment

Your email address will not be published. Required fields are marked *