The project provides a command-line script written in bash to easily create, manage, enable, disable, and delete WordPress sites using Docker Compose with LEMP Stack setup. It provides a simple and automated way to set up and manage WordPress site on your server.
Before running this project , you need to setup an EC2 Instance on Amazon Web Services(AWS) using Amazon Linux AMI. During setting up of EC2 Instance make sure to keep port 80 and port 3306 open in security group of the instance.
After setting up the instance and logging into the instance , you need to run the following commands as a prerequisite for the project to run successfully.
Install git using yum package manager
sudo yum install git -y
After installing git you need to install lynx which is a terminal-based web browser for all Linux distributions. It shows the result as plain text on the terminal
sudo yum install lynx -y
Clone the project
git clone https://github.com/shubhamch71/WordPress-Site-on-Dockerized-LEMP-Stack.git
Go to the project directory
cd WordPress-Site-on-Dockerized-LEMP-Stack
Give permissions to the script
chmod a+x wp_lemp.sh
To successfully launch the wordpress website , navigate to the directory where the wordpress_manager.sh script is located.
The command syntax for using the script is as follows:
./wp_lemp.sh <command> <site_name>
Where:
- is one of the following: create, enable, disable, or delete.
- <site_name> is the desired name for your WordPress site (e.g., example.com).
The create command allows you to create a new WordPress site using Docker Compose with the LEMP stack.
./wp_lemp.sh create <site_name>
<site_name>: Specify the name for your WordPress site. The create command will perform the following tasks:
- Set up a new directory with the provided <site_name>.
- Create the necessary Nginx configuration file and Dockerfile for PHP customization.
- Generate a Docker Compose file to set up the Nginx, PHP, and MySQL containers for the WordPress site.
- Prompt you to open the site in your browser once it's up and healthy.
The enable and disable commands allow you to start or stop the containers for a specific WordPress site.
- The enable command will start the containers for the specified site, making it accessible.
./wp_lemp.sh enable <site_name>
- The disable command will stop the containers for the specified site, making it inaccessible.
./wp_lemp.sh disable <site_name>
<site_name>: Specify the name of the WordPress site you want to enable or disable.
The delete command allows you to delete a WordPress site, including stopping the containers and removing local files.
./wp_lemp.sh delete <site_name>
The delete command will perform the following tasks:
- Stop and remove the containers associated with the site.
- Remove the local directory for the site.
After doing the prerequisites, following is the demo output of the project
- After running the create subcommand , the script checks for docker and docker-compose and installs them if it is not installed .
- After docker-compose is installed it creates the docker containers and launches the Wordpress site after a health check is done successfully.
- You are prompted to open the Wordpress site in using lynx in the command line itself. Please type Y to open it in lynx.
- After opening it in lynx you can see the installation page of Wordpress site which indicates the successful setup of Wordpress site using lemp stack . (Note this installation setup is required only for the first time). To exit lynx you can traverse to the bottom of page using down arrow key and then press q to quit and press y .
- You can also open the site on external browser by copy pasting the ec2 instance public ip address. (Optional - You can directly open the website by typing the website name in external browser if you have the domain for the same.)
- After running the enable subcommand the conatiners are started again and now you can access the wordpress site .