First, the use of tools:
Nginx-1.8.1.tar.gz
Nginx_upload_module-2.2.0.tar.gz
Openssl-1.0.2h.tar.gz
Pcre-8.37.tar.gz
Zlib-1.2.8.tar.gz
Graphicsmagick-1.3.22.tar.gz
Apache-tomcat-7.0.47.tar.gz
Because of the use of Java Voice, the basic configuration is not said.
Second, the general record of the installation process:
1, decompression. tar.gz file
TAR-ZXVF pcre-8.37.tar.gz
2, configuration
./configure
3, compile
Make
4, installation
Make install
What you need to be aware of during installation:
1, the installed version needs special attention. I have installed the openssl-fips-2.0.12.tar.gz,nginx_upload_module-2.0.11.tar.gz these two versions, there are a variety of problems without solution.
2, nginx installation configuration:
./configure--with-pcre=. /pcre-8.37--with-zlib=.. /zlib-1.2.8--with-openssl=/home/openssl-1.0.2h--with-http_ssl_module--add-module=/home/nginx_upload_ module-2.2.0
2, install nginx_upload_module-2.2.0.tar.gz need to download the patch Davromaniak.txt
cd/home/nginx_upload_module-2.2.0
Patchngx_http_upload_module.c Davromaniak.txt
3, GraphicsMagick in the installation process needs to support the Jpg,png format:
Yuminstall-y Libpng-devel libpng
Yuminstall-y Libjpeg-devel Libjpeg
Third, the Nginx upload configuration file
<span style= "FONT-SIZE:18PX;"
>server {Listen 9001;
server_name 127.0.0.1;
Client_max_body_size 50m;
Proxy_request_buffering off;
location/upload {#上传完成后端接受处理文件 upload_pass/img_server/upload;
Upload_store/home/upload #上传文件夹 upload_cleanup 400 404 499 500-505;
Upload_limit_rate 0;# limit upload speed upload_store_access user:rw;
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"; Upload_aggregate_form_field "${upload_field_name}_md5" $upload _file_md5; #md5 Upload_aggregate_form_field "${upload
_field_name}_size "$upload _file_size; #文件大小 Upload_pass_form_field" ^submit$|^description$ ";
#如果希望把所有的表单字段都传给后端可以用 Upload_pass_form_field "^.*$";
Upload_pass_args on;
} location/{Proxy_pass http://127.0.0.1:8080; #proxy_intercept_Errors on;
Proxy_set_header remote_addr $remote _addr;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
} Access_log/usr/local/nginx/logs/img.log; }</span>
Note: Upload_pass: A path for background processing that needs to go through a proxy server to the Tomcat server.
Four, Java background to upload files data method:
<span style= "FONT-SIZE:14PX;"
> try {sis = Request.getinputstream ();
int a = 0;
int k = 0;
String s = "";
while ((A = Sis.readline (b, 0, b.length))!=-1) {s = new String (b, 0, a);
if ((k = S.indexof ("name=\"))!=-1) {String fieldName =s.substring (k + 6, S.length ()-3);
Sis.readline (b, 0, b.length);
Stringbufferfieldvalue = new StringBuffer (b.length);
while ((A = Sis.readline (b, 0, b.length))!=-1) {s = new String (b, 0, a-2);
if ((b[0) = && (b[1] = =) && (b[2] = =) && (b[3] = =) && (b[4] = = 45)) {
Break
else {fieldvalue.append (s);
} System.out.println (fieldname+ "---->" + fieldvalue.tostring ()); Args.put (Fieldname,fieldvalue.tostring ());
} catch (Exception e) {e.getstacktrace (); }</span>
Note: Upload must be POST method (enctype= "Multipart/form-data")
V. GraphicsMagick cache files for compression processing
<span style= "FONT-SIZE:14PX;" >public static string Saveminphoto (Stringsrcpath, string topath, int width, int height) throws Exception {
SYSTEM.O Ut.println ("----------------saveminphoto--------------");
Operation op = new Operation ();
Convertcmd cmd = new Convertcmd (true);
try {
op.addimage (srcpath);
Op.addrawargs ("-sample", Width + "x" + height + ">");
Op.addrawargs ("-gravity", "center");
Op.addrawargs ("-quality", "the");
Op.addimage (Topath);
Cmd.run (OP);
catch (Exception e) {
System.out.println ("error:" + e.getmessage ());
E.printstacktrace ();
File File = new file (Srcpath);
if (file.exists ()) {
file.delete ();
}
Return "Upload failed";
}
Return "Upload succeeded";
} </span>
did not write down the whole process, just to record the main part and the problems I encountered and their solutions, and some of them could not remember.