How To Increase File Upload Size In Apache

Last updated on November 9th, 2022 at 06:14 am

By default, Apache has a file upload size limit of 2MB. If you need to upload larger files such as multimedia video, audio and images, you need to increase file upload size in Apache. Here’s how to set max file upload size and increase file upload size in Apache.

How To Increase File Upload Size In Apache

Here are the steps to increase file upload size in Apache. We will use the server directive LimitRequestBody to define the file size limit. After you increase file upload size limit in Apache, you may want to use a reporting software to monitor the key metrics about your website/application such as signups, traffic, sales, revenue, etc. using dashboards & charts, to ensure everything is working well.

1. Open .htaccess file

You will typically find .htaccess file in your site’s root folder (e.g /var/www/html/). You can open it using vi editor

$ sudo vim /var/www/html/.htaccess

2. Increase File Upload Size Limit

Let’s say your uploads are stored at /var/www/example.com/wp-uploads and you want to limit the file upload size to 5MB. Add the following line to your .htaccess file.

<Directory "/var/www/example.com/wp-uploads">
LimitRequestBody 5242880
</Directory>

In the above configuration, when we use LimitRequestBody directive, we need to specify the file size in bytes. You can also add the above line to your Apache server configuration file httpd.conf.

Bonus Read:How to Password Protect Directory in Apache

3. Restart Apache Server

Restart Apache Server to apply changes

$ sudo service apache2 restart

That’s it! Now you can upload larger files in Apache/Wordpress. In case the uploaded file is larger than file size limit, server will show an error, and you can once again, increase file upload size in Apache. BTW, if you allow image uploads to your website, you might want to prevent image hotlinking in Apache.

You can also use the same trick to reduce or limit the file upload size in Apache, so that malicious attackers don’t bring down your server by uploading really large files.

By the way, if you want to create dashboards & charts to monitor your business or website, you can try Ubiq. We offer a 14-day free trial.