A quick-reference guide with ready-to-use commands for increasing the file upload size limit in WordPress by modifying PHP configuration on Apache servers.
WordPress enforces file upload limits based on the underlying PHP configuration. By default, these limits can be restrictive when uploading large media files, themes, or plugins. This repository provides a one-liner set of sed commands that update the relevant PHP settings and restart Apache so the changes take effect immediately.
- Increases
upload_max_filesizeto 512 MB - Increases
post_max_sizeto 512 MB - Extends
max_execution_timeto 300 seconds - Extends
max_input_timeto 300 seconds - Automatically creates backup files (
.bak) of the originalphp.inibefore making changes - Restarts Apache to apply the new configuration
- A Linux server running Apache with PHP (e.g., Ubuntu, Debian)
- WordPress installed and configured
sudoprivileges on the server- PHP installed via the system package manager (configuration at
/etc/php/*/apache2/php.ini)
No installation is required. Simply copy and run the commands below on your server.
Run the following commands on your WordPress server:
sudo sed -i.bak -e 's/^upload_max_filesize.*/upload_max_filesize = 512M/g' /etc/php/*/apache2/php.ini;
sudo sed -i.bak -e 's/^post_max_size.*/post_max_size = 512M/g' /etc/php/*/apache2/php.ini;
sudo sed -i.bak -e 's/^max_execution_time.*/max_execution_time = 300/g' /etc/php/*/apache2/php.ini;
sudo sed -i.bak -e 's/^max_input_time.*/max_input_time = 300/g' /etc/php/*/apache2/php.ini;
sudo service apache2 restartAfter running the commands, verify the new limits by navigating to WordPress Admin > Media > Add New or by checking the PHP info:
php -i | grep -E "upload_max_filesize|post_max_size|max_execution_time|max_input_time"- WordPress -- Content management system
- PHP -- Server-side scripting language powering WordPress
- Apache -- Web server hosting the WordPress site
- Bash -- Shell commands for automated configuration
This project is licensed under the MIT License.