banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận hệ điều hành *nix Không thể download tập tin từ máy chủ Linux share dữ liệu  XML
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 21/09/2011 15:42:14 (+0700) | #1 | 247531
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Chào mọi người!
- Mình xây dựng trang web: ngôn ngữ PHP, CSDL MySQL, máy chủ Apache chạy trên HĐH CentOS
- Trên web có module download tài liệu là các tập tin .doc, .pdf,.. Các tập tin đặt tại máy chủ Web thì download về bình thường.
- Nhưng khi dùng một thiết bị lưu trữ QNAP (nó chạy HĐH Linux) để chứa các tập tin gốc .doc, .pdf . Mình đã mount thư mục chứa tập tin về máy chủ web Apache; thì trang web không thể download các tập tin này được.
- Mình đã disable SELinux trên máy chủ Web luôn vẫn không download được.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 21/09/2011 15:47:40 (+0700) | #2 | 247533
[Avatar]
conmale
Administrator

Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
[Profile] [PM]

lyphuong wrote:
Chào mọi người!
- Mình xây dựng trang web: ngôn ngữ PHP, CSDL MySQL, máy chủ Apache chạy trên HĐH CentOS
- Trên web có module download tài liệu là các tập tin .doc, .pdf,.. Các tập tin đặt tại máy chủ Web thì download về bình thường.
- Nhưng khi dùng một thiết bị lưu trữ QNAP (nó chạy HĐH Linux) để chứa các tập tin gốc .doc, .pdf . Mình đã mount thư mục chứa tập tin về máy chủ web Apache; thì trang web không thể download các tập tin này được.
- Mình đã disable SELinux trên máy chủ Web luôn vẫn không download được.
 


Apache debug log?
What bringing us together is stronger than what pulling us apart.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 22/09/2011 13:02:12 (+0700) | #3 | 247583
luckyfun
Member

[Minus]    0    [Plus]
Joined: 20/03/2008 12:52:22
Messages: 8
Offline
[Profile] [PM]

lyphuong wrote:
Chào mọi người!
- Mình xây dựng trang web: ngôn ngữ PHP, CSDL MySQL, máy chủ Apache chạy trên HĐH CentOS
- Trên web có module download tài liệu là các tập tin .doc, .pdf,.. Các tập tin đặt tại máy chủ Web thì download về bình thường.
- Nhưng khi dùng một thiết bị lưu trữ QNAP (nó chạy HĐH Linux) để chứa các tập tin gốc .doc, .pdf . Mình đã mount thư mục chứa tập tin về máy chủ web Apache; thì trang web không thể download các tập tin này được.
- Mình đã disable SELinux trên máy chủ Web luôn vẫn không download được.
 


check lại permission thử xem! smilie
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 22/09/2011 18:39:29 (+0700) | #4 | 247600
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Chào anh
- Em làm hoài mà nó vẫn chưa được.
- Đây là log Apache
Access log
192.168.2.111 - - [23/Sep/2011:02:23:02 +0700] "GET /csdlkhcn/download.php?dulieu=tailieuso&file=48470.pdf HTTP/1.1" 200 112 "http://192.168.2.115/csdlkhcn/tai-lieu-so-hoa.html" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
192.168.2.111 - - [23/Sep/2011:02:23:02 +0700] "GET /favicon.ico HTTP/1.1" 200 1406 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
192.168.2.111 - - [23/Sep/2011:02:26:02 +0700] "GET /csdlkhcn/tai-lieu-so-hoa.html HTTP/1.1" 200 46437 "http://192.168.2.115/csdlkhcn/index.php" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
192.168.2.111 - - [23/Sep/2011:02:26:05 +0700] "GET /csdlkhcn/download.php?dulieu=tailieuso&file=48463.pdf HTTP/1.1" 200 112 "http://192.168.2.115/csdlkhcn/tai-lieu-so-hoa.html" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22" 


Error log
[Fri Sep 23 02:16:56 2011] [notice] caught SIGTERM, shutting down
[Fri Sep 23 02:19:43 2011] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Sep 23 02:19:43 2011] [notice] Digest: generating secret for digest authentication ...
[Fri Sep 23 02:19:43 2011] [notice] Digest: done
[Fri Sep 23 02:19:43 2011] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
[Fri Sep 23 02:22:59 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php
[Fri Sep 23 02:26:02 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php 


- Còn đây là permission thư mục chứa tập tin bên trong mình đã mount qua Máy chủ web Apache
drwxr-xr-x 1 root root 0 Apr 13 16:09 .
drwxr-xr-x. 3 root root 4096 Aug 26 21:33 ..
drwxr-xr-x 1 root root 0 Oct 25 2010 congviec
drwxr-xr-x 1 root root 0 May 26 16:30 detai
drwxr-xr-x 1 root root 0 Jun 28 15:34 dulieucnnn
drwxr-xr-x 1 root root 0 Sep 13 09:19 images
-rwxr-xr-x 1 root root 44 Sep 14 2005 index.html
drwxr-xr-x 1 root root 0 Aug 16 10:54 movie
drwxr-xr-x 1 root root 0 Aug 18 16:03 tailieuso 



[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 27/09/2011 18:19:11 (+0700) | #5 | 247823
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Anh Conmale có thể chỉ cách khắc phục trường hợp này giùm. Thank !
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 28/09/2011 05:21:33 (+0700) | #6 | 247837
[Avatar]
conmale
Administrator

Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
[Profile] [PM]

lyphuong wrote:
Anh Conmale có thể chỉ cách khắc phục trường hợp này giùm. Thank ! 


Logs ở trên chẳng có thông tin gì liên quan tới chuyện "download không được" hết.

Bồ đã mount thư mục QNAP như thế nào? Cấu hình cụ thể của apache sử dụng filesystem QNAP là gì?
What bringing us together is stronger than what pulling us apart.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 28/09/2011 20:09:16 (+0700) | #7 | 247874
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Em xem Logs Apache nó giống nhau khi: các tập tin tại máy chủ web Apache thì download được, hay các tập tin đặt từ thiết bị lưu trữ QNAP mount sang máy chủ web Apache không download được.

- Máy chủ Web Apache sử dụng HĐH CentOS sử dụng filesystem ext4 (IP: xxx.xxx.xxx.115)
- QNAP là một thiết bị lưu trữ khác nó sử dụng HĐH Linux, chia sẽ dữ liệu (IP: xxx.xxx.xxx.118)

Lệnh mount trên máy chủ web Apache HĐH CentOS
- mount -t cifs //xxx.xxx.xxx.118/yy /zzz/yy -o username=xxx,password=xxx,iocharset=utf8,file_mode=0777,dir_mode=0777
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 29/09/2011 03:36:32 (+0700) | #8 | 247891
[Avatar]
conmale
Administrator

Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
[Profile] [PM]

lyphuong wrote:
Em xem Logs Apache nó giống nhau khi: các tập tin tại máy chủ web Apache thì download được, hay các tập tin đặt từ thiết bị lưu trữ QNAP mount sang máy chủ web Apache không download được.
 

Câu này mơ hồ quá. Những log nào chứng minh rằng tập tin không download được khi dùng QNAP? Bồ cho vài ví dụ xem?

lyphuong wrote:

- Máy chủ Web Apache sử dụng HĐH CentOS sử dụng filesystem ext4 (IP: xxx.xxx.xxx.115)
- QNAP là một thiết bị lưu trữ khác nó sử dụng HĐH Linux, chia sẽ dữ liệu (IP: xxx.xxx.xxx.118)

Lệnh mount trên máy chủ web Apache HĐH CentOS
- mount -t cifs //xxx.xxx.xxx.118/yy /zzz/yy -o username=xxx,password=xxx,iocharset=utf8,file_mode=0777,dir_mode=0777 


Như vậy thì QNAP share bằng Samba và apache server mount QNAP với CIFS?

Nếu mount options với file_mode và dir_mode là 0777 như trên thì làm sao có được:
Code:
drwxr-xr-x 1 root root 0 Apr 13 16:09 .
drwxr-xr-x. 3 root root 4096 Aug 26 21:33 ..
drwxr-xr-x 1 root root 0 Oct 25 2010 congviec
drwxr-xr-x 1 root root 0 May 26 16:30 detai
drwxr-xr-x 1 root root 0 Jun 28 15:34 dulieucnnn
drwxr-xr-x 1 root root 0 Sep 13 09:19 images
-rwxr-xr-x 1 root root 44 Sep 14 2005 index.html
drwxr-xr-x 1 root root 0 Aug 16 10:54 movie
drwxr-xr-x 1 root root 0 Aug 18 16:03 tailieuso


Vậy người dùng không download được cái gì trong các thư mục trên? Cụ thể là thư mục nào? Bồ liệt kê nội dung ngay thư mục bị sự cố xem?

Bồ cũng thử xem ngay trên máy chạy apache, bồ copy file đến /zzz/yy coi thử được không? Đồng thời, thử switch sang account nào dùng để chạy apache và thử "read" files nằm trong /zzz/yy coi thử được không?

PS: đọc thật kỹ những câu hỏi đã được đặt ra và cố gắng trả lời đầy đủ nếu như bồ muốn giải quyết vấn đề.
What bringing us together is stronger than what pulling us apart.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 29/09/2011 15:28:03 (+0700) | #9 | 247924
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Câu này mơ hồ quá. Những log nào chứng minh rằng tập tin không download được khi dùng QNAP? Bồ cho vài ví dụ xem? 

Đã Xóa tất cả nội dung trong Log và sau đó em kiểm tra download một tập tin (nên log chỉ có mấy dòng đó thôi). Bên dưới là log download tập tin không được khi dùng QNAP, nó không ghi nhận gì vấn đề download không được.

Access log
Code:
192.168.2.111 - - [23/Sep/2011:02:23:02 +0700] "GET /csdlkhcn/download.php?dulieu=tailieuso&file=48470.pdf HTTP/1.1" 200 112 "http://192.168.2.115/csdlkhcn/tai-lieu-so-hoa.html" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
    192.168.2.111 - - [23/Sep/2011:02:23:02 +0700] "GET /favicon.ico HTTP/1.1" 200 1406 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
    192.168.2.111 - - [23/Sep/2011:02:26:02 +0700] "GET /csdlkhcn/tai-lieu-so-hoa.html HTTP/1.1" 200 46437 "http://192.168.2.115/csdlkhcn/index.php" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"
    192.168.2.111 - - [23/Sep/2011:02:26:05 +0700] "GET /csdlkhcn/download.php?dulieu=tailieuso&file=48463.pdf HTTP/1.1" 200 112 "http://192.168.2.115/csdlkhcn/tai-lieu-so-hoa.html" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22"


Error log
Code:
[Fri Sep 23 02:16:56 2011] [notice] caught SIGTERM, shutting down
    [Fri Sep 23 02:19:43 2011] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Fri Sep 23 02:19:43 2011] [notice] Digest: generating secret for digest authentication ...
    [Fri Sep 23 02:19:43 2011] [notice] Digest: done
    [Fri Sep 23 02:19:43 2011] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
    [Fri Sep 23 02:22:59 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php
    [Fri Sep 23 02:26:02 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php


Như vậy thì QNAP share bằng Samba và apache server mount QNAP với CIFS? 

Đúng rồi, QNAP được share bằng Samba và apache server mount QNAP với CIFS (như lệnh mount).
Nếu mount options với file_mode và dir_mode là 0777 như trên thì làm sao có được: 

Xin lỗi, Ban đầu em chỉ mount không có option với file_mode và dir_mode là 0777, nên nó là
Code:
drwxr-xr-x 1 root root 0 Apr 13 16:09 .
 drwxr-xr-x. 3 root root 4096 Aug 26 21:33 ..
 drwxr-xr-x 1 root root 0 Oct 25 2010 congviec
 drwxr-xr-x 1 root root 0 May 26 16:30 detai
 drwxr-xr-x 1 root root 0 Jun 28 15:34 dulieucnnn
 drwxr-xr-x 1 root root 0 Sep 13 09:19 images
 -rwxr-xr-x 1 root root 44 Sep 14 2005 index.html
 drwxr-xr-x 1 root root 0 Aug 16 10:54 movie
 drwxr-xr-x 1 root root 0 Aug 18 16:03 tailieuso


Sau đó mới mount lại thêm option với file_mode và dir_mode là 0777 nhưng vẫn download không được

Vậy người dùng không download được cái gì trong
các thư mục trên? Cụ thể là thư mục nào? Bồ liệt kê nội dung ngay thư
mục bị sự cố xem?
Bồ cũng thử xem ngay trên máy chạy apache, bồ
copy file đến /zzz/yy coi thử được không? Đồng thời, thử switch sang
account nào dùng để chạy apache và thử "read" files nằm trong /zzz/yy
coi thử được không? 


Quyền trên thư mục
Code:
drwxrwxrwx. 1 root root    0 Aug 18 16:03 tailieuso


Đây là vài tập tin trong thư mục cần download tailieuso, còn nhiều tập tin nữa và tên tập tin cần download là 48463.pdf có trong thư mục này (mà máy chủ Web Apachhe đã mount từ QNAP)

Code:
total 108761886
drwxrwxrwx. 1 root root         0 Aug 18 16:03 .
drwxrwxrwx. 1 root root         0 Apr 13 16:09 ..
-rwxrwxrwx. 1 root root     96256 Nov 13  2009 03.doc
-rwxrwxrwx. 1 root root  16630078 Mar 26  2003 10000.pdf
-rwxrwxrwx. 1 root root  17850979 Apr 26  2003 10001.pdf
-rwxrwxrwx. 1 root root  10165743 Apr 26  2003 10002.pdf
-rwxrwxrwx. 1 root root  23445714 Apr 26  2003 10003.pdf
-rwxrwxrwx. 1 root root  41681921 Apr 26  2003 10004.pdf


Ghi và đọc tập tin trên thư mục tailieuso đều được.

Nó có đặc điểm này:
Nếu download tập tin, dùng đường dẫn trực tiếp đến tập tin trực tiếp thì được (Các tập tin đặt tại máy chủ Web Apache, hay được mount từ thiết bị lưu trữ QNAP đều được)

Code:
http://xxx/xxx/xxx/tailieuso/48471.pdf


Nhưng khi dùng viết code php download để không hiển thị đường dẫn đến tập tin

Code:
csdlkhcn/download.php?dulieu=tailieuso&file=48463.pdf


- Trường hợp 1: tập tin nằm trực tiếp tại máy chủ Web Apache thì download được

- Trường hợp 2: tập tin được mount đến máy chủ Web Apache thì download không được (đây là trường hợp cần khắc phục để sử dụng)
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 07:03:42 (+0700) | #10 | 247940
[Avatar]
hoanglan87
Member

[Minus]    0    [Plus]
Joined: 25/06/2008 07:20:09
Messages: 33
Offline
[Profile] [PM]
Xin lỗi vì chen ngang, nhưng bạn cho mình hỏi khi bạn truy cập

Code:
csdlkhcn/download.php?dulieu=tailieuso&file=48463.pdf


Thì trình duyệt báo lỗi như thế nào? Như bạn trình bày, mình nghĩ có thể là lỗi lập trình php của web.

[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 07:47:18 (+0700) | #11 | 247944
[Avatar]
conmale
Administrator

Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
[Profile] [PM]
Bồ thảy cái cấu hình apache lên và nội dung cái download.php lên. Có thể đây là lỗi lập trình php.
What bringing us together is stronger than what pulling us apart.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 09:33:32 (+0700) | #12 | 247948
[Avatar]
xnohat
Moderator

Joined: 30/01/2005 13:59:19
Messages: 1210
Location: /dev/null
Offline
[Profile] [PM] [Email] [WWW] [Yahoo!] [MSN]
Trước mắt là PHP báo một lỗi liên quan tới header

Code:
[Fri Sep 23 02:22:59 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php
     [Fri Sep 23 02:26:02 2011] [error] [client 192.168.2.111] PHP Notice: Undefined variable: header_code in /var/www/html/csdlkhcn/components/com_chronoconnectivity/chronoconnectivity.html.php on line 56, referer: http://192.168.2.115/csdlkhcn/index.php
iJust clear, "What I need to do and how to do it"/i
br
brBox tán gẫu dời về: http://www.facebook.com/hvaonline
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 11:50:27 (+0700) | #13 | 247959
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Thì trình duyệt báo lỗi như thế nào? Như bạn trình bày, mình nghĩ có thể là lỗi lập trình php của web. 

Lỗi này là do mình viết code php để quy định khi download không được (có nằm trong code download.php bên dưới)
Mình có nghĩ đến lỗi code php và tìm lỗi nhưng chưa thấy.
Nhưng nếu cả 2 trường hợp: tập tin đặt tại máy chủ Web Apache hay tập tin được mount đến máy chủ Web từ thiết bị lưu trữ QNAP đều download không được (thì chắc chắn là lỗi code php)
Tình huống bên dưới: (nên chưa xác định được lỗi)
- Trường hợp 1: tập tin nằm trực tiếp tại máy chủ Web Apache thì download được
- Trường hợp 2: tập tin được mount đến máy chủ Web Apache thì download không được (đây là trường hợp cần khắc phục để sử dụng)

Bồ thảy cái cấu hình apache lên và nội dung cái download.php lên. Có thể đây là lỗi lập trình php. 

httpd.conf
Code:
ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

<IfModule worker.c>
StartServers         4
MaxClients         300
MinSpareThreads     25
MaxSpareThreads     75 
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

Listen 80
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule substitute_module modules/mod_substitute.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule version_module modules/mod_version.so

Include conf.d/*.conf

User apache
Group apache

ServerAdmin root@localhost
ServerName 192.168.2.115:80
UseCanonicalName Off
DocumentRoot "/var/www/html"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/var/www/html">

    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    UserDir disabled

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    # 
    #UserDir public_html

</IfModule>


DirectoryIndex index.html index.html.var
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile conf/magic
</IfModule>
HostnameLookups Off
ErrorLog logs/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog logs/access_log combined
ServerSignature On
Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_dav_fs.c>
    # Location of the WebDAV lock database.
    DAVLockDB /var/lib/dav/lockdb
</IfModule>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

ForceLanguagePriority Prefer Fallback

AddDefaultCharset UTF-8
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Alias /error/ "/var/www/error/"
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
    <Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback
    </Directory>

</IfModule>
</IfModule>
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" wwwect-carefully
BrowserMatch "MS FrontPage" wwwect-carefully
BrowserMatch "^WebDrive" wwwect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" wwwect-carefully
BrowserMatch "^gnome-vfs/1.0" wwwect-carefully
BrowserMatch "^XML Spy" wwwect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" wwwect-carefully


download.php
Code:
<?php
ob_start(); 
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>File Download</title>
</head>
<body>
<?php
// Ham thuc hien download
function send_file($upload_dir,$name) {
    ob_end_clean();
    $path = $upload_dir.$name;
    if (!is_file($path) or connection_status()!=0) return(FALSE);
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Content-Type: application/octet-stream");
    header("Content-Length: ".(string)(filesize($path)));
	header("Content-Disposition: attachment; filename=$name");	
    header("Content-Transfer-Encoding: binary\n");
    if ($file = fopen($path, 'rb')) {
        while(!feof($file) and (connection_status()==0)) {
            print(fread($file, 1024*8));
            flush();
        }
        fclose($file);
    }
    return((connection_status()==0) and !connection_aborted());
}
?>
<?php
// Dinh nghia duong dan goc
define( 'JPATH_DULIEU',		'/share/dulieuweb');  // Duong dan thu muc nam ngoai ung dung Web
//define( 'JPATH_DULIEU',		'http://192.168.2.115/csdlkhcn/dulieu');  // Duong dan nam trong thu muc ung dung Web
//define( 'JPATH_DULIEU',		'D:/dulieuweb');

// Kiem tra bien nhan ve tu URL de lay dung thu muc
//echo $_GET["dulieu"];
if ($_GET["dulieu"]=='mov') 
	$upload_dir=JPATH_DULIEU.'/movie/';
else if ($_GET["dulieu"]=='tailieuso')
	$upload_dir=JPATH_DULIEU.'/tailieuso/';
else if ($_GET["dulieu"]=='dulieucnnn')
	$upload_dir=JPATH_DULIEU.'/dulieucnnn/';
else if ($_GET["dulieu"]=='detai')
	$upload_dir=JPATH_DULIEU.'/detai/'.$_GET["dd"].'/';
else if ($_GET["dulieu"]=='congviec')
	$upload_dir=JPATH_DULIEU.'/congviec/';

//lay ten file can download tu URL
$filename = isset($_GET['file'])?$_GET['file']:'';
$filename=str_replace(".dat",".wmv",$filename);

// Kiem tra in duongdan den taptin
//echo $upload_dir.$filename;

    //Close the session to allow for header() to be sent
	// Goi ham send_file thuc hien download neu download khong duoc thi bao loi
    session_write_close();
    if(!send_file($upload_dir,$filename)) {	
		print '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
        die ("Tập tin không tìm thấy trên Server !");  
    } else {
        //Log the download	
    }
?>
</body>
</html>
<?php ob_end_flush(); ?>


Trước mắt là PHP báo một lỗi liên quan tới header 

Log Lỗi này thì: cả 2 trường hợp đều có lỗi này (Tập tin nằm trực tiếp tại máy chủ Web Apache thì download được, hay Tập tin được mount đến máy chủ Web Apache thì download không được), nên có lẽ không phải lỗi này. Mình cũng trong quá trình khắc phục lỗi này.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 11:59:45 (+0700) | #14 | 247961
[Avatar]
conmale
Administrator

Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
[Profile] [PM]
Trên apache config chẳng thấy có cái gì liên quan đến "/share/dulieuweb" hết. Cái "/share/dulieuweb" thuộc trong DocRoot nào của apache? Thuộc virtualhost nào (nếu có)?

Trong cấu hình của apache ở trên chỉ có mỗi: DocumentRoot "/var/www/html", vậy cái "/share/dulieuweb" nằm ở đâu trong DocumentRoot này?
What bringing us together is stronger than what pulling us apart.
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 15:50:30 (+0700) | #15 | 247978
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Trên apache config chẳng thấy có cái gì liên quan đến "/share/dulieuweb" hết. Cái "/share/dulieuweb" thuộc trong DocRoot nào của apache? Thuộc virtualhost nào (nếu có)?

Trong cấu hình của apache ở trên chỉ có mỗi: DocumentRoot "/var/www/html", vậy cái "/share/dulieuweb" nằm ở đâu trong DocumentRoot này? 


Khi mount đến máy chủ Web có đường dẫn thư mục chứa tập tin là "/share/dulieuweb/tailieuso"

Kiểm tra Link download
Code:
csdlkhcn/download.php?dulieu=tailieuso&file=48463.pdf

Code định nghĩa đường dẫn:
Code:
define( 'JPATH_DULIEU', '/share/dulieuweb'); // Duong dan thu muc nam ngoai ung dung Web

Em không dùng virtualhost
Đường dẫn nằm ngoài thư mục ứng dụng web, tức là "/share/dulieuweb" (tại root)
Tuy không nằm trong DocumentRoot (Không nằm trong DocumentRoot "/var/www/html" ; hoặc không nằm trong thư mục ứng dụng web "/var/www/html/csdlkhcn" nhưng vẫn download được tập tin chứa trong đường dẫn "/share/dulieuweb/tailieuso", em đã kiểm tra cả các máy trong LAN và ngoài Internet.
Code php nhận thêm đường dẫn có thư mục tailieuso và cả tập tin cần download
Code:
if ($_GET["dulieu"]=='mov') 
 	$upload_dir=JPATH_DULIEU.'/movie/';
 else if ($_GET["dulieu"]=='tailieuso')
 	$upload_dir=JPATH_DULIEU.'/tailieuso/';
 else if ($_GET["dulieu"]=='dulieucnnn')
 	$upload_dir=JPATH_DULIEU.'/dulieucnnn/';
 else if ($_GET["dulieu"]=='detai')
 	$upload_dir=JPATH_DULIEU.'/detai/'.$_GET["dd"].'/';
 else if ($_GET["dulieu"]=='congviec')
 	$upload_dir=JPATH_DULIEU.'/congviec/';
 
 //lay ten file can download tu URL
 $filename = isset($_GET['file'])?$_GET['file']:'';
 $filename=str_replace(".dat",".wmv",$filename);
 
 // Kiem tra in duongdan den taptin
 //echo $upload_dir.$filename;

Quá trình download.php xử lý, kiểm tra đường dẫn đầy đủ đến tập tin 48471.pdf
Code:
/share/dulieuweb/tailieuso/48471.pdf


Nó chỉ bị sự cố ở chỗ là:
- Trường hợp 1: Tập tin nằm trực tiếp tại máy chủ Web Apache thì download được
- Trường hợp 2: Tập tin được mount đến máy chủ Web Apache thì download không được (đây là trường hợp cần khắc phục để sử dụng)

Phải chi cả 2 trường hợp đều download không được thì mình nghĩ là lỗi do code php, hay lỗi đường dẫn; đằng này nó chỉ khác ở chổ là tập tin tai máy chủ web; hay tập tin mount đến máy chủ web (vị trí đường dẫn đến tập tin thì giống nhau)



Phần các tập tin đặt trong thư mục ứng dụng web
Em cũng có kiểm tra mount các tập tin đến trong thư mục ứng dụng web "/var/www/html/csdlkhcn"
Định nghĩa đường dẫn
Code:
define( 'JPATH_DULIEU',		'http://192.168.2.115/csdlkhcn/dulieu');  // Duong dan nam trong thu muc ung dung Web


Kết quả vẫn giống như bên trên: tức là tập tin tại máy chủ Web Apache download được; tập tin mount từ thiết bị lưu trữ QNAP đến máy chủ web Apache thì không được
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 16:16:02 (+0700) | #16 | 247980
myquartz
Member

[Minus]    0    [Plus]
Joined: 04/01/2005 04:58:30
Messages: 563
Offline
[Profile] [PM]
Thử mount thay vì vào /share/dulieuweb, thì mount vào /var/www/share/dulieuweb xem?
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 30/09/2011 16:22:53 (+0700) | #17 | 247981
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Thử mount thay vì vào /share/dulieuweb, thì mount vào /var/www/share/dulieuweb xem? 


Mình có làm trường hợp này luôn rồi
Phần các tập tin đặt trong thư mục ứng dụng web
Em cũng có kiểm tra mount các tập tin đến trong thư mục ứng dụng web "/var/www/html/csdlkhcn"
Khi mount đến máy chủ Web có đường dẫn thư mục chứa tập tin là "/var/www/html/csdlkhcn/dulieu/tailieuso"
Định nghĩa đường dẫn
Code:
define( 'JPATH_DULIEU',		'http://192.168.2.115/csdlkhcn/dulieu');  // Duong dan nam trong thu muc ung dung Web

Quá trình download.php xử lý, kiểm tra đường dẫn đầy đủ đến tập tin 48471.pdf là
Code:
http://192.168.2.115/csdlkhcn/dulieu/tailieuso/48471.pdf


Kết quả vẫn giống như bên trên: tức là tập tin tại máy chủ Web Apache download được; tập tin mount từ thiết bị lưu trữ QNAP đến máy chủ web Apache thì không được
[Up] [Print Copy]
  [Question]   Không thể download tập tin từ máy chủ Linux share dữ liệu 04/10/2011 09:36:18 (+0700) | #18 | 248110
lyphuong
Member

[Minus]    0    [Plus]
Joined: 31/01/2007 11:08:21
Messages: 30
Offline
[Profile] [PM]
Mình đã tìm thấy lỗi khi mount cifs không download được là do hàm is_file và filesize không làm việc trong tập tin xử lý download.php.
Trong PHP có 4 hàm: file_exists, is_file, filesize, is_dir
- Nếu các tập tin đặt trực tiếp tại máy chủ Web Apache, chay PHP thì 4 hàm làm việc tốt.
- Nếu các tập tin, thư mục được mount cifs đến thì hàm file_exists làm việc, nhưng 3 hàm is_file, filesize, is_dir không làm việc
Code:
<?php
echo file_exists('/share/dulieuweb/tailieuso/48471.pdf'); // hàm trả về 1 làm việc tốt
echo is_file('/share/dulieuweb/tailieuso/48471.pdf');       // hàm không làm việc
echo filesize('/share/dulieuweb/tailieuso/48471.pdf');       // hàm không làm việc
echo is_dir('/share/dulieuweb/tailieuso');                     // hàm không làm việc
?>

Sử dụng Google Search với từ khoá "mount cifs is_file" sẽ tìm thấy giải thích

http://php.net/manual/en/function.is-dir.php
Just a note for anyone who encounters is_dir() returning false on CIFS mount points or directories within those mount points on 2.6.31 and newer kernels: Apparently in new kernels they've started using the CIFS serverino option by default. With Windows shares this causes huge inode numbers and which apparently can cause is_dir() to return false. Adding the noserverino option to the CIFS mount will prevent this. This may only occur on 32 systems but I don't have a 64 bit install to test against. 

Trên mạng có chỉ cách sử dụng mount cifs thêm option noserverino
Các hàm file_exists, is_file, filesize, is_dir đã làm việc, vấn đề download đã làm việc tốt.
Cám ơn Anh conmale, cám ơn mọi người.


[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|