Question: How do I upload WordPress files larger than 2 MB to my Elastic Beanstalk environment?

When I try to upload WordPress files larger than 2 MB to my AWS Elastic Beanstalk environment, I receive the following error message: "The uploaded file exceeds the upload_max_filesize directive in php.ini."Short descriptionThe default PHP configuration on an Amazon Elastic Compute Cloud (Amazon EC2) instance doesn't allow you to upload WordPress files larger than 2 MB. To upload files larger than 2 MB, change the default value of the upload_max_filesize parameter in the /etc/php.ini file.Important: M and MB are equivalent expressions for "megabyte." For example, 2M is equal to 2 MB. However, use only M in your configuration file, as MB isn't valid in a configuration file.

ResolutionChoose the resolution that applies to your solution stack.Update the upload file size for an Elastic Beanstalk environment running a PHP solution stackTo increase the file size across all instances, complete the following steps to update the underlying Amazon Machine Image (AMI).1.    In a code editor, create a new file named change_upload_size.config, and then add the following code to the file:files:    "/etc/php.d/99uploadsize.ini":        mode: "000644"        owner: root        group: root        content: |            upload_max_filesize = 100M            post_max_size = 100Mcommands:    remove_old_ini:        command: "rm -f /etc/php.d/99uploadsize.ini.bak"Note: In the preceding example, the value of the post_max_size parameter is updated from the default 32M to 100M.Tip: To modify php.ini parameters such as memory_limit, see the php.ini directives for post_max_size. The maximum memory_limit value in Elastic Beanstalk is 256M.2.    In the root of your application source bundle, create a new directory called .ebextensions, and then move the change_upload_size.config file to the .ebextensions  directory.If the .ebextensions directory is already inside your application source bundle, then keep the change_upload_size.config file in the .ebextensions directory with the other .config files. The directory structure should be similar to the following example:├── wp-site.zip/     ├── .ebextensions/         ├── change_upload_size.config    ├── wp-content/    ├── wp-includes/    ├── wp-admin/    ├── LICENSE    ├── README.md    ├── index.php    ├── license.txt    ├── readme.html    ├── ...    ├── ...    ├── ...    ├── ...    ├── wp-settings.php    ├── wp-signup.php    ├── wp-trackback.php    └── xmlrpc.phpImportant: For Amazon Linux 2 platforms based on Elastic Beanstalk, change the file name 99uploadsize.ini to z99uploadsize.ini everywhere in the .ebextension to allow the new PHP settings to override the defaults.3.    Open the Elastic Beanstalk console, and then create a zip archive of your application source bundle.4.    To upload your code to an existing Elastic Beanstalk environment, choose your environment, and then choose Upload and Deploy.Note: To deploy your code in a new Elastic Beanstalk environment, see Creating an Elastic Beanstalk environment.If the error message doesn't go away after you upload the .ebextensions file, then use a YAML validator to check for white space errors in your code. Also, consider using the remove_old_ini command to remove unnecessary backup files. For more information, see Extending php.ini.Change the upload file size for a single Amazon EC2 instance running a LAMP stack1.    To open the /etc/php.ini file with the vi editor, run the following command:$ sudo vi /etc/php.iniNote: The /etc/php.ini file name or path can vary depending on your version of PHP or the AMI that you're using.2.    In the vi editor, change the value of the upload_max_filesize parameter to a larger size than 2 MB, and then save the file.Tip: To modify php.ini parameters such as memory_limit, see the php.ini directives for post_max_size. For more information, see the post_max_size entry on the PHP website.3.    To restart the Apache server gracefully, run the appropriate command for your environment.For Amazon Linux:$ sudo service httpd gracefulFor Amazon Linux 2:$ sudo service httpd reloadNote: The /etc/php.ini file name or path can vary depending on your version of PHP or the AMI that you're using. The command to restart the Apache server can also vary if you're using a distribution other than Amazon Linux AMI. WordPress limits the memory of its PHP processes by default.

Related informationAdvanced environment customization with configuration files (.ebextensions)Deploying a high-availability WordPress website with an external Amazon RDS database to Elastic BeanstalkTutorial: Hosting a WordPress blog with Amazon LinuxDescription of core php.ini directives