Skip to content

Example of a simple application using Docker, Nginx, PHP, MongoDB, Composer

Notifications You must be signed in to change notification settings

dbazhenov/nginx-php-mongodb-docker-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Develop a Simple Web Application Using Docker, Nginx, PHP and MongoDB

The repository contains files for preparing the environment and running a simple PHP script.

The application runs with Nginx + PHP-fpm 8.2 + MongoDB 6, the environment is run with Docker compose. It also uses Composer to include the required MongoDB packages.

The application gets access data from environment variables, connects to the database and writes 1000 documents to the database.

That's it! However, it's a good starting point to do something more.

Installation

  1. Clone the repository and navigate to the project folder.

  2. Run Image build from Dockerfile

docker build -t php8.2-fpm-mongo .
  1. Run docker-compose
docker-compose up -d
  1. Connect to a container with PHP-fpm
docker exec -it [php-fpm-container-name] bash
  1. Install the Composer packages needed for the application (composer.json)
composer install
  1. Open localhost in your browser

  2. Enjoy modifying the index.php script and checking the result by simply reloading the localhost page in your browser

  3. Stop docker-compose after experimenting

docker-compose down

About

Example of a simple application using Docker, Nginx, PHP, MongoDB, Composer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published