设为首页 收藏本站
查看: 1402|回复: 0

[经验分享] FastDFS的php和nginx模块配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-10-8 09:31:07 | 显示全部楼层 |阅读模式
一、FastDFS和php整合
1、安装php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 安装依赖包
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel  openssl openssl-devel openldap openldap-devel nss_ldap openldap_clients

# 安装epel,为了安装libmcrypt等包
yum  install epel-release
yum install libmcrypt libmcrypt-devel mcrypt mhash -y

#下载并解压php源码包
cd /opt/tools
wget http://cn2.php.net/get/php-5.6.26.tar.gz/from/this/mirror
tar -zxf php-5.6.26.tar.gz

#编译安装
cd php-5.6.26
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc  --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql
make && make install



2、生成并配置fastdfs的php模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 进入fastdfs源码解压后的目录
cd /opt/tools/fastdfs-5.05/php_client/
/usr/local/php/bin/phpize

# 测试php安装结果
[iyunv@mylinux3 php_client]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

# 编译并安装fastdfs的php模块
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
[iyunv@mylinux3 php_client]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
total 1992
-rwxr-xr-x 1 root root  340037 Oct  5 17:26 fastdfs_client.so
-rwxr-xr-x 1 root root 1105024 Oct  5 17:13 opcache.a
-rwxr-xr-x 1 root root  586352 Oct  5 17:13 opcache.so



3、编辑php.ini

1
2
3
4
5
cp /opt/tools/php-5.6.26/php.ini-production /usr/locni-production /usr/local/php/etc/php.ini
cd /opt/tools/fastdfs-5.05/php_client
[iyunv@mylinux3 php_client]# ll fastdfs_client.ini
-rw-rw-r-- 1 root root 1403 Nov 22  2014 fastdfs_client.ini
cat fastdfs_client.ini >> /usr/local/php/etc/php.ini



4、测试通过php操作fastdfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
/usr/local/php/bin/php fastdfs_test.php

[iyunv@mylinux3 php_client]# /usr/local/php/bin/php fastdfs_test.php
5.05
fastdfs_tracker_make_all_connections result: 1
array(1) {
  ["group1"]=>
  array(13) {
    ["total_space"]=>
    int(17944)
    ["free_space"]=>
    int(12476)
    ["trunk_free_space"]=>
    int(0)
    ["server_count"]=>
    int(2)
    ["active_count"]=>
    int(2)
    ["storage_port"]=>
    int(23000)
    ["storage_http_port"]=>
    int(8888)
    ["store_path_count"]=>
    int(1)
    ["subdir_count_per_path"]=>
    int(256)
    ["current_write_server"]=>
    int(0)
    ["current_trunk_file_id"]=>
    int(0)
    ["192.168.100.181"]=>
    array(61) {
      ["ip_addr"]=>
      string(15) "192.168.100.181"
      ["join_time"]=>
      int(1475602195)
      ["up_time"]=>
      int(1475646224)
      ["http_domain"]=>
      string(0) ""
      ["version"]=>
      string(4) "5.05"
      ["src_storage_id"]=>
      string(0) ""
      ["if_trunk_server"]=>
      bool(false)
      ["upload_priority"]=>
      int(10)
      ["store_path_count"]=>
      int(1)
      ["subdir_count_per_path"]=>
      int(256)
      ["storage_port"]=>
      int(23000)
      ["storage_http_port"]=>
      int(8888)
      ["current_write_path"]=>
      int(0)
      ["status"]=>
      int(7)
      ["total_space"]=>
      int(17944)
      ["free_space"]=>
      int(12476)
      ["connection.alloc_count"]=>
      int(256)
      ["connection.current_count"]=>
      int(1)
      ["connection.max_count"]=>
      int(2)
      ["total_upload_count"]=>
      int(1)
      ["success_upload_count"]=>
      int(1)
      ["total_append_count"]=>
      int(0)
      ["success_append_count"]=>
      int(0)
      ["total_modify_count"]=>
      int(0)
      ["success_modify_count"]=>
      int(0)
      ["total_truncate_count"]=>
      int(0)
      ["success_truncate_count"]=>
      int(0)
      ["total_set_meta_count"]=>
      int(0)
      ["success_set_meta_count"]=>
      int(0)
      ["total_delete_count"]=>
      int(1)
      ["success_delete_count"]=>
      int(1)
      ["total_download_count"]=>
      int(2)
      ["success_download_count"]=>
      int(2)
      ["total_get_meta_count"]=>
      int(0)
      ["success_get_meta_count"]=>
      int(0)
      ["total_create_link_count"]=>
      int(0)
      ["success_create_link_count"]=>
      int(0)
      ["total_delete_link_count"]=>
      int(0)
      ["success_delete_link_count"]=>
      int(0)
      ["total_upload_bytes"]=>
      int(13)
      ["success_upload_bytes"]=>
      int(13)
      ["total_append_bytes"]=>
      int(0)
      ["success_append_bytes"]=>
      int(0)
      ["total_modify_bytes"]=>
      int(0)
      ["success_modify_bytes"]=>
      int(0)
      ["total_download_bytes"]=>
      int(26)
      ["success_download_bytes"]=>
      int(26)
      ["total_sync_in_bytes"]=>
      int(12)
      ["success_sync_in_bytes"]=>
      int(12)
      ["total_sync_out_bytes"]=>
      int(0)
      ["success_sync_out_bytes"]=>
      int(0)
      ["total_file_open_count"]=>
      int(5)
      ["success_file_open_count"]=>
      int(5)
      ["total_file_read_count"]=>
      int(2)
      ["success_file_read_count"]=>
      int(2)
      ["total_file_write_count"]=>
      int(3)
      ["success_file_write_count"]=>
      int(3)
      ["last_heart_beat_time"]=>
      int(1475660266)
      ["last_source_update"]=>
      int(1475647676)
      ["last_sync_update"]=>
      int(1475648117)
      ["last_synced_timestamp"]=>
      int(1475648114)
    }
    ["192.168.100.182"]=>
    array(61) {
      ["ip_addr"]=>
      string(15) "192.168.100.182"
      ["join_time"]=>
      int(1475602286)
      ["up_time"]=>
      int(1475648692)
      ["http_domain"]=>
      string(0) ""
      ["version"]=>
      string(4) "5.05"
      ["src_storage_id"]=>
      string(15) "192.168.100.181"
      ["if_trunk_server"]=>
      bool(false)
      ["upload_priority"]=>
      int(10)
      ["store_path_count"]=>
      int(1)
      ["subdir_count_per_path"]=>
      int(256)
      ["storage_port"]=>
      int(23000)
      ["storage_http_port"]=>
      int(8888)
      ["current_write_path"]=>
      int(0)
      ["status"]=>
      int(7)
      ["total_space"]=>
      int(18717)
      ["free_space"]=>
      int(15808)
      ["connection.alloc_count"]=>
      int(256)
      ["connection.current_count"]=>
      int(1)
      ["connection.max_count"]=>
      int(1)
      ["total_upload_count"]=>
      int(1)
      ["success_upload_count"]=>
      int(1)
      ["total_append_count"]=>
      int(1)
      ["success_append_count"]=>
      int(1)
      ["total_modify_count"]=>
      int(0)
      ["success_modify_count"]=>
      int(0)
      ["total_truncate_count"]=>
      int(0)
      ["success_truncate_count"]=>
      int(0)
      ["total_set_meta_count"]=>
      int(0)
      ["success_set_meta_count"]=>
      int(0)
      ["total_delete_count"]=>
      int(0)
      ["success_delete_count"]=>
      int(0)
      ["total_download_count"]=>
      int(2)
      ["success_download_count"]=>
      int(2)
      ["total_get_meta_count"]=>
      int(0)
      ["success_get_meta_count"]=>
      int(0)
      ["total_create_link_count"]=>
      int(0)
      ["success_create_link_count"]=>
      int(0)
      ["total_delete_link_count"]=>
      int(0)
      ["success_delete_link_count"]=>
      int(0)
      ["total_upload_bytes"]=>
      int(6)
      ["success_upload_bytes"]=>
      int(6)
      ["total_append_bytes"]=>
      int(6)
      ["success_append_bytes"]=>
      int(6)
      ["total_modify_bytes"]=>
      int(0)
      ["success_modify_bytes"]=>
      int(0)
      ["total_download_bytes"]=>
      int(25)
      ["success_download_bytes"]=>
      int(25)
      ["total_sync_in_bytes"]=>
      int(13)
      ["success_sync_in_bytes"]=>
      int(13)
      ["total_sync_out_bytes"]=>
      int(0)
      ["success_sync_out_bytes"]=>
      int(0)
      ["total_file_open_count"]=>
      int(5)
      ["success_file_open_count"]=>
      int(5)
      ["total_file_read_count"]=>
      int(2)
      ["success_file_read_count"]=>
      int(2)
      ["total_file_write_count"]=>
      int(3)
      ["success_file_write_count"]=>
      int(3)
      ["last_heart_beat_time"]=>
      int(1475660272)
      ["last_source_update"]=>
      int(1475648114)
      ["last_sync_update"]=>
      int(1475647685)
      ["last_synced_timestamp"]=>
      int(0)
    }
  }
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.182"
  ["port"]=>
  int(22122)
  ["sock"]=>
  int(4)
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.182"
  ["port"]=>
  int(22122)
  ["sock"]=>
  int(5)
}
bool(true)
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.182"
  ["port"]=>
  int(22122)
  ["sock"]=>
  int(-1)
}
array(2) {
  [0]=>
  array(4) {
    ["ip_addr"]=>
    string(15) "192.168.100.181"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
    ["store_path_index"]=>
    int(0)
  }
  [1]=>
  array(4) {
    ["ip_addr"]=>
    string(15) "192.168.100.182"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
    ["store_path_index"]=>
    int(0)
  }
}
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(44) "M00/00/00/wKhktVf0yf2AVFhSAAB7UNInADc94328.h"
}
array(5) {
  ["source_id"]=>
  int(0)
  ["create_timestamp"]=>
  int(1475660285)
  ["file_size"]=>
  int(31568)
  ["source_ip_addr"]=>
  string(15) "192.168.100.181"
  ["crc32"]=>
  int(-769195977)
}
file exist: 1
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(50) "M00/00/00/wKhktVf0yf2AVFhSAAB7UNInADc94328.part1.h"
}
delete slave file return: 1
delete file return: 1
string(57) "group1/M00/00/00/wKhktVf0yf2AE52YAAB7UNInADc60554.part2.h"
delete file group1/M00/00/00/wKhktVf0yf2AE52YAAB7UNInADc60554.part2.h return: 1
delete file group1/M00/00/00/wKhktVf0yf2AE52YAAB7UNInADc60554.h return: 1
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(44) "M00/00/00/wKhktlf0yf2AZjIKAAAAD5Ij_SY680.txt"
}
array(5) {
  ["source_id"]=>
  int(0)
  ["create_timestamp"]=>
  int(1475660285)
  ["file_size"]=>
  int(15)
  ["source_ip_addr"]=>
  string(15) "192.168.100.182"
  ["crc32"]=>
  int(-1843135194)
}
file exist: 1
token=984fd906825dec9b3e7cd560a44a97aa
file content: this is a test.(15)
storage_download_file_to_file result: 1
fastdfs_storage_set_metadata result: 1
array(3) {
  ["color"]=>
  string(0) ""
  ["font"]=>
  string(8) "MS Serif"
  ["size"]=>
  string(2) "32"
}
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(50) "M00/00/00/wKhktlf0yf2AZjIKAAAAD5Ij_SY680.part1.txt"
}
delete slave file return: 1
delete file return: 1
file content: thisisatest.(15)
storage_download_file_to_file1 result: 1
fastdfs_storage_set_metadata1 result: 1
array(5) {
  ["color"]=>
  string(6) "yellow"
  ["font"]=>
  string(8) "MS Serif"
  ["height"]=>
  string(3) "768"
  ["size"]=>
  string(10) "1234567890"
  ["width"]=>
  string(4) "1024"
}
string(57) "group1/M00/00/00/wKhktVf0yf6AOjCBAAAAD_4E1BM090.part2.txt"
delete file group1/M00/00/00/wKhktVf0yf6AOjCBAAAAD_4E1BM090.part2.txt return: 1
delete file group1/M00/00/00/wKhktVf0yf6AOjCBAAAAD_4E1BM090.bin return: 1
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.182"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.182"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(1) {
  [0]=>
  array(3) {
    ["ip_addr"]=>
    string(15) "192.168.100.182"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
  }
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(1) {
  [0]=>
  array(3) {
    ["ip_addr"]=>
    string(15) "192.168.100.181"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
  }
}
fastdfs_tracker_close_all_connections result: 1
tracker_make_all_connections result: 1
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(22122)
  ["sock"]=>
  int(3)
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(22122)
  ["sock"]=>
  int(8)
}
bool(true)
array(2) {
  [0]=>
  array(4) {
    ["ip_addr"]=>
    string(15) "192.168.100.181"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
    ["store_path_index"]=>
    int(0)
  }
  [1]=>
  array(4) {
    ["ip_addr"]=>
    string(15) "192.168.100.182"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
    ["store_path_index"]=>
    int(0)
  }
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(3) {
  ["ip_addr"]=>
  string(15) "192.168.100.181"
  ["port"]=>
  int(23000)
  ["sock"]=>
  int(-1)
}
array(1) {
  [0]=>
  array(3) {
    ["ip_addr"]=>
    string(15) "192.168.100.181"
    ["port"]=>
    int(23000)
    ["sock"]=>
    int(-1)
  }
}
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(44) "M00/00/00/wKhktVf0yf6ADI75AAB7UNInADc29189.h"
}
array(5) {
  ["source_id"]=>
  int(0)
  ["create_timestamp"]=>
  int(1475660286)
  ["file_size"]=>
  int(31568)
  ["source_ip_addr"]=>
  string(15) "192.168.100.181"
  ["crc32"]=>
  int(-769195977)
}
file exist: 1
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(50) "M00/00/00/wKhktVf0yf6ADI75AAB7UNInADc29189.part1.h"
}
delete slave file return: 1
delete file return: 1
string(57) "group1/M00/00/00/wKhktlf0yf6AGc7zAAB7UNInADc71931.part2.c"
delete file group1/M00/00/00/wKhktlf0yf6AGc7zAAB7UNInADc71931.part2.c return: 1
delete file group1/M00/00/00/wKhktlf0yf6AGc7zAAB7UNInADc71931.c return: 1
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(44) "M00/00/00/wKhktVf0yf6AFavJAAAAAAAAAAA794.txt"
}
file content: (0)
storage_download_file_to_file result: 1
storage_set_metadata result: 1
array(2) {
  ["color"]=>
  string(6) "yellow"
  ["size"]=>
  string(2) "32"
}
array(2) {
  ["group_name"]=>
  string(6) "group1"
  ["filename"]=>
  string(50) "M00/00/00/wKhktVf0yf6AFavJAAAAAAAAAAA794.part1.txt"
}
delete slave file return: 1
delete file return: 1
array(5) {
  ["source_id"]=>
  int(0)
  ["create_timestamp"]=>
  int(1475660286)
  ["file_size"]=>
  int(15)
  ["source_ip_addr"]=>
  string(15) "192.168.100.182"
  ["crc32"]=>
  int(-1385915893)
}
file exist: 1
token=1c19dc1cf1702db27bc956dd92827e41
file content: thisisatest.(15)
storage_download_file_to_file1 result: 1
storage_set_metadata1 result: 1
string(57) "group1/M00/00/00/wKhktlf0yf6AKcjvAAAAD61kmgs561.part2.txt"
delete file group1/M00/00/00/wKhktlf0yf6AKcjvAAAAD61kmgs561.part2.txt return: 1
array(3) {
  ["color"]=>
  string(6) "yellow"
  ["font"]=>
  string(4) "Aris"
  ["size"]=>
  string(2) "32"
}
delete file group1/M00/00/00/wKhktlf0yf6AKcjvAAAAD61kmgs561.bin return: 1
bool(true)
tracker_close_all_connections result: 1



二、fastdfs的nginx模块部署和配置
1、下载pcre

1
2
3
cd /opt/tools
wget https://sourceforge.net/projects ... .37.tar.gz/download --no-check-certificate
tar -zxf pcre-8.37.tar.gz



2、下载fastdfs nginx模块
1
2
3
4
5
6
7
8
9
10
11
12
13
cd /opt/tools/
git clone https://github.com/happyfish100/fastdfs-nginx-module.git
[iyunv@mylinux3 tools]# tree fastdfs-nginx-module/
fastdfs-nginx-module/
├── HISTORY
├── INSTALL
└── src
    ├── common.c
    ├── common.h
    ├── config
    ├── mod_fastdfs.conf
    └── ngx_http_fastdfs_module.c
1 directory, 7 files



3、编译安装nginx
1
2
3
4
5
6
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -zxf nginx-1.10.1.tar.gz
cd nginx-1.10.1
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre=/opt/tools/pcre-8.37 --add-module=/opt/tools/fastdfs-nginx-module/src/
make && make install
useradd -s /sbin/nologin -M nginx



4、准备配置文件
1
2
3
4
5
cd /opt/tools/fastdfs-nginx-module/src/
cp mod_fastdfs.conf /etc/fdfs/  #拷贝fastdfs nginx模块目录下的mod_fastdfs.conf到/etc/fdfs下
cp /opt/tools/fastdfs-5.05/conf/{anti-steal.jpg,http.conf,mime.types} /etc/fdfs/  #把fastdfs安装源文件中/conf目录下的这三个文件拷贝到/etc/fdfs下
touch /var/log/mod_fastdfs.log  #创建fastdfs nginx模块日志,方便后面排错
chown nginx:nginx /var/log/mod_fastdfs.log



5、修改配置文件
1)修改nginx配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /usr/local/nginx/conf/
cp nginx.conf nginx.conf.bak
vi nginx.conf
[iyunv@mylinux3 conf]# diff nginx.conf.bak  nginx.conf
37c37
<         server_name  localhost;
---
>         server_name  192.168.100.181;
41a42,45
>         location /group1/M00 {     #这段内容是新增的,需要放在默认location / 段的前面
>             root /data/fdfs_storage/store/;
>             ngx_fastdfs_module;
>         }



2)修改fastdfs nginx模块的配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
cp /etc/fdfs/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf.bak
vi /etc/fdfs/mod_fastdfs.conf
[iyunv@mylinux3 conf]# diff /etc/fdfs/mod_fastdfs.conf.bak /etc/fdfs/mod_fastdfs.conf
40c40,41
< tracker_server=tracker:22122
---
> tracker_server=192.168.100.181:22122   #修改tracker的IP地址
> tracker_server=192.168.100.182:22122
53c54
< url_have_group_name = false
---
> url_have_group_name = true    #允许包含组名,这个与nginx的配置对应,因为nginx上的配置没有把路径写全,所以这里要允许包含组名
62c63
< store_path0=/home/yuqing/fastdfs
---
> store_path0=/data/fdfs_storage/store  #修改存储路径为实际的文件路径
78c79
< log_filename=
---
> log_filename=/var/log/mod_fastdfs.log  #指定fastdfs nginx的日志路径



6、启动nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@mylinux3 conf]# /usr/local/nginx/sbin/nginx -t
ngx_http_fastdfs_set pid=8782
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[iyunv@mylinux3 conf]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=8783
[iyunv@mylinux3 conf]# lsof -i :80
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   8784  root    6u  IPv4  44777      0t0  TCP *:http (LISTEN)
nginx   8785 nginx    6u  IPv4  44777      0t0  TCP *:http (LISTEN)
[iyunv@mylinux3 conf]# netstat -lnt|grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      
[iyunv@mylinux3 conf]# ps -ef|grep nginx
root       8784      1  0 23:07 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      8785   8784  0 23:07 ?        00:00:00 nginx: worker process      
root       8791   1793  0 23:07 pts/0    00:00:00 grep nginx



7、上传文件
1
2
3
4
5
6
[iyunv@mylinux3 tools]# cat /root/a.txt
Hello,world.
[iyunv@mylinux3 tools]# fdfs_upload_file /etc/fdfs/client.conf /root/a.txt
group1/M00/00/00/wKhktVf1GFaATxhVAAAADUwC04E708.txt
[iyunv@mylinux3 tools]# fdfs_upload_file /etc/fdfs/client.conf /root/test.gif
group1/M00/00/00/wKhktlf1GcKALtFFAAAlbU5-NyE685.gif



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-282917-1-1.html 上篇帖子: CentOS 6.5上安装并配置FastDFS 下篇帖子: Fastdfs 无法上传文件问题描述及解决方案
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表