Skip to content

This is a System Administration subject, to discover Docker and set up my first web server!

Notifications You must be signed in to change notification settings

lilangbr/42ft_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42ft_server

🔧 Docker, Nginx, Mysql, phpmyadmin, Wordpress, bash
🌍 Linux

It is a systems administration project, whose objective is to create a containerized and ready-to-deploy web server, using Docker. Applications such as Nginx, PHPMyAdmin and Wordpress are run inside the container, and the use of Docker Compose is prohibited. In addition to learning about how a server works and about the concept of containerization, the project also encourages the use of scripts to facilitate and automate deployment.

This server runs multiples services:

  • Wordpress,
  • phpMyAdmin, and a
  • SQL database

• It was set up a web server with Nginx, in only one debian buster docker container.

• Ther web server is be able to run several services at the same time: WordPress website, phpMyAdmin and MySQL. (It was make sure that the SQL database works with the WordPress and phpMyAdmin.)

• The server is be able to use the SSL protocol.

• Depending on the url, the server redirects to the correct website.

• Ther server is running with an autoindex that is be able to be disabled.

🚧 Build:

$ sudo docker image build -t lilangbr/ft_server:last .

🚀 Up:

$ sudo docker container run -it -p 80:80 -p 443:443 --name last lilangbr/ft_server:last

🛑 Stop:

$ sudo docker container stop last

♻️ Start again:

$ sudo docker container start -ai last

Enjoy this!

0th

🚧 Steps of contruction

In order you understand how the server was contructed, below it was the steps of this project: (The intermediate files can be obtained by looking for commits)

Step 1 - NGINX v1.0

Install NGINX server, start it and keep the container running.

1th

To keep container running: In Unix-type operating systems, the / dev / null, or null device, is a special file that discards all information written in it and that does not return any information to a process that reads it (more precisely, it returns an end of archive). In Unix programming jargon, it's also called a bit bucket or "black hole". See

  • Build:
    • $ sudo docker image build -t lilangbr/ft_server:1.0 .
  • Up:
    • $ sudo docker container run -it -p 80:80 --name v1.0 lilangbr/ft_server:1.0

1_1th

  • Stop:
    • $ sudo docker container stop v1.0
  • Start again:
    • $ sudo docker container start -ai v1.0

Step 2 - SSL v1.1

Configure nginx HTTPS server with self-signed SSL certificate.

  • Three new files: config.sh, nginx.conf and self-signed.conf
    • The first copies the others, which are additional configuration files, to the folders specified in the container, makes the necessary links, as well as creates a self-signed key and certificate pair with OpenSSL installed by Dockerfile(#SSL config).
    • In the second, additional configuration file, the connection to port 80 is redirected to a secure HTTPS connection - port 443, which is added, setting the certificate, including the self-signed.conf file, as well as the index files.

2th

Build:

  • $ sudo docker image build -t lilangbr/ft_server:1.1 .
  • Up:
    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v1.1 lilangbr/ft_server:1.1
  • To stop and start again, see Step 1.

Step 3 - MySQL v1.2

Install MariaDB Server, start it and test an exampledb and a exampleuser.

  • Modified files:

3_0th

  • Schema:

3th

  • Start

3_1th

  • Test

3_2th

  • Exit

3_4th

  • ***** All right! *****

  • Build:

    • $ sudo docker image build -t lilangbr/ft_server:1.2 .
  • Up:

    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v1.2 lilangbr/ft_server:1.2
  • Stop:

    • $ sudo docker container stop v1.2
  • Start again:

    • $ sudo docker container start -ai v1.2

Step 4 - PHP v1.3

Install PHP for processing. Need PHP fastCGI process manager to handle PHP requests. It's also necessary a module that allows PHP to communicat wiht MySQL.

4th_0

  • Schema:

4th

  • Test 1: Passed!

4_1th

  • Test 2: Passed!

4_2th

  • Test 3: Passed!

4_3th

  • ***** All right! *****

  • Build:

    • $ sudo docker image build -t lilangbr/ft_server:1.3 .
  • Up:

    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v1.3 lilangbr/ft_server:1.3
  • Stop:

    • $ sudo docker container stop v1.3
  • Start again:

    • $ sudo docker container start -ai v1.3

Step 4* - More Tests

Here, let's test the Database connection from PHP. In config file, a database with some entries was created and also it was created a test file named todo_list.php to show in browser. As it was expected, the PHP was connected with database! In figure, the black box represent the server side, and the white box (the browser), the client side:

4_testth

  • ***** All right! *****

  • Build:

    • $ sudo docker image build -t lilangbr/ft_server_test:1.3 .
  • Up:

    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v_test1.3 lilangbr/ft_server_test:1.3
  • Stop:

    • $ sudo docker container stop v_test1.3
  • Start again:

    • $ sudo docker container start -ai v_test1.3

Step 5 - Wordpress v1.4

As in the previous steps, just look at the difference between commits. The steps were detailed in the code, with comments. The files are basically downloaded and later configured.

* Start verification *

5_0th

5_1th

5_2th

5_3th

***** All right! *****

  • Build:
    • $ sudo docker image build -t lilangbr/ft_server:1.4 .
  • Up:
    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v1.4 lilangbr/ft_server:1.4
  • Stop:
    • $ sudo docker container stop v1.4
  • Start again:
    • $ sudo docker container start -ai v1.4

Step 6 - phpMyAdmin v1.5

Same as Step 5.

6th

***** All right! *****

  • Build:
    • $ sudo docker image build -t lilangbr/ft_server:1.5 .
  • Up:
    • $ sudo docker container run -it -p 80:80 -p 443:443 --name v1.5 lilangbr/ft_server:1.5
  • Stop:
    • $ sudo docker container stop v1.5
  • Start again:
    • $ sudo docker container start -ai v1.5

Step 7 - Autoindex control

Basically, it was created a sheel script that identifies the line in the server config file that causes a state switch and change it by its opposite. Autoindex on -> autoindex off autoindex off -> autoindex on Warnings are show in the command line to guide admin. A soft link was generate in the root container to facilities the managing.

It was also created scripts that run the build image and up the container associated. As well as a script that clean the local machine(removes container and its image).

***** Thats all folks! *****

  • Build:
    • $ sudo docker image build -t lilangbr/ft_server:last .
  • Up:
    • $ sudo docker container run -it -p 80:80 -p 443:443 --name last lilangbr/ft_server:last
  • Stop:
    • $ sudo docker container stop last
  • Start again:
    • $ sudo docker container start -ai last

7th

About

This is a System Administration subject, to discover Docker and set up my first web server!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published