0

Trying to add .conf files to /etc/httpd/conf.d/ directory on the E2 instance from elastic beanstalk during deployment of Elastic Beanstalk Application. I've added the .ebextensions directory with a .config file that is defined as follows:

files:
  "/etc/php.d/project.ini" :
    mode: "000644"
    owner: root
    group: root
    content: |
      max_input_vars = 10000
      upload_max_filesize = 256M
      post_max_size = 256M

container_commands:
  01_enable_mod_deflate:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
  02_enable_mod_expires:
    command: "cp .ebextensions/enable_mod_expires.conf /etc/httpd/conf.d/enable_mod_expires.conf"
  03_secure_wordpress:
    command: "cp .ebextensions/secure_wordpress.conf /etc/httpd/conf.d/secure_wordpress.conf"
  04_restart_apache:
    command: "sudo apachectl restart"

the .conf files are all in the .ebextensions folder, but they are not getting copied over, which is causing an issue with .htaccess in the root of the wordpress site. The error that is being generated looks like this:

Command 01_enable_mod_deflate (cp /var/app/current/.ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf) failed 2020-10-05 13:45:59,944 [ERROR] Error encountered during build of postbuild_0_Benefits_Bridge_2: Command 01_enable_mod_deflate failed Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config CloudFormationCarpenter(config, self._auth_config).build(worklog) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build changes['commands'] = CommandTool().apply(self._config.commands) File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply raise ToolError(u"Command %s failed" % name) ToolError: Command 01_enable_mod_deflate failed

Not sure what any of that even means, but it's generating the same error for each file. What is wrong here? I just spun up a new instance of Elastic Beanstalk and shouldn't this work by default? Is there an issue with the Instance or something? The site is generating a 500 error because of the .htaccess file in the root, but if I remove it, than only the homepage loads and all other pages give 404 errors. I need these .conf files added to the /etc/httpd/conf.d/ directory of all instances, but they aren't added at all to any of the instances because of the error above, which I have no idea how to fix, or if this is an issue with the instance which is the default that gets created with Elastic Beanstalk?

How to fix this problem? I've restarted the Environment, but that didn't help. I'm a bit hestitant to Rebuild the Environment since that will wipe out the database that is connected to the application and not sure if that would help any.

Solomon Closson
  • 6,111
  • 14
  • 73
  • 115
  • Can you ssh into the instance and inspect from inside? Are the destination locations correct? If you manually copy the files, does everything work as expected? – Marcin Oct 05 '20 at 23:34
  • yes, I can ssh into the instance fine, and copying files works as expected inside the instance. – Solomon Closson Oct 06 '20 at 15:48
  • The directory to /etc/httpd/conf.d/ is there, but the .ebextensions directory is not even on the instance at all. Shouldn't that also be copied into the /var/app/current directory? Or is that only used during deployment? – Solomon Closson Oct 06 '20 at 16:10
  • Ok, more info. the project.ini file is being written with the following information correctly. When I log in via ssh, I have to do sudo cp in order for it to work, so gonna try changing it to that inside of the .config file also and hope that does it. – Solomon Closson Oct 06 '20 at 17:31
  • Tried with `sudo` and still no luck. It just doesn't copy over the files and doesn't even add the files to the instance at all anywhere. – Solomon Closson Oct 06 '20 at 17:49
  • any solution yet? – BlackPearl Jan 08 '21 at 21:30

1 Answers1

2

You are probably using Amazon Linux 2 that changed the location of configuration files for proxy (NGINX or Apache). Put your proxy configuration files under .platform instead of .ebextensions: Ex:

|____wp-signup.php
|____.platform
| |____httpd
| | |____conf.d
| | | |____http-redirect.conf

More details in the documentation:

Migrating your Elastic Beanstalk Linux application to Amazon Linux 2

Edu_Godoy
  • 81
  • 7