Search code examples
phpapacheamazon-ec2amazon-elastic-beanstalkmod-security

install Mod_security on Amazon Elastic Beanstalk (Apache, EC2)


I get dependency issues when I try to install mode_security on Elastic Beanstalk.

It's pretty simple to recreate it:

- launch a new PHP environment:

  1. get on the elastic beanstalk console and create a new environment (you can register for free)
  2. choose 'web server', then 'PHP', then 'load balancing'
  3. in 'Application Version' click Next, 'Environment Information' set name and Next
  4. in 'Additional Resources','Configuration Details',etc let default then next and launch your environment

- SSH into your instance:

If you have the elastic beanstalk cli

  1. cd your folder
  2. eb use [your env name]
  3. eb ssh (you may be asked some confirmations)
  4. try to install mod_security: yum install mod_security

Now you should have:

Error: httpd24 conflicts with httpd-2.2.31-1.7.amzn1.x86_64
Error: httpd24-tools conflicts with httpd-tools-2.2.31-1.7.amzn1.x86_64

enter image description here

Thank you for helping! If you have any questions, I'm here!


I saw on stackoverflow a solution was to remove them yum remove httpd httpd-tools and install mod_security, but that brings other dependency issues...


Solution

  • When you are logged in to your instance (eb or ssh), use this to install the relevant packages:

    sudo yum install httpd24-devel.x86_64
    sudo yum install mod24_security.x86_64
    

    Don't forget to restart apache

    sudo /etc/init.d/httpd restart