ft_server
ft_server copied to clipboard
[Guide to ft_server 42] My first Web Server with Docker 🐳. LEMP development (Linux, Nginx, MySql, Php)
ft_server - @42born2code
![]()
Table of Contents:
- What is ft_server ❔
- Instructions 👈
- Guide: What I did step by step ✔️
- How it looks 💻
- 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 |

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
How it looks 👀
http://localhost/

http://localhost/pypmyadmin

http://localhost/wordpress

Resources/Research: 🔍
-
Docker
-
Dockerfile: a text file that contains all commands, in order, needed to build a given image.
- Dockerfile-best-practice
- Dockerfile-reference
- ARG-ENV Build-time configuration with ARG && Run-time Environment Replacement using ENV
-
Web Server: a web server stores and delivers the content for a website – such as text, images, video, and application data – to clients that request it.
- What is a web server?
- Linux Web Server Guides
- How To Install Linux, Nginx, MariaDB, PHP (LEMP stack) on Debian 10 LEMP stack means: Linux, Nginx, MySQL, PHP.
-
Debian
- About Debian
- Debian Directory Structure
- wget use it to retrieve content and files from various web servers
- How to Use sed to Find and Replace String in Files (autoindex on/off)
-
Nginx
- Default nginx configuration
- Nginx 502 Bad Gateway Error
-
MariaDB (database system) installed to store and manage data for your site
- mysql_secure_installation a shell script available on Unix systems, and enables you to improve the security of your MariaDB installation
- MariaDB vs MySQL
-
PHP
-
phpMyAdmin phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web.
-
WordPress
-
SSL