The “ depends_on” directive instructs our PHP container to wait until MariaDB has been started. RUN docker-php-ext-install mysqli pdo pdo_mysql gd zip # Installing dependencies for the PHP modulesĪpt-get install -y zip libzip-dev libpng-dev So, create a file named “ php-dockerfile” in the “lemp” directory with your preferred text editor and add the following content to it: vim php-dockerfile FROM php:8.1-fpm Therefore, we will create a new Docker image based on the official PHP 8.1 one, but additionally, we will compile and include some of the most often-used PHP extensions, such as MySQL, GD, ZIP, and so on. Unfortunately, they are, in most cases, insufficient for the applications we aim to develop. The answer is simple: the official image includes a limited set of preinstalled PHP extensions. You may be asking why we need to build our own Docker image for PHP instead of using one already available on Docker Hub. This is because we will be building our own, the instructions for which can be found in the “php-dockerfile” file. The key point here is the “ build” directive, which states, “ dockerfile: php-dockerfile.”Īs you can see, there is no path to a Docker image here. We’ll begin with PHP, the first service in our “docker-compose.yml” file. We’ll go through it in more detail below. Don’t be worried if something in its contents is unclear to you. We use an arbitrary name for the main directory, such as “ lemp.” It will store all the files required for the setup, so let’s create it. The final version should look like the one shown below, and we’ll now explain what each file and directory represents. Let’s begin by creating the directory structure to house the files required to set up Nginx, MariaDB, and PHP with Docker Compose. Then, you can use a single command such as “ docker-compose up” to start all the containers and link them together. To use it, you must first create a “ docker-compose.yml” file that configures the containers for your application. In other words, it is a tool for defining and running multi-container Docker applications. Set Up Nginx, MariaDB, and PHP with Docker Composeĭocker Compose allows you to build and run stacks of multiple containers. docker-compose versionĮverything seems fine, so let’s get to the actual part. You should receive a response similar to the one shown. Next, run the command below to ensure that Docker Compose is installed and functioning correctly. Sudo chmod +x /usr/local/bin/docker-compose Type the following commands: sudo curl -L "$(uname -m)" -o /usr/local/bin/docker-compose Therefore, you must Install Docker before adding Docker Compose otherwise, Compose will not function.įortunately, even if it is not already on your Linux system, installing it is pretty simple. Remember, it is provided separately from Docker. The other essential component is Docker Compose. How to Install Docker on AlmaLinux / Rocky Linux.How to Install Docker on Debian 11 (Bullseye).So, if you don’t already have Docker installed, any of the following guides may be helpful: Of course, having Docker and Docker Compose installed is required to deploy a containerized LEMP stack. So without further ado, let’s get to work. In addition, we’ll add the popular web-based application phpMyAdmin to the LEMP stack to manage your MySQL/MariaDB database. This guide will show you how to quickly and easily integrate Nginx, MariaDB, and PHP using Docker Compose. With its help, you can have your LEMP stack up and running in minutes and focus entirely on developing web apps without wasting time installing and configuring services.īut if you still prefer to take the traditional approach and install the LEMP stack from the native packages for the distro you are using, our tutorials for Ubuntu, Debian, Rocky Linux, and AlmaLinux will help you do it effortlessly. This is where Docker containers, specifically Docker Compose, come in. However, installing and configuring all of these services takes time and skills. In addition, it is widely popular and well-supported among the Open Source community. It is an acronym representing Linux, Nginx, MySQL/MariaDB, and PHP. The LEMP stack is an open-source solution used to develop web applications. They are popular among software developers due to their flexibility and portability. When it comes to application development, containers are now the standard approach. This guide shows you how to set up your LEMP (Nginx, MariaDB, PHP) stack easily and quickly using Docker Compose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |