How Do I Change the Maximum Upload File Size for an Apache Web Server?


Scott Campbell

Are you facing issues with uploading large files to your Apache web server? Do you want to change the maximum upload file size to accommodate larger files? In this tutorial, we will walk you through the process of changing the maximum upload file size for an Apache web server.

Step 1: Accessing the php.ini File

To change the maximum upload file size, we need to modify the php.ini configuration file. This file is responsible for managing various PHP settings and can be found in the root directory of your Apache web server.

Here are the steps to access the php.ini file:

  1. Connect to your web server using SSH or any other terminal emulator.
  2. Navigate to the root directory by running the command:
  3. cd /etc/php/7.4/apache2/
  4. Edit the php.ini file using a text editor like nano:
  5. sudo nano php.ini

Step 2: Changing Maximum Upload File Size

Once you have opened the php.ini file, follow these steps to change the maximum upload file size:

  1. Use your text editor’s search functionality (Ctrl + W or Command + F) and look for “upload_max_filesize”.
  2. You will find a line similar to this:
  3. ;upload_max_filesize = 2M

    Note: The semicolon (;) at the beginning of this line indicates that it is commented out. We need to remove it in order to make changes.

  4. Change the value next to “upload_max_filesize” to your desired file size. For example, if you want to set the maximum upload file size to 100MB, modify the line as follows:
  5. upload_max_filesize = 100M

    Note: Make sure to specify the size in megabytes (MB) or gigabytes (GB) using the appropriate suffix.

  6. Save the changes and exit the text editor. In nano, you can do this by pressing Ctrl + X, then Y, and finally Enter.

Step 3: Restarting Apache Web Server

After modifying the php.ini file, we need to restart the Apache web server for the changes to take effect. Follow these steps:

  1. Run the following command to restart Apache:
  2. sudo service apache2 restart
  3. This will restart your Apache web server and apply the new maximum upload file size.

Verification and Troubleshooting

To ensure that your changes have been successful, you can create a simple PHP script that displays your PHP settings. Follow these steps:

  1. Create a new file called “phpinfo.php” in your web server’s document root directory (e.g., /var/www/html/) using a text editor.
  2. Add the following code to this file:
  3. <?php
  4. Save and close the file.
  5. Access this file through your web browser by navigating to http://your-server-ip/phpinfo.php.
  6. You should see a page displaying detailed PHP information, including the new maximum upload file size.

If you are still unable to change the maximum upload file size, make sure you have edited the correct php.ini file and restarted the Apache web server properly. Additionally, check for any errors or warnings displayed in your Apache error log.


Changing the maximum upload file size for an Apache web server is essential when dealing with large files. By following the steps outlined in this tutorial, you can easily modify this setting and accommodate larger uploads to your web server.

Remember to always consider your server’s resources and limitations when changing this value. Setting an excessively high maximum upload file size can impact performance and consume unnecessary disk space.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy