Hello 👋,
In this month’s blog post I’ll show you how to run a PHP Application inside a container.
I’m quite a fan of online forums and the majority of forum software is written in PHP. To evaluate them quickly I wanted the ability to be able to run and install then locally.
I’ve come up with this docker-compose file
| |
All you need to do is place the PHP application inside the ./application directory and run:
| |
The file will set up the following components:
- php - The PHP runtime.
- nginx - The Nginx web server used to serve requests. You can customize it by editing
./config/nginx/conf.d/default.conf - database - Runs a PostgresSQL database which persists data inside the local
./.datadirectory. - maria - Runs a MariaDB database which persists data inside the local
./.datadirectory.
It’s unlikely that you need both databases running at the same time, feel free to delete the one you don’t need. Some PHP Applications work with PostgresSQL and some work only with MariaDB/MySQL.
Thank you for reading, if you have any questions please do reach out on @mastodon.
By the way, I’m using this method to host my forum.
The full code is available on forge: https://forge.nuculabs.dev/dnutiu/containerized-php-application




