3

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.

Ruchit Rami
  • 313
  • 1
  • 8
  • 15

1 Answers1

6

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.

jamieb
  • 3,387
  • 4
  • 24
  • 36
  • I am running into a similar problem. In your addition of a custom .ini file to /etc/php.d/ do you mean that it is necessary to connect to each running instance behind the beanstalk loadbalancer and apply this file? – Hal Jan 25 '13 at 21:09
  • @Hal, no you have to use an [Elastic Beanstalk config file](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html) to do it. SSHing into each instance and doing it would just mean your changes were reset each time a new instance started. – jamieb Jan 25 '13 at 21:38
  • @jamieb - So, exactly WHERE does one make the change to php.ini, or more precisely, the php.d file. I'm really not following what your recommending; "no, don't use the Elastic Beanstalk config file" and "No, you ssh into each instance...". So where? I'm having exactly the problem you mention in point 2... the changes I make are being wiped out each time the instance is started. How and where should those changes be made to make them "stick"? –  Aug 01 '13 at 01:04
  • @wagnert Use an Elastic Beanstalk config file to [copy your custom PHP ini file](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-files) from an S3 bucket to `/etc/php.d`. – jamieb Aug 07 '13 at 23:12