Google Code Prettify
2012年7月2日 星期一
Apache http Server 2.4 效能解放
Apache 2.4 宣佈已經可以跟 Nginx比拼了
但很多網路文章卻測不出這個效能
一開始我也沒辦法解放它的效能
經過數次的安裝移除的循環
發現一個重要的參數: --with-mpm
必須安裝為 event Multi-Processing Module
這就是解放效能的所在囉
什麼是 event module, 其實就是 linux EPoll,Nginx 也是應用這個模式
Apache 2.4 安裝步驟
#安裝 APR
tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apache-apr --enable-nonportable-atomics=yes
make
sudo make install
#安裝 APR-UTIL apr-util
tar -zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apache-apr --with-apr=/usr/local/apache-apr
make
sudo make install
unzip -o pcre-8.30.zip
cd pcre-8.30
./configure --prefix=/usr/local/pcre --enable-utf --enable-unicode-properties
make
sudo make install
#安裝 apache server
1. tar -zxvf httpd-2.4.2.tar.gz
2. cd httpd-2.4.2
3. ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apache-apr --with-apr-util=/usr/local/apache-apr --with-pcre=/usr/local/pcre --with-mpm=event \
--enable-nonportable-atomics=yes \
--enable-mods-shared=all \
--enable-expires=shared \
--enable-headers=shared \
--enable-reqtimeout=shared \
--enable-ssl=shared \
--enable-rewrite=shared \
--enable-speling=shared \
--enable-proxy=shared \
--enable-proxy-connect=shared \
--enable-proxy-ajp=shared \
--enable-proxy-balancer=shared \
--enable-proxy-express=shared \
--enable-info=shared \
--enable-heartbeat=shared \
--enable-heartmonitor=shared \
--enable-ratelimit=shared \
--enable-remoteip=shared \
--enable-allowmethods=shared
4. make
5. sudo make install
6.Check Apache MPM 是 event
/usr/local/apache2.4/bin/httpd -l
/usr/local/apache2.4/bin/httpd -V | grep MPM
#效能調整
#修改 httpd-mpm.conf 下的mpm_event_module
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
利用 Ghostscript 重新產生PDF
Ghostscript
http://pages.cs.wisc.edu/~ghost/
完整參數
http://www.ghostscript.com/doc/current/Use.htm
範例指令
轉換為600dpi
gswin32c -dNOPAUSE -dBATCH -q -r600 -sDEVICE=pdfwrite -sOutputFile=out.pdf input.pdf
指定頁數
gswin32c -dNOPAUSE -dBATCH -q -r600 -sDEVICE=pdfwrite -dFirstPage=22 -dLastPage=36 -sOutputFile=out.pdf input.pdf
pdfwrite Additional Options
PDF optimization level selection options
-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)
Paper size selection options
-sPAPERSIZE=letter
-sPAPERSIZE=a4
-dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch)
-dFIXEDMEDIA (force paper size over the PostScript defined size)
Other options
-dEmbedAllFonts=true
-dSubsetFonts=false
-dFirstPage=pagenumber
-dLastPage=pagenumber
-dAutoRotatePages=/PageByPage
-dAutoRotatePages=/All
-dAutoRotatePages=/None
-r1200 (resolution for pattern fills and fonts converted to bitmaps)
-sPDFPassword=password
-dConvertCMYKImagesToRGB=true
-dCompatibilityLevel=1.5
更多參數請參考 Ps2pdf.htm
2011年4月25日 星期一
讓Ext JS 2 支援IE9
if (typeof Range.prototype.createContextualFragment == "undefined") {
Range.prototype.createContextualFragment = function(html) {
var doc = this.startContainer.ownerDocument;
var container = doc.createElement("div");
container.innerHTML = html;
var frag = doc.createDocumentFragment(), n;
while ( (n = container.firstChild) ) {
frag.appendChild(n);
}
return frag;
};
}2011年3月9日 星期三
GraphicsMagick 安裝
2011年3月7日 星期一
ImageMagick pdf to jpg
- ghostscript-8.70.tar.gz
- ghostscript-fonts-std-8.11.tar.gz 解壓縮到 /usr/local/share/ghostscript/fonts
- gs871w32.exe
- 設定path C:\Program Files\gs\gs8.71\bin
2010年5月21日 星期五
OpenOffice service
soffice -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.Service" -nofirststartwizard
但如果使用非管理者的帳號啟動上列指令,可能會發生部分目錄下的轉檔失敗。
可以改用下列指令啟動
soffice.bin -accept="socket,host=localhost,port=8100;urp;StarOffice.Service" -headless
-nofirststartwizard
2009年6月26日 星期五
Dynamic Web service client
String wsdl = "http://localhost:8080/SOA-DO1/PortTypeBndPort?WSDL";org.apache.axis.client.Service service = new org.apache.axis.client.Service();
Call call = service.createCall();
call.setTargetEndpointAddress(wsdl);
call.setOperationName(new QName("http://schemas.xmlsoap.org/wsdl/soap/","Add"));
//Input
call.addParameter( "machineid",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter( "passcode",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter( "uid",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter( "url",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter( "note",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter( "handle_time",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
//Output
call.addParameter( "status",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.OUT);
call.addParameter( "message",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.OUT);
call.addParameter( "time",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.OUT);
call.addParameter( "sno",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.OUT);
call.setUseSOAPAction(true);
call.setSOAPActionURI("do1.soa.com/PortType/Add");
String machineid = "sdfs";
String passcode = "sdfsf";
String uid = "C123456789";
String url = "http://www.google.com.tw";
String note = "測試網站-新增測試";
String handle_time = "";
List list = new ArrayList();
list.add(machineid);
list.add(passcode);
list.add(uid);
list.add(url);
list.add(note);
list.add(handle_time);
Object [] inputParams = list.toArray();
List outputParams = new ArrayList();
//取得第一個回傳值
outputParams.add(call.invoke(inputParams));
//取得剩餘的回傳值
outputParams.addAll(call.getOutputValues());
for(int i=0;i<outputParams.size();i++){
System.out.println(i+"="+outputParams.get(i));
}