Skip to content

[Guide to ft_server 42] My first Web Server with Docker 🐳. LEMP development (Linux, Nginx, MySql, Php)

Notifications You must be signed in to change notification settings

vvarodi/ft_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ft_server - @42born2code

Table of Contents:

  1. What is ft_server ❔
  2. Instructions πŸ‘ˆ
  3. Guide: What I did step by step βœ”οΈ
  4. How it looks πŸ’»
  5. Resources / Research πŸ”

What is ft_server ❔

SUBJECT

The goal of ft_server is to create a web server with Nginx capable of running a WordPress website, phpMyAdmin, and a MySQL database. This server will run in only one Docker container, under Debian Buster.

Services Path
WordPress http:localhost/wordpress
phpMyAdmin http:localhost/phpmyadmin

final_version

Description for newbies: πŸ’‘

When you type in the search bar "Google.com" a web server stores the files constituting the website (images, etc.). To obtain the page, your browser makes a request for a web page to the server which then sends the files (if the server doesn't find the requested document, it returns a 404 response instead).

There are different types of web servers: static or dynamic. In our case, we will create a dynamic web server.

From a software point of view, the components of a dynamic web server are:

  • An OS (ex: Windows or Linux)
  • An HTTP server = software that supports client-server requests for the HTTP protocol (ex: Apache or Nginx)
  • A database (ex: mySQL, Oracle)
  • A script language = allows to interpret customer requests and translate them into html (ex: PHP, Python, Java)

  • Our OS = Debian Buster
  • Our HTTP server = Nginx
  • Our Database = Maria DB.
  • Our scripting language = PHP.

Plus we will install and configure phpMyAdmin and WordPress

We are going to do all of this in a Docker container. Why in a Docker container? 🐳

⚠️ The problem: Often we end up with applications that have tons of dependencies: need magic to convert images, need a particular database, need nginx or apache etc. When working with a third-party web host it is a bit hell. The system administrator will have to install the correct versions on a number of machines etc., puzzle. πŸ’’

πŸ’― The solution: Docker makes it possible to package an application in a virtual container. It's a sort of box that is completely isolated from our operating system. In which we can install all the libraries that our application needs to function. And we also install our application there. And so we can send this box all over the place, and it's going to work no matter what operating system.βœ”οΈ

The Docker image would include:

  • Nginx
  • PHP
  • MariaDB SQL database
  • PhpMyAdmin
  • Wordpress

Instructions πŸ‘ˆ

πŸ”§ Installation

git clone https://github.com/vvarodi/ft_server.git && cd ft_server

πŸ“¦ Content

  • Dockerfile (contains the instructions for building the webserver's docker image)

  • srcs/ (contains configs and some bash scripts)

  • testing.sh (Build, run and enter a container)

  • deleting.sh (Remove and clean)

autoindex_on/off.sh (Once the container is running, stop and change AUTOINDEX environment variable)

πŸ”¨ Build Docker image

docker build -t ft_server .

πŸƒ Run a container

docker run --name ft_server -d -p 443:443 -p 80:80 ft_server

🐚 Shell acces to the container

docker exec -it ft_server bash

πŸ“ Autoindex on/off

By default AUTOINDEX is on when you run the container. If you want to run the container setting autoindex off at the beggining of being launched:

docker run --env AUTOINDEX=off --name ft_server -d -p 443:443 -p 80:80 ft_server

It also can be activated/desactivated when the container is launched (via an environment variable):

Inside the container

echo $AUTOINDEX
AUTOINDEX=off
bash change_autoindex.sh

or outside the container

sh autoindex_off.sh

Guide: What I did step by step

Wiki

How it looks πŸ‘€

http://localhost/

final

http://localhost/pypmyadmin

phpmyadmin

http://localhost/wordpress

WordPressWelcome

Resources/Research: πŸ”

About

[Guide to ft_server 42] My first Web Server with Docker 🐳. LEMP development (Linux, Nginx, MySql, Php)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published