VestaCP is an open core Web hosting control panel similar to cPanel. It’s a popular replacement for cPanel when you don’t want to pay cPanel’s monthly fee. I actually use it to host several websites on Vultr but perform most of the system management from the command line.
This short article shows how to edit the php.ini file to fix the upload_max_filesize exceeded error that’s usually encountered when one attempts to upload a file whose size exceeds that allowed by PHP. That error should be very familiar to users of WordPress, because that was what I was using when I encountered the error shown in the image below.
Though the error message tells you what directive to modify and the file to find it in, it doesn’t tell you what directory the file is in. I can tell you that if you’re using CentOS 7, the same Linux distribution that powers my server, you’ll find the file under the /etc directory.
By default, the value of that directive is 2M, that is, 2 MB. Since the file I was trying to upload was 3.3 MB, I only needed to give the directive a higher value and restart Apache. How I went about it is shown in the following code block. By this time you know that I first had to log into the server by SSH. I manage the server from the command line using the root account and not sudo, so sudo is not used in the following commands:
# To make it easier to recover from a misconfiguration, make a copy of the file
cp /etc/php.ini /etc/php.ini.copy
Then open the original file using the nano text editor
# Search for the upload_max_filesize directive. It and the default value are shown next
upload_max_filesize = 2M
# Change it to a value that exceeds the size of files you were trying to upload
upload_max_filesize = 6M
# Save and close the file, then restart Apache using the following command
After Apache has been restarted, you may try uploading the file again. That fixed it for me. Did not need to modify any other directive.