Learn more about hosting WordPress on Lambda with EFS. Our WordPress Support team is here to help you with your questions and concerns.
WordPress Lambda EFS | How-to Guide
Did you know there are different approaches when it comes to hosting WordPress on AWS?
Today, we are going to take a look at running WordPress on Lambda, via Amazon Elastic File System (EFS).
Before diving into the setup process, keep the following ready:
- An AWS account.
- A VPC with Internet access via a NAT gateway or instance.
- Terraform installed (via v0.12 syntax).
- A MySQL database (e.g., MySQL on RDS).
- An EC2 instance for initial setup and WordPress installation.
How to set it up
- If not already running, start an EC2 instance and install the `amazon-efs-utils` package to prepare for mounting the EFS volume.
- Then, clone the Terraform module repository and create a `local.auto.tfvars` file that has the Security Group IDs and Subnet IDs. Or, we can configure custom domain settings if needed.
$ git clone https://github.com/KotobaMedia/terraform-aws-wordpress-on-lambda-efs
$ cd ./terraform-aws-wordpress-on-lambda-efs
- Then, create a file called local.auto.tfvars, and add this content to it:
# The Security Group IDs listed in step 1.
security_group_ids = ["sg-XXX"]
# The Subnet IDs you listed in step 1.
subnet_ids = ["subnet-XXX", "subnet-XXX", "subnet-XXX"]
If we want to use a custom domain name, set the acm_certificate_arn and domain_name variables.
- Next, run Terraform to create the resources.
$ terraform apply
If it asks for the AWS credentials, press Ctrl-C and set the authentication information via environment variables.
Now confirm when Terraform asks if we want to apply the changes.
- Next, we have to give EC2 instance access to the EFS filesystem by attaching the generated security group. Then, mount the EFS filesystem on the EC2 instance.
$ sudo -s
# mkdir /mnt/efs
# mount -t efs fs-XXXXX:/ /mnt/efs
- Then, go to to the designated directory on the EFS filesystem and start the WordPress installation.
Alternatively, we can use the Lambda approach outlined below:
- First, clone the WordPress boilerplate repository and follow the provided instructions to assemble the Lambda runtime.
- Then, deploy WordPress to Lambda using AWS SAM CLI. Make sure the database configuration and CloudFront settings are correctly configured.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts introduced us to hosting WordPress on Lambda with EFS.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments