PHP 8 development environment with PHP-FPM, Nginx and MySQL, using Docker and Docker Compose.
You need to have Docker and Docker Compose installed on your server to proceed using this PHP environment.
The following three separate service containers will be used:
app
service running PHP 8 FPM.db
service running MySQL.nginx
service that uses the app
service to parse PHP code before serving the application to the final user.Set the MySQL environment variables creating a .env
file based on the .env.example
file.
Build the app image with the following command:
docker-compose build app
docker-compose up -d
docker-compose ps
You can use the docker-compose exec
command to execute commands in the service containers, such as an ls -l
to show detailed information about files in the application directory:
docker-compose exec app ls -l
Now go to your browser and access your server’s domain name or IP address on port 8000
: http://server_domain_or_IP:8000
. In case you are running this demo on your local machine, use http://localhost:8000
to access the application from your browser.
You can use the logs command to check the logs generated by your services:
docker-compose logs nginx
docker-compose pause
docker-compose unpause
docker-compose down