Setup project with PHP Docker Boilerplate

Setup php project with Docker Boilerplate photo
Photo by @yakobusan Jakob Montrasio 孟亚柯
Deploying the first PHP project with Docker can be very difficult. With the PHP Docker Boilerplate you will get a running System in some minutes ready to use without without any hassles – PHP, Apache, Nginx, MySQL, Postgres, Mail, Solr, Elasticsearch…. all services running within ome minutes.

The first requirement for running PHP Docker Boilerplate is a native Linux or a Linux VM with Docker and you should also use git.

First jump into the Linux VM with SSH, clone the Docker Boilerplate into a directory and jump into this directory:

Now edit the docker-compose.yml and docker-env.yml for your needs – eg. if you want special services or different UIDs/GIDs.

After this setup you can startup the Docker containers:

If this was your first docker-compose up then the Docker container will be downloaded and the provisioning will be started (~5-15 minutes). After downloading and provisioning the Docker containers will be started and you can access the webserver with http://linux-ip:8000/ – now your Docker Boilerplate is running even if you get an access error from the webserver.

If you want to try the running PHP-FPM create a code/index.php:

refresh your web browser and you should get the PHP info page.

To deploy your own project delete the code/ directory and clone your own project into this directory. You don’t need to restart the Docker containers because this directory is directly mounted into the containers and all changes are immediately visible. Both, the webserver (web container) and PHP-FPM (main container), will get the mounted code/ directory.

For MySQL connection use:

Hostname: mysql
Username: dev
Password: dev
Database: database

These variables are editable in docker-env.yml. If you change these settings after first startup you need to destroy your MySQL container volume data with docker-compose rm mysql because MySQL provisioning is only done once.


Congratulations – your PHP Docker Boilerplate is running!

Tagged in:, ,
I'm working as DevOps (software developer and linux administrator) in a TYPO3 agency in Stuttgart. I love OpenSource technologies like Linux and PHP and I'm want to share knowledge and experience.


Leave a Reply