Skip to content

Elastic Beanstalk – Multi-Version Deployment & Persistent Apache Configuration

0

Hi,

We are running an Elastic Beanstalk application using Apache and PHP 8. The application is based on WordPress, and we manage multiple WordPress versions across different groups of sites.

All site groups are hosted within a single Beanstalk environment to minimize the number of EC2 instances. Each Beanstalk application version corresponds to a specific group of sites (e.g., v1 hosts 5 sites, v2 hosts 3 other sites, etc.).

Problem: When the Auto Scaling Group (ASG) adds or removes instances, only the latest application version is automatically deployed. As a result, other site groups that rely on previous versions are not deployed on the new instances.

Current Setup: We already use Amazon EFS to persist WordPress binaries and assets.

Now, we want to persist Apache virtual host configuration files and SSL certificates to avoid losing configuration during scaling events. To achieve this, we:

Created EFS access points (e.g., /vhosts) Mounted them on EC2 instances Created symbolic links for the following directories: /etc/httpd/vhosts.d → /vhosts /etc/pki/tls/certs → /vhosts /etc/pki/tls/private → /vhosts Issue: Apache fails to start on EC2 instances due to the following error:

It seems the httpd service cannot run with configuration files on EFS. This may be due to the suid option not being supported by NFS.

Account ID: 278368569131

asked a year ago174 views

1 Answer
0

To address the issues you're facing with your Elastic Beanstalk application running Apache and PHP 8 for multiple WordPress versions, I can suggest a few approaches:

  1. Immutable Deployments: Instead of relying on rolling updates, consider using immutable deployments. This method creates an entirely new set of instances with the new version, ensuring all required configurations and versions are present. Once the new instances are healthy, traffic is shifted to them, and the old instances are terminated. This approach can help ensure all your site groups are properly deployed on each instance.

  2. Custom AMI: Create a custom Amazon Machine Image (AMI) that includes all the necessary WordPress versions, Apache configurations, and SSL certificates. Use this AMI as the base for your Elastic Beanstalk environment. This way, when new instances are launched, they will already have all the required components.

  3. Deployment Scripts: Implement deployment scripts that run on instance launch to pull and set up all required WordPress versions and configurations. These scripts can be included in your Elastic Beanstalk application bundle and executed during the deployment process.

  4. Separate Environments: Consider creating separate Elastic Beanstalk environments for each group of sites or WordPress version. This approach, while increasing the number of environments, ensures that each group is managed independently and reduces the complexity of maintaining multiple versions in a single environment.

Regarding the Apache configuration persistence issue:

The error you're encountering suggests that Apache is having trouble reading its configuration from the EFS mount. This is likely due to security restrictions. Instead of symlinking the entire configuration directories, consider the following:

  1. Store the configuration files on EFS, but copy them to the local filesystem during instance startup or deployment.

  2. Use a custom platform hook or an .ebextensions configuration file to copy the necessary files from EFS to the appropriate local directories on instance launch.

  3. If possible, keep the Apache configuration files local to the EC2 instances and use other methods (like S3 or a configuration management tool) to ensure consistency across instances.

  4. For SSL certificates, consider using AWS Certificate Manager (ACM) instead of storing them on EFS. ACM integrates well with Elastic Beanstalk and eliminates the need to manage certificate files directly.

By implementing these strategies, you should be able to maintain multiple WordPress versions and persist Apache configurations without encountering the issues you're currently facing.
Sources
Seamless Production Deployment with Elastic Beanstalk | .NET on AWS Blog
Immutable environment updates - AWS Elastic Beanstalk

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.