<menu id="w8yyk"><menu id="w8yyk"></menu></menu>
  • <dd id="w8yyk"><nav id="w8yyk"></nav></dd>
    <menu id="w8yyk"></menu>
    <menu id="w8yyk"><code id="w8yyk"></code></menu>
    <menu id="w8yyk"></menu>
    <xmp id="w8yyk">
    <xmp id="w8yyk"><nav id="w8yyk"></nav>
  • 網站首頁 > 物聯資訊 > 技術分享

    再次優化NGINX+php-fpm上傳

    2016-09-28 00:00:00 廣州睿豐德信息科技有限公司 閱讀
    睿豐德科技 專注RFID識別技術和條碼識別技術與管理軟件的集成項目。質量追溯系統、MES系統、金蝶與條碼系統對接、用友與條碼系統對接

    上次寫了一篇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"/><br />
    <input type="submit" name="submit" value="Upload"/>
    <input type="hidden" name="test" value="value"/>
    </form>
    </body>
    </html>

    4.測試: RFID設備管理軟件 PS:不太熟悉 wordpress 下如何顯示html代碼·很多代碼都被隱藏不顯示,html 代碼部分顯示不全。

    from:http://deidara.blog.51cto.com/400447/389873

    RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成
    最近免费观看高清韩国日本大全