Skip to content

Commit 974e347

Browse files
committed
1.optimize log and conf dir; 2.use network instead of link
1 parent e09423c commit 974e347

20 files changed

+187
-139
lines changed
File renamed without changes.

conf/nginx/conf.d/site1.conf conf/conf.d/site1.conf

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ server {
44
root /var/www/html/site1;
55
index index.php index.html index.htm;
66
#charset koi8-r;
7-
#access_log /var/log/nginx/log/host.access.log main;
8-
7+
8+
access_log /dev/null;
9+
#access_log /var/log/dnmp/nginx.site1.access.log main;
10+
error_log /var/log/dnmp/nginx.site1.error.log warn;
11+
912
#error_page 404 /404.html;
1013

1114
# redirect server error pages to the static page /50x.html
@@ -24,7 +27,7 @@ server {
2427
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
2528
#
2629
location ~ \.php$ {
27-
fastcgi_pass fpm:9000;
30+
fastcgi_pass php:9000;
2831
fastcgi_index index.php;
2932
include fastcgi_params;
3033
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

conf/nginx/conf.d/site2.conf conf/conf.d/site2.conf

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ server {
1111
root /var/www/html/site2;
1212
index index.php index.html index.htm;
1313
#charset koi8-r;
14-
#access_log /var/log/nginx/log/host.access.log main;
14+
15+
access_log /dev/null;
16+
#access_log /var/log/dnmp/nginx.site2.access.log main;
17+
error_log /var/log/dnmp/nginx.site2.error.log warn;
1518

1619
#error_page 404 /404.html;
1720

@@ -39,7 +42,7 @@ server {
3942
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
4043
#
4144
location ~ \.php$ {
42-
fastcgi_pass fpm:9000;
45+
fastcgi_pass php:9000;
4346
fastcgi_index index.php;
4447
include fastcgi_params;
4548
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

conf/mysql/my.cnf conf/my.cnf

+4-6
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ sort_buffer_size = 8M
4545
join_buffer_size = 8M
4646
thread_cache_size = 64
4747
innodb_thread_concurrency = 4
48-
query_cache_size =128M
49-
query_cache_limit = 2M
5048
default-storage-engine = InnoDB
5149

5250
character-set-server = utf8mb4
@@ -60,14 +58,14 @@ tmp_table_size = 64M
6058
table_open_cache = 2048
6159
datadir = /var/lib/mysql
6260
tmpdir = /tmp
63-
lc-messages-dir = /usr/share/mysql
6461
explicit_defaults_for_timestamp
62+
secure_file_priv=""
6563

6664
# *** log config***
6765
slow_query_log
6866
long_query_time = 2
69-
# log-slow-queries = /var/log/mysql/mysql-slow.log
70-
slow-query-log-file = /var/log/mysql/mysql-slow.log # 5.6+
67+
# log-slow-queries = /var/log/dnmp/mysql.slow.log
68+
slow-query-log-file = /var/log/dnmp/mysql.slow.log # 5.6+
7169
log-queries-not-using_indexes
7270

7371
# *** myisam Specific options ***
@@ -87,7 +85,7 @@ myisam_recover_options
8785
[mysqldump]
8886
quick
8987
max_allowed_packet = 16M
90-
log-error = /var/log/mysql/error.log
88+
log-error = /var/log/dnmp/mysql.error.log
9189

9290
# Recommended in standard MySQL setup
9391
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

conf/nginx/nginx.conf conf/nginx.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
user nginx;
33
worker_processes 1;
44

5-
error_log /var/log/nginx/error.log warn;
65
pid /var/run/nginx.pid;
7-
6+
error_log /var/log/dnmp/nginx.error.log warn;
87

98
events {
109
worker_connections 1024;
@@ -19,7 +18,8 @@ http {
1918
'$status $body_bytes_sent "$http_referer" '
2019
'"$http_user_agent" "$http_x_forwarded_for"';
2120

22-
access_log /var/log/nginx/access.log main;
21+
access_log /dev/null;
22+
#access_log /var/log/dnmp/nginx.access.log main;
2323

2424
sendfile on;
2525
#tcp_nopush on;

conf/php/php-fpm.d/www.conf conf/php-fpm.d/www.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ pm.max_spare_servers = 3
359359
; Note: on highloaded environement, this can cause some delay in the page
360360
; process time (several ms).
361361
; Default Value: no
362-
;catch_workers_output = yes
362+
catch_workers_output = yes
363363

364364
; Clear environment in FPM workers
365365
; Prevents arbitrary environment variables from reaching FPM worker processes
@@ -408,6 +408,6 @@ pm.max_spare_servers = 3
408408
; specified at startup with the -d argument
409409
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
410410
;php_flag[display_errors] = off
411-
;php_admin_value[error_log] = /var/log/fpm-php.www.log
412-
;php_admin_flag[log_errors] = on
411+
php_admin_value[error_log] = /var/log/dnmp/php.fpm.error.log
412+
php_admin_flag[log_errors] = on
413413
;php_admin_value[memory_limit] = 32M

conf/php/php.ini conf/php.ini

File renamed without changes.

docker-compose.yml

+54-38
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
1-
nginx:
2-
image: nginx:alpine
3-
ports:
4-
- "80:80"
5-
- "443:443"
6-
volumes:
7-
- ./www/:/var/www/html/:rw
8-
- ./conf/nginx/conf.d:/etc/nginx/conf.d/:ro
9-
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
10-
- ./log/nginx/:/var/log/nginx/:rw
11-
links:
12-
- php72:fpm
1+
version: "3"
2+
services:
3+
nginx:
4+
image: nginx:alpine
5+
container_name: dnmp-nginx
6+
ports:
7+
- "80:80"
8+
- "443:443"
9+
volumes:
10+
- ./www/:/var/www/html/:rw
11+
- ./conf/conf.d:/etc/nginx/conf.d/:ro
12+
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
13+
- ./log/:/var/log/dnmp/:rw
14+
networks:
15+
- net-php
1316

14-
php72:
15-
build: ./php/php72/
16-
expose:
17-
- "9000"
18-
volumes:
19-
- ./www/:/var/www/html/:rw
20-
- ./conf/php/php.ini:/usr/local/etc/php/php.ini:ro
21-
- ./conf/php/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
22-
- ./log/php-fpm/:/var/log/php-fpm/:rw
23-
links:
24-
- mysql:mysql
25-
- redis:redis
17+
php:
18+
build: ./php/php72/
19+
container_name: dnmp-php
20+
expose:
21+
- "9000"
22+
volumes:
23+
- ./www/:/var/www/html/:rw
24+
- ./conf/php.ini:/usr/local/etc/php/php.ini:ro
25+
- ./conf/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
26+
- ./log/:/var/log/dnmp/:rw
27+
networks:
28+
- net-php
29+
- net-mysql
30+
- net-redis
2631

27-
mysql:
28-
image: mysql:latest
29-
ports:
30-
- "3306:3306"
31-
volumes:
32-
- ./conf/mysql/my.cnf:/etc/mysql/my.cnf:ro
33-
- ./mysql/:/var/lib/mysql/:rw
34-
- ./log/mysql/:/var/log/mysql/:rw
35-
environment:
36-
MYSQL_ROOT_PASSWORD: "123456"
32+
mysql:
33+
image: mysql:latest
34+
container_name: dnmp-mysql
35+
ports:
36+
- "3306:3306"
37+
volumes:
38+
- ./conf/my.cnf:/etc/mysql/my.cnf:ro
39+
- ./mysql/:/var/lib/mysql/:rw
40+
- ./log/:/var/log/dnmp/:rw
41+
networks:
42+
- net-mysql
43+
environment:
44+
MYSQL_ROOT_PASSWORD: "123456"
3745

38-
redis:
39-
image: redis:latest
40-
ports:
41-
- "6379:6379"
46+
redis:
47+
image: redis:latest
48+
container_name: dnmp-redis
49+
networks:
50+
- net-redis
51+
ports:
52+
- "6379:6379"
53+
54+
networks:
55+
net-php:
56+
net-mysql:
57+
net-redis:

docker-compose54.yml

+54-38
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
1-
nginx:
2-
image: nginx:alpine
3-
ports:
4-
- "80:80"
5-
- "443:443"
6-
volumes:
7-
- ./www/:/var/www/html/:rw
8-
- ./conf/nginx/conf.d:/etc/nginx/conf.d/:ro
9-
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
10-
- ./log/nginx/:/var/log/nginx/:rw
11-
links:
12-
- php54:fpm
1+
version: "3"
2+
services:
3+
nginx:
4+
image: nginx:alpine
5+
container_name: dnmp-nginx
6+
ports:
7+
- "80:80"
8+
- "443:443"
9+
volumes:
10+
- ./www/:/var/www/html/:rw
11+
- ./conf/conf.d:/etc/nginx/conf.d/:ro
12+
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
13+
- ./log/:/var/log/dnmp/:rw
14+
networks:
15+
- net-php
1316

14-
php54:
15-
build: ./php/php54/
16-
expose:
17-
- "9000"
18-
volumes:
19-
- ./www/:/var/www/html/:rw
20-
- ./conf/php/php.ini:/usr/local/etc/php/php.ini:ro
21-
- ./conf/php/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
22-
- ./log/php-fpm/:/var/log/php-fpm/:rw
23-
links:
24-
- mysql:mysql
25-
- redis:redis
17+
php:
18+
build: ./php/php54/
19+
container_name: dnmp-php
20+
expose:
21+
- "9000"
22+
volumes:
23+
- ./www/:/var/www/html/:rw
24+
- ./conf/php.ini:/usr/local/etc/php/php.ini:ro
25+
- ./conf/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
26+
- ./log/:/var/log/dnmp/:rw
27+
networks:
28+
- net-php
29+
- net-mysql
30+
- net-redis
2631

27-
mysql:
28-
image: mysql:latest
29-
ports:
30-
- "3306:3306"
31-
volumes:
32-
- ./conf/mysql/my.cnf:/etc/mysql/my.cnf:ro
33-
- ./mysql/:/var/lib/mysql/:rw
34-
- ./log/mysql/:/var/log/mysql/:rw
35-
environment:
36-
MYSQL_ROOT_PASSWORD: "123456"
32+
mysql:
33+
image: mysql:latest
34+
container_name: dnmp-mysql
35+
ports:
36+
- "3306:3306"
37+
volumes:
38+
- ./conf/my.cnf:/etc/mysql/my.cnf:ro
39+
- ./mysql/:/var/lib/mysql/:rw
40+
- ./log/:/var/log/dnmp/:rw
41+
networks:
42+
- net-mysql
43+
environment:
44+
MYSQL_ROOT_PASSWORD: "123456"
3745

38-
redis:
39-
image: redis:latest
40-
ports:
41-
- "6379:6379"
46+
redis:
47+
image: redis:latest
48+
container_name: dnmp-redis
49+
networks:
50+
- net-redis
51+
ports:
52+
- "6379:6379"
53+
54+
networks:
55+
net-php:
56+
net-mysql:
57+
net-redis:

0 commit comments

Comments
 (0)