- What is ft_server β
- Instructions π
- Installation π§
- Content π¦
- Build Docker image π³
- Run a container π³
- Shell acces to the container π³
- Autoindex on/off π
- Guide: What I did step by step βοΈ
- How it looks π»
- Resources / Research π
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 |
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 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
git clone https://github.com/vvarodi/ft_server.git && cd ft_server
-
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)
docker build -t ft_server .
docker run --name ft_server -d -p 443:443 -p 80:80 ft_server
docker exec -it ft_server bash
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
http://localhost/
http://localhost/pypmyadmin
http://localhost/wordpress
-
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
-
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