How to replace php.ini on elastic beanstalk EC2 instances for PHP

amazon ec2amazon s3amazon-beanstalk

I have been exploring Elastic Beanstalk for easy deployment of my PHP 5.4 application. For my application, I need to make changes in php.ini file.

After some searching on internet i tried to use configuration files in git directory. Following is the content of my file(.config) in .elasticbeanstalk directory in git directory:

    files:
  "/etc/php.ini":
    mode: "000644"
    owner: root
    group: root
    source: https://bucketname.s3.amazonaws.com/php.ini

I have uploaded my custom php.ini in my own bucket on s3 and have given all rights to everyone. But still after deployment multiple time I am unable to see new files deployed.

I am using the following code to check for the changes in php.ini file.

    <html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World2<br/></p>'; 
 echo 'display_errors = ' . ini_get('display_errors') . "\n";
 echo 'register_globals = ' . ini_get('register_globals') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
echo 'include_path = ' . ini_get('include_path') . "\n";
 ?> 
 </body>
</html> 

In my custom php.ini post_max_size has value 8M which shows 32M on beanstalk application.

Edit: I have downloaded my php.ini file from EC2 instance that is running my application. And it is different than my custom php.ini.
Further, I am using <?php phpinfo(); ?> to check changes from my php page.

Best Answer

You don't want to be doing this. It could break the upgrade path of Amazon's AMI since it's a rolling release.

Instead of wholesale replacing the entire file, specify the changes that you need in a custom .ini file and put it in /etc/php.d/. If a setting in the custom .ini conflicts with one specified in php.ini, the custom setting will take precedence.