How to Increase Amazon EC2 Ubuntu Instance Maximum File Upload Size

Every now and then, as a data scientist or software engineer, you may find yourself needing to upload large files to your Amazon EC2 Ubuntu instance. However, you might encounter a hurdle - the maximum file upload size. In this blog post, we’ll walk you through how to increase this limit.

How to Increase Amazon EC2 Ubuntu Instance Maximum File Upload Size

Every now and then, as a data scientist or software engineer, you may find yourself needing to upload large files to your Amazon EC2 Ubuntu instance. However, you might encounter a hurdle - the maximum file upload size. In this blog post, we’ll walk you through how to increase this limit.

Understanding the Limit

Before we delve into how to increase the limit, it’s crucial to understand what we are dealing with. By default, PHP sets a limit on the maximum file upload size to prevent potential abuse and ensure the system’s performance. This limit is typically set at 2MB. If you find yourself needing to upload larger files, you will need to adjust this limit manually.

Increase Maximum File Upload Size

Let’s dive into the steps you need to follow to increase the maximum file upload size on your Amazon EC2 Ubuntu instance:

1. Access Your Instance

First, you need to access your EC2 Ubuntu instance. You can do this using SSH:

ssh -i /path/my-key-pair.pem ubuntu@ec2-198-51-100-1.compute-1.amazonaws.com

Ensure that you replace /path/my-key-pair.pem with the path to your key pair and ubuntu@ec2-198-51-100-1.compute-1.amazonaws.com with the public DNS name of your instance.

2. Edit PHP Configuration File

Once you’re in, navigate to the php.ini file. This is the file where PHP’s settings are stored. The location of this file depends on your PHP version. For PHP7.4, it can be found at /etc/php/7.4/apache2/php.ini.

Use the nano command to open the file:

sudo nano /etc/php/7.4/apache2/php.ini

3. Adjust Settings

In the php.ini file, look for the following settings:

  • upload_max_filesize
  • post_max_size

These settings control the maximum upload file size. Increase these values to your preferred limit. For example:

upload_max_filesize = 100M
post_max_size = 100M

This will set the maximum file upload size to 100MB.

4. Save and Exit

After adjusting the settings, save and exit the file by pressing CTRL+X, then Y to confirm the changes, and finally ENTER to exit.

5. Restart Apache

For the changes to take effect, you need to restart your Apache server. This can be done using the following command:

sudo service apache2 restart

Now, you should be able to upload larger files to your EC2 Ubuntu instance without hitting the limit.

Conclusion

Increasing the maximum file upload size on an Amazon EC2 Ubuntu instance is a straightforward process that can be done in a few steps. Remember, it’s important to set a limit that is suitable for your specific needs to maintain system performance. Happy uploading!

If you found this guide helpful, please share it with your network! Stay tuned for more handy “How to” and “What is” articles answering your data science and software engineering questions.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.