🔧 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.
- 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!
🚧 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)
Install NGINX server, start it and keep the container running.
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
- Stop:
- $ sudo docker container stop v1.0
- Start again:
- $ sudo docker container start -ai v1.0
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.
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.
Install MariaDB Server, start it and test an exampledb and a exampleuser.
- Modified files:
- Schema:
- Start
- Test
- Exit
-
***** 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
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.
- Schema:
- Test 1: Passed!
- Test 2: Passed!
- Test 3: Passed!
-
***** 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
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:
-
***** 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
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 *
***** 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
Same as Step 5.
***** 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
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