I created a LAMP (Linux-Apache-MySQL-PHP) local development environment you can use to develop your web applications.
It is a docker environment. Docker allows you to separate your development environment from your host computer. The web server and the database server are not installed on your host computer. They run in isolation inside your docker containers, so they don’t alter your host computer. Another benefit is that this system is easily portable: you just need to clone the git repository and then start the containers and you are ready to use the development environment. An additional benefit is that you can run for example different versions of PHP in the same machine. More information on Docker benefits and how it works here.
This local development environment for web applications contains:
- the Apache web server with mod_rewrite enabled
- the MySQL database server
- PHP version 7.4
- phpMyAdmin to manage the database
- Mailhog to debug the emails
- Composer version 2
- Git
- Xdebug
- The WordPress CLI
To execute the environment you need docker and docker-compose installed on your system.
You can find this web development environment in the GitHub account of somedevtips.com at the following url: https://github.com/somedevtips/docker-lamp
The git project contains the instructions on how to setup and run the project. The first time you run it, it will take some time because it will have to create the docker image of the webserver from the Docker file and download the other docker images. The following times you’ll have the images already downloaded and built, so it will start much more rapidly.
If you need to tweak the Apache and PHP settings, you can do it, the instructions are in the GitHub repository.
To start the development environment, you will execute the following command:
docker-compose up -d
If you want to use one the provided tools, for example git, composer or the WordPress CLI you will execute the following command:
docker-compose exec -u $USER phpapache bash
With the command you open a shell in web server and PHP container and there you can use the provided tools.
You can manage the database with phpMyAdmin and trap the emails sent by the website with Mailhog: see the GitHub project README file.