Create AWS EFS (Elastic File System) Plugin storage for WordPress behind Load Balancer
Tags: aws, efs, wordpress
Published: 2020-02-07 00:51:39

---
title: Create AWS EFS (Elastic File System) Plugin storage for WordPress behind Load Balancer
published: true
date: 2019-12-27 01:54:17 UTC
tags: AWS,EFS,Wordpress
canonical_url: 
---

> **This article is the continuation of [WordPress with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series](https://dev.to/saluminati/high-traffic-wordpress-website-with-docker-aws-ecs-code-pipeline-load-balancer-rds-efs-complete-series-43id). For better understating, please start from the beginning of the series.**

# Why do we need to use EFS for plugin storage

We all love the fact that on WordPress, we can install plugins without a deployment. Here’s the challenge with this approach, if your WordPress website is behind a Load balancer and there are multiple instances running. You will be installing the plugin only on the instance you are connected to. It will crash for the users who are connected to other instances.

One simpler solution is to deploy the WordPress website again with the plugin included. It takes away the freedom of installing or un-installing a plugin without a redeployment.

[AWS Elastic File System (EFS)](https://aws.amazon.com/efs/) is our answer, we will simple mount the plugin directory of WordPress instances to our EFS.

Let’s get our hands dirty folks !!!

# Create EFS Service

Select EFS from the service tab of your AWS console and click on **Create file system**

In the security groups we will add efs Security group.

![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/27022325/001-4-1024x600.png)

![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/27022523/002-4-1024x1022.png)

**Note:** Please use MAX/IO option optimal performance.

Go ahead and finish creating the EFS setup. It will take few minutes for AWS to create our file system.

In the meantime, we will SSH into our Bastian instance and install few things. Please refer to the [Prepare AWS Security Groups for WordPress project](https://dev.to/saluminati/prepare-aws-security-groups-for-wordpress-project-5ebn-temp-slug-9850075) **Connect to Bastian Instance** section to connect.

Once you connect to the bastian instance, run the following commands:

```shell
sudo apt-get update

sudo apt-get install nfs-common

mkdir efs
mkdir efs/plugins
mkdir efs/cache
```

We will use the same EFS for our plugins and cache (for SEO optimization later)

Go to your EFS file system and copy the DNS value.

![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/27023541/003-4-1024x387.png)

Run the following command

```shell
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-6f0f3156.efs.ap-southeast-2.amazonaws.com:/ efs
```

Please replace **fs-6f0f3156.efs.ap-southeast-2.amazonaws.com** with your own file system DNS name

now run the following command to make sure that the EFS is mounted correctly.

```shell
df -h
```

![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/27024131/efs-mount-1024x374.png)

As I told you earlier, It’ll get easier as we will progress. Our plugins and cache storage in completed !!!!

#### Previous

**[Create MYSQL database using AWS RDS](https://dev.to/saluminati/create-mysql-database-using-aws-rds-2p7j)**

#### Next

**[Build and Push wordpress project to AWS ECR](https://dev.to/saluminati/build-and-push-wordpress-project-to-aws-ecr-2h7c)**