|
1 | | -Nginx + Php-fpm + Apache + MySQL + NodeJS + phpMyAdmin with Docker-Compose |
| 1 | +nginx + PHP-FPM + Apache + MySQL + NodeJS + phpMyAdmin with Docker-Compose |
2 | 2 | ========================================================================== |
3 | 3 |
|
4 | 4 | Initial configuration to install a web environment with the following images: |
5 | 5 |
|
6 | | -- nginx: it will be running as a reverse-proxy for Apache; the static data (images, texts, js scripts, etc) will be |
7 | | -returned by nginx itself |
8 | | -- Php-fpm 7.2: it will install `composer` and try to run it with `composer install` |
9 | | -- Apache (httpd): it will be proxying the requests to PHP-FPM |
10 | | -- MySQL 8: default access credentials are defined in `.env` file incl. the root password |
11 | | -- NodeJS: will try to run `npm run dev` or `npm run dev` depending on the settings defined in `.env` file |
12 | | -- phpMyAdmin: it will be available on the port `5426`, e.g. `http://localhost:5426` |
| 6 | +- nginx: reverse-proxy for Apache and PhpMyAdmin |
| 7 | +- PHP-FPM 8.2 with `composer` |
| 8 | +- Apache (httpd): as a proxy for requests to PHP-FPM |
| 9 | +- MySQL 8: default access credentials are defined in `.env` file |
| 10 | +- NodeJS 21 |
| 11 | +- phpMyAdmin 5.2: it will be available on the port `81`, e.g. `http://localhost:81` |
13 | 12 |
|
14 | | -## Prerequisites |
| 13 | +## Installation |
15 | 14 |
|
16 | | -Please make sure docker & docker-compose are installed on the target machine. |
| 15 | +### Prerequisites |
17 | 16 |
|
18 | | -If you are not sure, please run the following command (Ubuntu): |
19 | | - |
20 | | -``` |
21 | | -sudo apt-get install docker docker-compose -y |
22 | | -``` |
23 | | - |
24 | | -## Initial Settings |
25 | | - |
26 | | -Navigate to the root directory and open `.env` file for editing: |
27 | | - |
28 | | -``` |
29 | | -# App Settings |
30 | | -APP_NAME=docker |
31 | | -APP_PATH=./app |
32 | | -# To launch the app in dev environment just remove prod |
33 | | -APP_ENV=prod |
34 | | -``` |
35 | | - |
36 | | -## Run Docker-Compose |
37 | | - |
38 | | -To build the images and run the configuration please navigate to the root directory and run the following command |
| 17 | +- Docker 24.0 |
| 18 | +- Docker Compose 2.22 |
39 | 19 |
|
40 | | -``` |
41 | | -docker-compose up -d --build |
42 | | -``` |
| 20 | +### Build and Run |
43 | 21 |
|
44 | | -Remove option `-d` if you don't want to run it in the detached mode. |
| 22 | +1. Run `make build` to build the Docker images |
| 23 | +2. Run `make up` to run the Docker containers |
45 | 24 |
|
46 | | -If the images are already built just run the following command |
| 25 | +All the commands above can be run with one command: |
47 | 26 |
|
48 | 27 | ``` |
49 | | -docker-compose up -d |
| 28 | +make build && make up |
50 | 29 | ``` |
51 | 30 |
|
52 | | -Docker Management |
53 | | ------------------ |
54 | | - |
55 | | -### Start Docker containers |
56 | | - |
57 | | -When the containers are built you can start the containers by using the following command |
58 | | - |
59 | | -`docker-compose up` OR `docker-compose up -d` for the _detached_ mode. |
60 | | - |
61 | | -### Stop Docker containers |
62 | | - |
63 | | -To stop Docker containers you can use the following command |
64 | | - |
65 | | -`docker-compose down` |
66 | | - |
67 | | -### Log in to Containers |
68 | | - |
69 | | -To log in to the container you can use one of the following commands |
70 | | - |
71 | | - - NGINX: `docker-compose exec web sh` |
72 | | - |
73 | | - - PHP: `docker-compose exec php sh` |
74 | | - |
75 | | - - APACHE: `docker-compose exec apache sh` |
76 | | - |
77 | | - - MYSQL: `docker-compose exec db sh` |
78 | | - |
79 | | - - NODEJS: `docker-compose exec nodejs sh` |
80 | | - |
81 | | - - PHPMYADMIN: `docker-compose exec phpmyadmin sh` |
| 31 | +As a result, the application will be available at http://localhost/. |
82 | 32 |
|
83 | | -### Troubleshooting |
| 33 | +### Stopping the Application |
84 | 34 |
|
85 | | -- Docker can't run the container on the default port `80`: Please check if there is no other app which uses the same |
86 | | -port on your machine. You can also change the default port for `nginx` in the file `docker-compose.yml`. |
87 | | -- Can't log in to `php` container: Please check all running Docker processes by using the following command |
88 | | -`docker-compose ps`. Check if you are using the correct name. |
| 35 | +To stop the application, run `make down`. |
0 commit comments