All articles

LAMP Docker Environment

Customizing Your Docker LAMP Environment: A Step-by-Step Guide.

This Docker LAMP environment is an excellent choice for local development, as it provides the necessary tools and configurations for PHP and frontend development. With the ability to set up multiple local websites and configure the versions of PHP, MySQL, or Node, this environment provides flexibility and ease of use. In this article, we will explore the features of this Docker LAMP environment and guide you through setting up your own local development environment. Let’s dive in!

This Docker LAMP environment has recently been updated to include PHP 8.2 and the latest versions of MySQL / MariaDB. It comes with pre-installed tools lik, phpMyAdmin, and xDebug, as well as support for Redis, many PHP extensions, and easy configuration of virtual hosts and HTTPS/SSL.

GitHub Repository

LAMP Docker - local development

Credit: this Docker LAMP environment is a fork and an improved version of the original work by SprintCube.

Setup

First, clone the Docker LAMP repository onto your local computer using the following command in your terminal:

text
git clone https://github.com/danielefavi/lamp-docker.git

Then open the project folder and duplicate the file .env.example and renaming it as .env.

This file is used to define various environment variables and is responsible for configuring your Docker containers. Within the .env file, you can customize your Docker LAMP environment by choosing the PHP version (from PHP v5.4 up to v8.2), the database version (with many versions of MySQL or MariaDB), and other server configurations. Additionally, there are many other configuration options available within the .env file, making it easy to tailor the environment to your specific needs. 

Once you have customized your environment using the .env file, run the following command to start the Docker containers and bring up your LAMP stack:

text
docker compose up -d

Once the containers are up and running, you can access your local website by visiting http://localhost in your web browser.

Other Configurations

Additionally, adding new virtual hosts to your Docker LAMP environment is a breeze. Simply modify the config/vhosts/default.conf file to add your new virtual host configuration. The Docker LAMP environment also supports HTTPS/SSL, making it easy to test your secure web applications. With these features and more, the Docker LAMP environment provides a robust and flexible local development environment for your web applications.

Conclusion

Using Docker LAMP environments is an effective way to develop and test web applications locally before deploying them to a production environment. With this Docker LAMP environment, you can easily set up and customize your development environment by configuring the .env file. By providing pre-installed tools like Apache, phpMyAdmin, and xDebug, as well as support for Redis and many PHP extensions, this environment can help you streamline your development workflow. Whether you’re a beginner or an experienced web developer, using Docker LAMP environments can help you save time and ensure your web applications are reliable and performant.

Related articles

PHP

Laravel Metadata

Laravel Metadata is a PHP package that helps you to handle extra data on your models without adding any new fields on your database table.

Read
AI

A Coding Partner Who Knows Everything About Your Code

What if you could have a coding partner who knew every single line of code in your project? Well, I have been developing a tool that does exactly that. It uses a AI technique, such as RAG, allowing you to ask complex questions and get immediate answers.

Read