1
1
# Nginx PHP MySQL
2
2
3
- Docker running Nginx, PHP-FPM, MySQL and PHPMyAdmin.
4
-
5
- ** THIS ENVIRONMENT SHOULD ONLY BE USED FOR DEVELOPMENT!**
6
-
7
- ** DO NOT USE IT IN PRODUCTION!**
3
+ Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.
8
4
9
5
## Images to use
10
6
@@ -20,51 +16,87 @@ Docker running Nginx, PHP-FPM, MySQL and PHPMyAdmin.
20
16
1 . Download it :
21
17
22
18
``` sh
23
- $ git clone https://github.com/nanoninja/docker-nginx-php-mysql.git
24
- $ cd docker-nginx-php-mysql
19
+ git clone https://github.com/nanoninja/docker-nginx-php-mysql.git
20
+
21
+ cd docker-nginx-php-mysql
25
22
```
26
23
27
24
2. Copying the composer configuration file :
28
25
29
26
` ` ` sh
30
- # Convenient to avoid overwriting the configuration with Git.
31
- $ cp web/app/composer.json.dist web/app/composer.json
27
+ cp web/app/composer.json.dist web/app/composer.json
32
28
` ` `
33
29
34
- 3. Run :
30
+ 3. Start :
35
31
36
32
` ` ` sh
37
- $ docker-compose up -d
33
+ docker-compose up -d
38
34
` ` `
39
35
36
+ ** Please wait this might take a several minutes...**
37
+
40
38
4. Open your favorite browser :
41
39
42
40
* [http://localhost:8000](http://localhost:8000/)
43
41
* [https://localhost:3000](https://localhost:3000/) ([HTTPS](https://github.com/nanoninja/docker-nginx-php-mysql#generating-ssl-certificates) not configured by default)
44
42
* [phpMyAdmin](http://localhost:8080/) (user: dev, pass: dev)
45
43
44
+ 5. Stop :
45
+
46
+ ` ` ` sh
47
+ docker-compose stop
48
+ docker-compose kill
49
+ docker-compose rm -f
50
+ ` ` `
51
+
52
+ # # Using Makefile
53
+
54
+ When developing, you can use the Makefile for doing the following operations :
55
+
56
+ # ## Makefile
57
+
58
+ | Name | Description |
59
+ | ---------------| -----------------------------------|
60
+ | apidoc | Generate documentation of API |
61
+ | clean | Clean directories for reset |
62
+ | composer-up | Update php composer |
63
+ | docker-start | Create and start containers |
64
+ | docker-stop | Stop all services |
65
+ | docker-sweep | Sweep old containers and volumes |
66
+ | gen-certs | Generate SSL certificates |
67
+ | mysql-dump | Create backup of whole database |
68
+ | mysql-restore | Restore backup from whole databas |
69
+ | test | Test application |
70
+
46
71
# # Directory tree
47
72
48
73
` ` ` sh
74
+ .
75
+ ├── Makefile
49
76
├── README.md
50
77
├── bin
51
- │ └── linux
52
- │ └── clean.sh
78
+ │ └── linux
79
+ │ └── clean.sh
80
+ ├── data
81
+ │ └── db
82
+ │ └── mysql
53
83
├── docker-compose.yml
54
84
├── etc
55
- │ ├── nginx
56
- │ │ └── default.conf
57
- │ └── php
58
- │ └── php.ini
85
+ │ ├── nginx
86
+ │ │ └── default.conf
87
+ │ ├── php
88
+ │ │ └── php.ini
89
+ │ └── ssl
59
90
└── web
60
91
├── app
61
- │ ├── composer.json.dist
62
- │ ├── phpunit.xml.dist
63
- │ ├── src
64
- │ │ └── Foo.php
65
- │ └── test
66
- │ ├── FooTest.php
67
- │ └── bootstrap.php
92
+ │ ├── composer.json
93
+ │ ├── composer.json.dist
94
+ │ ├── phpunit.xml.dist
95
+ │ ├── src
96
+ │ │ └── Foo.php
97
+ │ └── test
98
+ │ ├── FooTest.php
99
+ │ └── bootstrap.php
68
100
└── public
69
101
└── index.php
70
102
` ` `
@@ -81,50 +113,44 @@ Docker running Nginx, PHP-FPM, MySQL and PHPMyAdmin.
81
113
# # Updating composer
82
114
83
115
` ` ` sh
84
- $ docker run --rm -v $( pwd ) /web/app:/app -v ~ /.ssh:/root/.ssh composer/composer update
116
+ docker run --rm -v $( PWD ) /web/app:/app composer/composer update
85
117
` ` `
86
118
87
119
# # MySQL Container shell access
88
120
89
121
` ` ` sh
90
- $ docker exec -it mysql bash
122
+ docker exec -it mysql bash
91
123
` ` `
92
124
93
125
and
94
126
95
127
` ` ` sh
96
- $ mysql -uroot -proot
128
+ mysql -uroot -proot
97
129
` ` `
98
130
99
131
# # Creating database dumps
100
132
101
133
` ` ` sh
102
- $ docker exec mysql sh -c ' exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > /some/path/on/your/host/all-databases .sql
134
+ source .env && docker exec -i $( docker-compose ps -q mysqldb ) mysqldump --all-databases -u " $MYSQL_ROOT_USER " -p" $MYSQL_ROOT_PASSWORD " > " $MYSQL_DUMPS_DIR /db .sql"
103
135
` ` `
104
136
105
137
or
106
138
107
139
` ` ` sh
108
- $ docker exec mysql sh -c ' exec mysqldump dbname -uroot -p"$MYSQL_ROOT_PASSWORD"' > /some/path/on/your/host/dbname.sql
109
- ` ` `
110
-
111
- # ## Example
112
-
113
- ` ` ` sh
114
- $ docker exec mysql sh -c ' exec mysqldump test -uroot -p"$MYSQL_ROOT_PASSWORD"' > $( pwd) /data/db/dumps/test.sql
140
+ source .env && docker exec -i $( docker-compose ps -q mysqldb) mysqldump test -u" $MYSQL_ROOT_USER " -p" $MYSQL_ROOT_PASSWORD " > " $MYSQL_DUMPS_DIR /test.sql"
115
141
` ` `
116
142
117
143
# # Generating SSL certificates
118
144
119
145
1. Generate certificates
120
146
121
147
` ` ` sh
122
- $ docker run --rm -v $( pwd ) /etc/ssl:/certificates -e " SERVER=localhost" jacoelho/generate-certificate
148
+ docker run --rm -v $( PWD ) /etc/ssl:/certificates -e " SERVER=localhost" jacoelho/generate-certificate
123
149
` ` `
124
150
125
151
2. Configure Nginx
126
152
127
- Edit nginx file ** etc/nginx/default.conf** and uncomment the server section.
153
+ Edit nginx file ** etc/nginx/default.conf** and uncomment the server section :
128
154
129
155
` ` ` nginx
130
156
# server {
@@ -135,11 +161,11 @@ $ docker exec mysql sh -c 'exec mysqldump test -uroot -p"$MYSQL_ROOT_PASSWORD"'
135
161
# # Generating API Documentation
136
162
137
163
` ` ` sh
138
- ./web/ app/vendor/apigen/apigen/bin/apigen generate -s web/ app/src -d web/ app/doc
164
+ docker exec -i $( docker-compose ps -q php ) php ./ app/vendor/apigen/apigen/bin/apigen generate -s app/src -d app/doc
139
165
` ` `
140
166
141
167
# # Cleaning project
142
168
143
169
` ` ` sh
144
- $ ./bin/linux/clean.sh $( pwd)
170
+ ./bin/linux/clean.sh $( pwd)
145
171
` ` `
0 commit comments