Use docker-compose to create a LEMP stack (L for Linux, E for Nginx, M for Mariadb and P for PHP) with wordpress.
127.0.0.1 login.42.fr
sudo adduser login
sudo usermod -aG sudo login
sudo usermod -aG docker login
sudo usermod -aG vboxsf login (if you use shared folders on your vm)
- Delete previous version
sudo apt-get remove docker-compose
sudo rm -f /usr/local/bin/docker-compose
- Install newest version
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Darwin-x86_64" -o /usr/local/bin/docker-compose (version 29.2 at the time of this readme)
sudo chmod +x /usr/local/bin/docker-compose
sudo service nginx stop
sudo service mysql stop
If you get the following error message : Docker compose up : error while fetching server API version
sudo gpasswd -a $USER docker
newgrp docker
Use official images to begin and see how each service can communicate with each other
- Understanding environment variables
https://betterprogramming.pub/using-variables-in-docker-compose-265a604c2006
- Understanding network
https://medium.com/edureka/docker-networking-1a7d65e89013 https://faun.pub/docker-networks-part-1-of-2-15a986a48d0a
You need to edit a file and move it to /etc/nginx/conf.d/
You can use a script or no but you need to launch the service using the command nginx -g daemon off
Make sure that you don't enable connexion on port 80:80.
- Understanding location block
- Understanding the implementation of fastcgi
- Example of configuration
You need to edit www.conf and place it to /etc/php/7.3(the usual version of php on 42 vm)/fpm/pool.d and wp-content.php to disable access wordpress installation page when you access your site at https://login.42.fr
You can launch the service with /usr/sbin/php-fpm7.3 (or another version if you don't use 42 vm) -F
Once you have successfully enable the connexion with wordpress and can launch the installation via the installation page you can create your 2 users (admin will be the first user you enter via the installation page and the second will be created via the dashbord and have the role of editor for example). You can add articles, change the color of the background, ... etc
You can then import it via a file.sql : https://www.interserver.net/tips/kb/import-export-databases-mysql-command-line/
You can launch the service with mysqld
- Setting up mariadb
https://www.digitalocean.com/community/tutorials/comment-installer-mysql-sur-ubuntu-18-04-fr
- Understand how to let mariadb communicate with the outside world and be able to communicate with wordpress
https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql
Overall tutorial well explained:
- https://tech.osteel.me/posts/docker-for-local-web-development-part-1-a-basic-lemp-stack
- https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose
- https://medium.com/rate-engineering/using-docker-containers-to-run-a-distributed-application-locally-eeabd360bca3
- To connect to mysql remotely and force root to enter a password you can type in your VM shell :
mysql -h 127.0.0.1 -u root (the connexion will be refused)
mysql -h 127.0.0.1 -u root -p (you will need to enter your password)
- To connect to mysql remotely using your database user:
mysql -h 127.0.0.1 -u llescure -p (you will need to enter your password)
- To show that the database is not empty:
show databases;
use wordpress (name of your dabatabse);
show tables;
- Why 127.0.0.1 ?
Because you set your server on 127.0.0.1 on /etc/hosts if your remember correctly
https://www.educative.io/blog/docker-compose-tutorial
https://cloud.google.com/architecture/best-practices-for-building-containers
Overall the documentation provided by digital ocean is well documented and available in french