[42 ft_server] How to install LEMP + Wordpress on Debian buster by using Dockerfile — 1


This article will show you how to install Nginx, MariaDB, phpmyadmin, Wordpress on debian buster by using Dockerfile. LEMP stands for Linux, Nginx, MariaDB or MySql, PHP.

I’ll assume that you already have docker in your local. Very first command in your dockerfile will be..

From debian:buster

By using From you can install OS in your virtual environment.

Before install other stacks, let’s get update software packages in debian. And wget command will be used to get .tar file of phpmyadmin and wordpress, so install it in advance.

RUN apt-get updateRUN apt-get upgrade -yRUN apt-get -y install wget
RUN apt-get -y install nginx

To access config file of nginx, run the docker by using below command in the directory which your dockerfile locates.

Build the image first, and then run it. Build the image with name ‘nginx’ or whatever name you prefer. And run the container with port 80:80. rm option will delete the container automatically after quitting this container.

docker build -t nginx .
docker run -it --rm -p 80:80 nginx

It will run in bash form. Since nginx does routing from default file in /etc/nginx/sites-available, you’ll need to go to the directory and copy it.

cd /etc/nginx/sites-available# cat default

You have to edit this default config file below. My config file follows after.

  1. First Server block
  • [::]: =>According to nginx docs, these square brackets [::]: are for IPv6 .
  • server_name => routing following domain.
  • return 301 => HTTP status code 301 makes redirection to HTTPS automatically.

2. Second Server block

  • Setting SSL Key and autoindex is optional.
  • root => if server_name domain exists, you can set the root folder.
  • index => set following files as index files.
  • first location block=> Since Nginx doesn’t support static file hosting as default, looking for file in the folder followed by uri within root folder. If cannot find this file, it shows 404(page not found) error.
  • second location block=> This enables php program connected with Nginx. php-fpm stands for PHP FastCGI Process Manager.

Next week, article will be continued with installing Mariadb(MySQL), phpmyadmin, and wordpress.

42 Seoul cadet