Coder Social home page Coder Social logo

gausahmed / lemp-wordpress-dev-environment-on-browser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

This repo contains the Bash shell script for creating LEMP Wordpress dev environment in your won browser. You can simply run the script and it will create LEMP stack in docker containers, for more details go through readme file.

Shell 100.00%
bash-script docker lemp-stack script wordpress wordpress-development

lemp-wordpress-dev-environment-on-browser's Introduction

Bash Script for creating LEMP Wordpress Site

This repository contains a Bash shell script which is capable of performing following tasks,

  1. Check if Docker and Docker-compose is installed in your machine or not. If not installed, install it.
  2. Create required files (eg. Docker-compose.yml, nginx/default.conf, publuc/index.php, etc)
  3. Create a WordPress site using the latest WordPress Version. This will be a LEMP (Linux, Nginx, Mysql, PHP) stck running inside Docker containers.
  4. Create a /etc/hosts entry for 'site_name' pointing to localhost.
  5. perform subcommands to, stopping/starting, deleting containers.

Execution Process

You only need to clone or copy this repository to your local folder and make sure the script.sh is executable in wordpress folder. You can do this by following command,

chmod +x script.sh

After making the script executable, we can run the script for the above operations to perform using following command,

It is MANDATORY to run the script as a administrator or superuser

sudo ./script.sh SITE_NAME

Note: Here you have to provide site name as an argument.

By running the scipt, it will perform the above mentioned task. It creates 5 different docker containers running LEMP stack (with phpmyadmin). If everything goes well, you can visit your wordpress site by opening it in the browser using either site_name or Localhost .

Running Subcommands

There are some sub-commands available in the script to perform operations like stopping, starting/restarting, deleting the containers. To run the sub-commands you need to add it to the main command as an argument for example,

  1. To start/Restart the containers,
./script.sh SITE_NAME enable
  1. To Stop the containers,
./script.sh SITE_NAME disable
  1. To Delete the containers,
./script.sh SITE_NAME delete

Installing Wordpress at localhost

After opening the site in a browser, you can see the wordpress installation page with a form requiring your information and login credentials. Fill the form and create the credentials and note them down for further use. Click on Install wordpress button at bottom. Login with your credentials and you are ready with your wordpress site.

Error handling

The script is already written so that there will be no room for error while execution but, we can't guarentee that the error will not occur. Incase any error occurs, you can look at the logs of all the containers and get rid of the error ofcourse manually by running,

docker-compose logs CONTAINER_NAME

There are more chances that the error can occure due to the ports on which we are running our stack are already in use. Although I have added a command in the script that makes the required ports free, but there can be some services which can restart at the same port. To avoid this error, check for the services running on the following ports 8000, 8080, 9000, 3306, 8081. If you found any service on one of these ports please try to stop them or you can change the script according to your required ports.

Conclusion & Results

With the above bash script we can create a sample wordpress site running inside Docker containers. the script itself creates the required files and folders like docker-compose.yml, nginx config files, etc.

lemp-wordpress-dev-environment-on-browser's People

Contributors

gausahmed avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.