ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • LINUX 시스템에서 PHP 파일업로드 최대 용량 설정해보아요~
    Programming 2012. 7. 19. 18:16

    사건의 발단은 이렇다.

    파일을 전송하는 웹사이트의 용량을 1G에서 2G로 늘리기로했다.


    Step1) PHP


    그래서 php.ini 의 용량부분을 수정했더니 php가 사망(?) 해 버리셨다;; 로그인부터 아무것도 되지 않더라~

    post_max_size = 2048M
    upload_max_filesize = 2048M


    서버 파일시스템을 확인해보니 ext3 ~! 문제없는데..

    [root@filetransfer01 filetransfer]# df -Th

    Filesystem    Type    Size  Used Avail Use% Mounted on

    /dev/sda7     ext3    179G   14G  156G   9% /data


    구글링 해보니 2047M 는 된다고~!? 

    post_max_size = 2047M
    upload_max_filesize = 2047M


    변경하니 잘된다~! (물론 아파치 리스타트는 에티켓이죠~)


    이유가 궁금해져서 찾아보니

    linux 시스템에서 지원하는 fopen 라이브러리에서 지원하는 최대 사이즈가 2G 미만이라고~

    그래서 2G미만부터 열리는거~ 그렇다고 php는 왜 먹통이 되냐고~!


    최종 1.8G로 최대 사이즈를 정하고 해서 아래와 같이 셋팅해줬다.

    memory_limit 용량은 더 줘야 하지만 800M로 지정했더니 25,864k free 남더라;; (더 많이 늘릴수도 없어~!)

    구글링해보니 용량은 memory_limit > post_max_size > upload_man_filesize 순으로 많게 줘야 한단다.

    그치만 서버가 꼬졌어요;;; (그리고 메모리값이 젤루 비싸거든요;)


    ]# vi /etc/php.ini

    max_execution_time = 7200     ;7200Sec = 2Min / Maximum execution time of each script, in seconds

    max_input_time = 7200   ; Maximum amount of time each script may spend parsing request data

    memory_limit = 800M      ; Maximum amount of memory a script may consume

    post_max_size = 1824M ; Maximum size of POST data that PHP will accept.

    file_uploads = On ; Whether to allow HTTP file uploads.

    upload_tmp_dir = /data/php_tmp/ ; Temporary directory for HTTP uploaded files (will use system default if not specified).

    upload_max_filesize = 1824M ; Maximum allowed size for uploaded files.


    Step2) /data

    데이터 저장 위치를 살펴보자.

    Filesystem            Size  Used Avail Use% Mounted on

    /dev/sda7             179G   12G  158G   7% /data  : 실제 데이터 쌓을곳

    /dev/sda2              19G  243M   18G   2% /home    : tmp 파일업로드 위치


    위와 같은 구조로 해버리는 경우 1G 데이터 업로드 후 이동()시 몇분의 소요시간을 가지게 된다!! T^T

    이런경우 모두~ Filesystem 한곳으로 몰아주자!

    Filesystem            Size  Used Avail Use% Mounted on

    /dev/sda7             179G   12G  158G   7% /data  : tmp파일업로드 / 실제 데이터


    그래서 php.ini 경로 변경

    ]# vi /etc/php.ini

    upload_tmp_dir = /data/php_tmp/ ; Temporary directory for HTTP uploaded files (will use system default if not specified).


    관련 내용을 알고싶다면 .. 아래 링크 본문에서 발췌

    The difference between cp and mv is that mv simply adds a directory entry for the existing file in the destination directory.  If the destination is on the same filesystem (mount point) then no file data is moved.  The source directory entry is then deleted.

    cp, on the other hand will create a new file, and copy the data into there.

    So, with fsync on mv, there is no buffered data to be written.

    With fsync on cp, there IS data to be written, and it looks like the directory entry just happens to get flushed with the file data.


    출처 : https://listman.redhat.com/archives/ext3-users/2010-June/msg00001.html

    참고: http://lovelydays95.tistory.com/entry/cp%EB%AA%85%EB%A0%B9%EC%96%B4%EC%99%80-mv%EB%AA%85%EB%A0%B9%EC%96%B4-%EB%B9%84%EA%B5%90


    Step3) Monitoring

    [root@filetransfer ~]# iftop -i eth0:1 -P
                        366Mb               732Mb               1.07Gb              1.43Gb         1.79Gb
    └───────────────────┴───────────────────┴───────────────────┴───────────────────┴───────────────────┴
    192.168.1x.xx:http                   => 192.168.3x.xx:rsip                   1.26Mb  1.17Mb  1.17Mb
                                         <=                                       88.6Mb  83.3Mb  83.1Mb            : 업로드 중일때

    192.168.1x.xx:http                   => 192.168.3x.xx:5xxx3                   45.2Mb  42.8Mb  42.8Mb : 다운로드 중일때
    ─────────────────────────────────────────────────────────────────────────────────────────────────────
    TX:             cum:   1.16GB   peak:   1.37Mb                       rates:   1.33Mb  1.24Mb  1.22Mb
    RX:                    7.88GB           92.5Mb                                88.8Mb  83.5Mb  83.2Mb
    TOTAL:                 9.04GB           93.8Mb                                90.1Mb  84.7Mb  84.4Mb


    실시간으로 보여줘서 좋은데.. 지켜봐야하는거네;;;


    'Programming' 카테고리의 다른 글

    그대에게 바치는 ....  (0) 2012.07.20
    ASCII 코드표  (0) 2012.03.13
    동접 개선을위한 개발이야기 - 2011 DBC 발표 자료 중에서  (0) 2011.11.08

    댓글

Designed by Tistory.