首页 > nginx > 再次优化NGINX+php-fpm上传

再次优化NGINX+php-fpm上传

2010年9月6日 eric 发表评论 阅读评论

上次写了一篇nginx+php-fpm优化上传,一位博友留言介绍了,第三方nginx upload module

http://www.grid.net.ru/nginx/upload.en.html

看了一下,功能蛮强大的,所以就记录下来·基本没什么变化,在原有的例子上稍加了下修改,加了一个限速功能。
在 0.8.X 版本上编译出出错,他官方也有写:

For nginx versions other than 0.7.44-51

但是我在最新版本 nginx-0.7.67.tar.gz 编译也没问题。

下载nginx:wget http://www.nginx.org/download/nginx-0.7.67.tar.gz
下载模块:wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12.tar.gz

1.下载编译安装nginx_upload_module

nginx $> tar zxvf nginx-0.7.67.tar.gz
nginx $> tar zxvf nginx_upload_module-2.0.12.tar.gz
nginx $> cd nginx-0.7.67
#关掉不需要的模块,节省资源开支俗话说越简洁越稳定~
nginx $> ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --without-http_memcached_module --without-http_empty_gif_module --without-mail_pop3_module  --without-mail_imap_module --without-mail_smtp_module --add-module=/root/nginx_upload_module-2.0.12
nginx $> make
nginx $> make install

2.创建配置文件:

nginx $> cd /usr/local/nginx/conf
nginx $> vim nginx.conf
user    www    www;
worker_processes  1;

error_log  logs/error.log notice;
pid        logs/nginx.pid;

working_directory /usr/local/nginx;

worker_rlimit_nofile    65535;
events {
    use epoll;
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 1024m;
   server {
        listen       80;
        server_name     192.168.6.162;
        index   index.html index.htm index.php;
        root    /var/www;

        # Upload form should be submitted to this location
        location /upload {
            # Pass altered request body to this location
            upload_pass   /upload.php;

            # Store files to this directory
            # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
            upload_store /var/www/webdata;

            # Allow uploaded files to be read only by user
            upload_store_access user:r;
            # 限制上传速度
            upload_limit_rate 128k;

            # Set specified fields in request body
            upload_set_form_field "${upload_field_name}_name" $upload_file_name;
            upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
            upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;

            # Inform backend about hash and size of a file
            upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
            upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;

            upload_pass_form_field "^submit$|^description$";
        }

        # Pass altered request body to a backend
           location ~ \.php {
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
   }
}

3.创建测试代码

nginx $> cd /var/www
nginx $> mkdir webdata
nginx $> chown www.www webdata
nginx $> vim upload.php
< ?php
  echo "REQUEST :";
  echo "Upload: " . $_REQUEST["file_name"] . "";
  echo "Type: " . $_REQUEST["file_content_type"] . "";
  echo "path: " . $_REQUEST["file_path"] . "";
  echo "MD5 " . $_REQUEST["file_md5"] . "";
  echo "Size: " . ($_REQUEST["file_size"] / 1024) . "";

  echo "_POST:";
  echo "Name : " . $_POST["file_name"] . "";
  echo "Type : " . $_POST["file_content_type"] . "";
  echo "Path : " . $_POST["file_path"] . "";
  echo "MD5  : " . $_POST["file_md5"] . "";
  echo "Size : " . ($_POST["file_size"] / 1024) .  "Kb";
?>
nginx $> vim upload.html
<html>
<body>
<h2>Select files to upload</h2>
<form name="upload" enctype="multipart/form-data" action="/upload" method="post">
<input type="file" name="file"/>
<input type="submit" name="submit" value="Upload"/>
<input type="hidden" name="test" value="value"/>
</form>

</body>
</html>

4.测试:

PS:不太熟悉 wordpress 下如何显示html代码·很多代码都被隐藏不显示,html 代码部分显示不全。

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/252.html

分类: nginx 标签: , , ,
  1. 2017年12月7日01:59 | #1

    receptfritt pris, http://www.phillipspond.net/?page_name=klomen , köpa apoteket recept.

  2. 2017年12月7日06:57 | #2

    bestill billig pris uten resept nett, http://www.therefinedfin.com/blog/apotek/oestrodose , salg kjøp.

  3. 2017年12月7日07:45 | #3

    receptfria pris, http://www.cudesign.net/apotek/efexor , köp i Sverige Danmark.

  4. 2017年12月7日13:12 | #4

    köpa generisk i Sverige, http://southernhillschristian.org/wordpress/apotek/finax , köp Sverige Danmark.

  5. 2017年12月7日14:02 | #5

    uten resept i Norge nettbutikk, http://www.sobrietygroup.com/apotek/ketoderm , Hvor kjøpe Norge.

  6. 2017年12月7日17:37 | #6

    receptfria tabletter, http://drewpallet.com/apotek/herpex , generiska alternativ till generic.

  7. 2017年12月7日19:43 | #7

    uten resept i Norge nettbutikk, http://www.hollyhockclothing.com/apotek/azelastine , kan man kjøpe uten resept i Spania pris.

  8. 2017年12月7日21:18 | #8

    I like what you guys are usually up too. This kind of clever work and reporting!
    Keep up the superb works guys I’ve incorporated you
    guys to my blogroll.

  9. 2017年12月7日22:07 | #9

    billig generic, http://www.aidseducation.org/apotek/enal , kostar pris.

  10. 2017年12月8日02:00 | #10

    apotek generic, http://www.annecray.com/apotek/vagifem , köp Sverige malmö.

  11. 2017年12月8日02:52 | #11

    apoteket, http://www.donaldneff.com/blog/apotek/buccoval , pris apoteket Oslo.

  12. 2017年12月8日04:31 | #12

    casino game
    [url=http://real777money.com/]free online casino games[/url]
    casino game
    play casino online

  13. 2017年12月8日06:20 | #13

    viagra online apotheke deutschland
    generic viagra
    where can i buy viagra online cheap
    [url=http://hqviagrajdr.com/]viagra for sale[/url]
    cheap viagra in canada

  14. 2017年12月8日15:29 | #14

    for salg Norge, http://www.cityofrefugenetwork.org/apotek/metaxalone , kjøp generisk man.

  15. 2017年12月8日15:41 | #15

    Danmark priser, http://www.amarasdance.com/v2/?page_name=acular , till salu billigt.

  16. 2017年12月8日20:19 | #16
  17. 2017年12月8日23:33 | #17

    casino games
    [url=http://real777money.com/]play casino online[/url]
    free casino games
    casino games

  18. 2017年12月9日20:27 | #18

    casino game
    [url=http://real777money.com/]free casino games[/url]
    casino games
    casino games

  19. 2017年12月10日00:39 | #19

    Bestellen bij apotheek amsterdam, http://www.jenniferjacula.com/blog/apotheek/hyaluronic-acid , kopen nederland spanje.

  20. 2017年12月10日02:39 | #20

    tabletti turku, http://www.petsinportraits.com/?page_name=furosemida – suomi tallinnasta.

  21. 2017年12月10日04:38 | #21

    Kopen in winkel rotterdam den haag, http://www.lifeimaginedcoaching.com/apotheek/acran , pil waar te koop winkel.

  22. 2017年12月10日08:36 | #22

    online suomi, http://kariewilliams.com/dev/apteekki/brinzolamide – virosta suomessa.

  23. 2017年12月10日09:34 | #23
  24. 2017年12月10日10:05 | #24

    Alternatief zonder voorschrift belgie, http://www.bambooskates.com/apotheek/rogaine-5 , te koop in nederland den haag.

  25. 2017年12月10日13:48 | #25

    Bestellen belgie den haag, http://www.jenniferjacula.com/blog/apotheek/cholestoplex , prijs nederland online.

  26. 2017年12月10日14:53 | #26

    tallinna helsinki, http://www.nlwpartners.com/apteekki/aripiprazole – lääke ilman reseptiä hinnat.

  27. 2017年12月10日17:17 | #27

    Kopen belgie frankrijk, http://www.tomirizarry.com/wp/?page_name=estraderm , pillen kopen frankrijk.

  28. 2017年12月10日20:49 | #28

    slot machines
    [url=http://real777money.com/]free slot games[/url]
    casino game
    casino online

  29. 2017年12月11日05:52 | #29

    This message is posted here using XRumer + XEvil 4.0

    XEvil 4.0 is a revolutionary application that can bypass almost any anti-botnet protection.
    Captcha Recognition Google (ReCaptcha-1, ReCaptcha-2), Facebook, BING, Hotmail, Yahoo,
    Yandex, VKontakte, Captcha Com – and over 8.4 million other types!

    You read this – it means it works! ;)
    Details on the official website of XEvil.Net, there is a free demo version.

    Check YouTube video “XEvil ReCaptcha2″

  30. 2017年12月11日18:45 | #30

    halpa rovaniemi, http://www.nlwpartners.com/apteekki/progynova – halpa hämeenlinna.

  31. 2017年12月11日20:24 | #31

    Bestellen goedkoop online, http://www.charliechannel.com/?page_name=januvia , prijs nederland duitsland.

  32. 2017年12月11日22:53 | #32

    Kopen in belgie kopen, http://www.musicismybusiness.net/apotheek/oprymea , tabletten te koop.

  33. 2017年12月11日23:01 | #33

    halvat hinnat tallinna, http://www.petsinportraits.com/?page_name=miranax – tabletti hämeenlinna.

  34. 2017年12月13日00:02 | #34

    comprar online online, http://farmaciaonline.life/prostafin.html – qual o mais barato.

  35. 2017年12月13日02:51 | #35

    fiyatı, http://turkiye-online-eczane.life/lotrisone.html – online eczane nasıl.

  36. 2017年12月13日04:22 | #36

    This message is posted here using XRumer + XEvil 4.0

    XEvil 4.0 is a revolutionary application that can solve almost any anti-botnet protection.
    Captcha Solution Google (ReCaptcha-1, ReCaptcha-2), Facebook, BING, Hotmail, Yahoo,
    Yandex, VKontakte, Captcha Com – and over 8.4 million other types!

    You read this – it means it works! ;)
    Details on the official website of XEvil.Net, there is a free demo version.

    Check YouTube video “XEvil ReCaptcha2″

  37. 2017年12月13日05:39 | #37

    farmacia porto alegre, http://farmacia-on-line.life/acticam.html – venda receita médica.

  38. 2017年12月13日09:44 | #38

    on-line nedir, http://turkiyeonlineeczane.life/rolac.html – En iyi ucuz.

  39. 2017年12月13日10:47 | #39

    hapı ankara, http://turkiye-eczane-online.life/hyaluron-hexal.html – muadilleri tablet.

  40. 2017年12月13日11:29 | #40

    qual generico, http://farmaciasportuguesas.life/eleval.html – tablets rio.

  41. 2017年12月13日15:29 | #41

    comprar original online brasil, http://farmacias-portuguesas.life/maxbon.html – quanto custa o fortaleza.

  42. 2017年12月13日16:29 | #42

    almanyada satisi bursa, http://turkiyeeczaneonline.life/salipax.html – online eczane ne kadar.

  43. 2017年12月13日17:49 | #43

    online payday loans
    [url=https://smajloans.com/]cash loans[/url]
    payday loans no credit check
    cash loans

  44. 2017年12月13日19:19 | #44

    sobre o remedio, http://portugalfarmacias.life/mycutol.html – preço do na argentina.

  45. 2017年12月13日21:24 | #45

    Nasıl alabilirim fiyatı, http://eczaneonlineturkiye.life/eutimil.html – satılık almak.

  46. 2017年12月13日22:06 | #46

    generico precisa de receita, http://portugal-farmacias.life/monkasta.html – Nome generico del.

  47. 2017年12月14日05:44 | #47

    comprar barato preço, http://portugal-farmacia.life/buventol.html – Nome generico do original.

  48. 2017年12月14日05:58 | #48

    Kampanya fiyatlari, http://onlineeczaneturkiye.life/exel.html – tabletler hd fiyatı.

  49. 2017年12月14日08:26 | #49

    This message is posted here using XRumer + XEvil 4.0

    XEvil 4.0 is a revolutionary application that can break almost any antibot protection.
    Captcha Bypass Google (ReCaptcha-1, ReCaptcha-2), Facebook, BING, Hotmail, Yahoo,
    Yandex, VKontakte, Captcha Com – and over 8.4 million other types!

    You read this – it means it works! ;)
    Details on the official website of XEvil.Net, there is a free demo version.

    Check YouTube video “XEvil ReCaptcha2″

  50. 2017年12月14日08:53 | #50

    farmacias argentina, http://farmaciaportugal.life/biogrip-t.html – para comprar precisa de receita que.

评论分页
1 ... 3 4 5 6 7 ... 20 252
订阅评论
1+7= (必填)