Last updated on December 31st, 2025 at 04:48 am
Today’s websites and blogs need to allow users to upload various kinds of files such as images, videos and more. These files can be quite big in size. By default, Apache server allows you to upload up to 2Mb file size. For bigger files, it simply returns an error without uploading anything. In such cases, you will need to increase file upload size in Apache server. In this article, we will learn how to do this.
Why Increase File Upload Size
Here are some of the most common reasons to increase file upload size in Apache server.
- User requirement – These days, people expect sites and apps to accept large file uploads like high resolution images, videos, large documents, etc. If you do not accommodate them, then people will stop using your service. So you need to provide such a web interface for this purpose.
- User experience – By default, Apache allows upload of only 2Mb. This is too low a limit. As a result, users often get ‘file too large’ error message. It spoils their user experience and stops them from using your site any further. So it is important to increase this limit, at least to some extent.
- Application Requirement – These days, ecommerce sites, social media tools, video editing sites, project management tools, and even document processing sites need to be able to handle large files. Sometimes, these files are in the form of plugins and updates and not user uploads.
Once you have ascertained the upload requirements of your site or service, it is important to increase the limit as per your requirement.
How to Increase File Upload Size in Apache Server
There are several ways to increase max upload file size in Apache server. Let us look at them one by one.
1. Apache Configuration
In this solution, we will modify Apache configuration file and add directives related to max upload file size. If you do not have access to Apache configuration file, you can skip to the next solution.
Open Apache configuration in a text editor.
sudo vi /etc/httpd/httpd.conf
OR
sudo vi /etc/apache2/apache2.conf
Add or modify the LimitRequestBody directive to set max file upload size to 64Mb.
LimitRequestBody 67108864
We have set it to slightly more than 64 Mb to accommodate request headers.
Save and close the file. Restart Apache server to apply changes.
sudo systemctl restart apache2 #ubuntu/debian
OR
sudo systemctl restart httpd #rhel/centos
2. Using php.ini
If you do not have access to Apache configuration file, then open PHP configuration file, php.ini in text editor. Location of php.ini varies according to the Operating system as well as PHP version.
To determine the location of php.ini file, create an php file with the following content.
<?php phpinfo(); ?>
Save and close the file. Open the file via its URL in web browser. It will display a table of PHP configuration variables. Look for the value of ‘Loaded Configuration File’ entry.
Then open the php.ini file in text editor. Modify the following PHP directives to set max file upload size to 64Mb.
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
Save and close the file. Let us look at the above directives in detail. upload_max_filesize specifies the max file upload size. post_max_size specifies the maximum size of request body, including file as well as request headers. So it should be greater than or equal to upload_max_filesize value. Memory_limit specifies the max amount of memory to be allocated for file processing. max_execution_time and max_input_time are the timeout values to be specified to avoid time outs in case of large file uploads.
Restart Apache server to apply changes.
sudo systemctl restart apache2 #ubuntu/debian
OR
sudo systemctl restart httpd #rhel/centos
3. Using .htaccess File
If you do not have access to Apache configuration file or php.ini file, then you can add or modify the following headers in .htaccess file. Please ensure you have enabled mod_rewrite for this method.
php_value upload_max_filesize = 64M
php_value post_max_size = 64M
php_value memory_limit = 256M
php_value max_execution_time = 300
php_value max_input_time = 300
Save and close the file. These are the same directives that we set in the previous solution using php.ini file. You can refer to their meaning there.
This is a very powerful method due to several reasons. First, it works even if you do not have access to Apache configuration file or php.ini file. Second, depending on location of .htaccess file, you can use it to increase file upload limit for specific directory.
Restart Apache server to apply changes.
sudo systemctl restart apache2 #ubuntu/debian
OR
sudo systemctl restart httpd #rhel/centos
Key Considerations
Here are several points to keep in mind while increasing file upload limit:
- Upstream updates – Generally, Apache server is used to run PHP based applications, blogs and websites. Please note, both Apache as well as PHP have specific file upload limits built into them. If you have increased the file upload size limit in Apache, you need to also make similar update in upstream PHP installation, by modifying php.ini config file. Otherwise, although Apache may accept bigger file uploads, they will be rejected by upstream PHP.
- Server Resources – Uploading larger files requires more processing power and memory. So if you increase this limit, you will see an increase in memory consumption and CPU usage. Make sure your memory and CPU can handle it. Otherwise, your site will crash. So be careful when you increase this limit. If you set it to a very high value, then other processes on your server may struggle for resources.
- Increase Timeouts – Large files take a long time to upload. Meanwhile, you may get a request timeout error. To prevent this, you may need to increase request timeout values in Apache.
- Chunked Uploads – If you find that even after increasing file upload limit, your server is unable to process large files, then consider using chunked uploads whereby you split the large file into smaller chunks and upload the chunks one by one.
Conclusion
In this article, we have learnt why you may need to increase max upload file limit. We have also learnt a couple of simple ways to increase file upload size in Apache server. You can use any of these solutions as per your requirement.
Also read:
How to Disable Cache in Apache Server
How to Restrict Access By IP in Apache Server
How to Upgrade Apache Version in Ubuntu

Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.