Skip to content

This project aims to broaden your knowledge of system administration by using Docker. You will virtualize several Docker images, creating them in your new personal virtual machine

Notifications You must be signed in to change notification settings

mouaammou/inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

inception

This project aims to broaden your knowledge of system administration by using Docker. You will virtualize several Docker images, creating them in your new personal virtual machine

about this project

The Inception 42 project is part of the curriculum at 42, a well-known programming school. This project is designed to expand students' knowledge of system administration using Docker. The main objective is to set up a small infrastructure composed of a WordPress site running on a LEMP stack (Linux, Nginx, MariaDB, PHP) within Docker containers. The project involves using Docker Compose to orchestrate the containers, ensuring they work together seamlessly​

Understanding the Configuration of PHP, WordPress, Nginx, and MariaDB

To understand why configuring PHP, WordPress, Nginx, and MariaDB is necessary, let's break down the roles each component plays and how they interact with each other.

1. PHP (Hypertext Preprocessor)

Role: PHP is a server-side scripting language designed for web development. It is embedded within HTML and interacts with databases to generate dynamic web pages.

Relation to WordPress: WordPress is built on PHP. When a user accesses a WordPress site, PHP scripts are executed on the server to fetch data from the database (such as posts, user information, etc.) and render it as HTML, which is then sent to the user's browser.

2. WordPress

Role: WordPress is a content management system (CMS) that allows users to create, manage, and modify content on a website without needing to code.

Relation to PHP: WordPress uses PHP to execute its core functionalities, plugins, and themes. The PHP scripts in WordPress handle tasks such as querying the database, processing form data, and rendering web pages.

Relation to MariaDB: WordPress stores all its content, user data, settings, and more in a database. MariaDB (or MySQL) is the database management system that WordPress uses to store and retrieve this data. PHP scripts in WordPress use SQL queries to interact with the MariaDB database.

3. Nginx

Role: Nginx is a web server that serves static content (HTML, CSS, JavaScript, images) and acts as a reverse proxy for handling dynamic content generated by PHP scripts.

Relation to PHP: Nginx does not process PHP scripts by itself. Instead, it passes requests for PHP scripts to PHP-FPM (FastCGI Process Manager), which executes the scripts and returns the output to Nginx. Nginx then sends this output to the user's browser.

Relation to WordPress: When a user requests a WordPress page, Nginx receives the request. If the request is for a PHP file (such as index.php), Nginx forwards it to PHP-FPM. PHP-FPM processes the PHP script, which interacts with the MariaDB database if needed, and returns the generated HTML back to Nginx. Nginx then serves this HTML to the user.

4. MariaDB

Role: MariaDB is an open-source relational database management system (RDBMS) that stores data in a structured format using tables.

Relation to WordPress: WordPress uses MariaDB to store all its data, including posts, pages, user information, and site settings. When a PHP script in WordPress needs to retrieve or update data, it sends an SQL query to the MariaDB database.

Relation to PHP: PHP scripts in WordPress use the mysqli or PDO_MySQL extensions to connect to and interact with the MariaDB database. These extensions enable PHP to send SQL queries to MariaDB and handle the responses.

Why Configuration is Necessary

  • PHP Configuration: Ensures that PHP is set up correctly to execute WordPress scripts efficiently. This includes installing necessary extensions (like php-mysql for database interaction) and setting appropriate values for PHP directives (such as memory_limit, upload_max_filesize, etc.) to handle the requirements of WordPress.

  • Nginx Configuration: Involves setting up Nginx to properly forward PHP requests to PHP-FPM and handle static content. This configuration ensures that PHP scripts are executed and their output is correctly served to users.

  • MariaDB Configuration: Ensures that the database is set up and optimized to store and retrieve WordPress data efficiently. This includes setting up user accounts, privileges, and database settings that match the needs of the WordPress installation.

Example Workflow

  1. User Request: A user visits yourdomain.com and requests the homepage.
  2. Nginx Handling: Nginx receives the request and sees that it needs to process index.php.
  3. PHP-FPM Processing: Nginx forwards the request to PHP-FPM, which executes the PHP script.
  4. Database Interaction: The PHP script sends an SQL query to MariaDB to fetch the latest blog posts.
  5. Response Generation: MariaDB returns the data to the PHP script, which processes it and generates an HTML response.
  6. Content Delivery: PHP-FPM sends the HTML back to Nginx, which serves it to the user's browser.

Docker Networking

Docker networking allows containers to communicate with each other, with the Docker host, and with external networks. Docker provides several types of networks, each suited to different use cases. Here's a detailed overview of Docker networking:

Docker Network Types

1. Bridge Network

  • Default Network: When you create a container, it is automatically connected to this network unless another network is specified.
  • Isolated Network: Containers on the same bridge network can communicate with each other, but are isolated from containers on other bridge networks.
  • Use Case: Useful for single-host setups where containers need to communicate.

2. Host Network

  • Network Sharing: The container shares the host's networking namespace, meaning it will have the same IP address as the host.
  • No Isolation: There is no network isolation between the container and the host.
  • Use Case: Suitable for scenarios where performance is critical, and network isolation is not needed.

3. Overlay Network

  • Multi-Host Communication: Enables communication between containers across multiple Docker hosts.
  • Swarm Mode: Primarily used in Docker Swarm for creating a multi-host overlay network.
  • Use Case: Ideal for distributed systems and microservices running on a cluster of Docker hosts.

4. Macvlan Network

  • Direct Network Access: Assigns a MAC address to each container, making it appear as a physical device on the network.
  • Fine-Grained Control: Allows for more control over network topologies and is useful when you need containers to look like physical devices on the network.
  • Use Case: Suitable for legacy applications that require direct network access.

5. None Network

  • No Networking: Containers do not have any network interfaces and cannot communicate over the network.
  • Use Case: Useful for running containers that do not require network connectivity.

About

This project aims to broaden your knowledge of system administration by using Docker. You will virtualize several Docker images, creating them in your new personal virtual machine

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published