I am unable to upload WordPress themes larger than 2 MB in size; I receive the error message “the uploaded file exceeds the upload_max_filesize directive in php.ini”. How can I resolve this?

The default PHP configuration on an AWS EC2 instance doesn’t allow uploading of files larger than 2 MB in size. Change the default value of the ‘upload_max_filesize’ parameter in /etc/php-<version>.ini.

Single EC2 Instance

1.    For a single EC2 instance running a LAMP stack, open the file /etc/php-5.5.ini (this file name may vary based on the PHP version) using your favorite editor.

$ sudo vi /etc/php-5.5.ini

2.    Change the value of the parameter "upload_max_filesize" from 2MB to a larger size and save the file.

3.    Restart the Apache server gracefully.

$ sudo apachectl -k graceful 

Note: To ensure that this change persists across new instances, update the underlying AMI.

Elastic Beanstalk

This can be achieved with an .ebextensions config file:



        mode: "000644"

        owner: root

        group: root

        content: |

            upload_max_filesize = 100M

            post_max_size = 100M



        command: "rm -f /etc/php.d/99uploadsize.ini.bak"

Note: Consider checking for whitespace problems using a YAML validator. The remove_old_ini command removes unnecessary backup files. The post_max_size is raised to 100 MB in this example because the default size is 8 MB; for more information, see Extending php.ini.

Elastic Beanstalk, EC2, WordPress, themes, PHP, ebextensions

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-12-27

Updated: 2017-01-05