A project that aims to broaden your knowledge of sys admin by using Docker.
After a lot(and I mean a lot!) of trial and error these are the steps I took to complete the project.
- Set up virtual machine using latest Debian image (12.5 at time of writing)
- Install required software - apt udpate
- apt install -y sudo, ufw, docker, docker-compose, make, openbox, xinit, kitty, firefox-esr - Do the port forwarding - ufw enable
- modify /etc/ssh/sshd.confit for Port 42
- ufw allow 443, 80 & 42
- shutdown the virtaul machine and add port forwarding rules in Settings
- SSH 42
- HTTP 80
- HTTPS 443
- restart the vm
- open a terminal and ssh into the vm with ssh [email protected] -p 42 - Configure sudo - nano /etc/sudoers
- add user ALL to user priveleges
- add user to sudo and docker groups sudo usermod -aG docker username - Make directories and files for the project using the subject pdf structure
- Modify /etc/hosts so that 127.0.0.1 points to user.42.fr
- Create nginx container. There is lots of documentation on the internet about this.
- image is the Dockerfile. Needs to contain the run commands for both nginx and openssl. We use openssl to generate a self-signed certificate in TLSv1.3
- configuration goes in conf/nginx.conf
- google what is required for an openssl certificate, there is a format to follow - Create worpress container. In the .env file that you would have created enter login details required for wordpress (there is an example included in my github).
- the Dockerfile needs to include the installalation of php-fpm and its dependicies
- in the /conf folder you will need a bash script to configure wordpress (I used wp-cli for this)
- at this point you will need the docker-compose.yml file (located at /srcs) - Create mariadb container - in the /conf folder you will need a bash script to configure the mysql database and store the login details in the .env file
- Create Makefile with docker-compose commands to build, up, down, fclean etc
docker-compose up -d - start container
docker-compose down - stop container
docker-compose up -d --build - build the container
docker ps -a - shows the list of running containers
docker-compose down --volumes - stops the container and removes the volumes
docker exec -it wordpress ps aux | grep 'php' - shows that wordpress and php have been installed
docker exec -it mariadb mysql -u user -ppwd - log into the mariadb
SHOW DATABASES - when in the mariadb will show a list of databases installed. Use this to check that a wordpress db exists.