環境
windows 7
visual studio 2010
apache2.2
apxs
1.
官網
http://webdav.todo.gr.jp/
http://gnuwin32.sourceforge.net/packages/regex.htm
下載
a. http://webdav.todo.gr.jp/download/mod_encoding-20021209.tar.gz
b. http://webdav.todo.gr.jp/download/experimental/mod_encoding.c.apache2.20040616a
c. http://gnuwin32.sourceforge.net/downlinks/regex-bin-zip.php (regex-2.7-bin.zip)
2.
a. 解開 mod_encoding-20021209.tar.gz
b. cd mod_encoding-20021209
c. 改名 mod_encoding.c 為 mod_encoding.c.bak
d. 複製 mod_encoding.c.apache2.20040616a 進來改名為 mod_encoding.c
e. 解開 regex-2.7-bin.zip
f. 複製 regex-2.7-bin/include/regex.h 到 mod_encoding-20021209/
3.
a. 建立目錄 mod_encoding-20021209/iconv_hook
b. 複製 mod_encoding-20021209/lib/iconv.h.replace 到 mod_encoding-20021209/iconv_hook/inconv.h
c. 複製 mod_encoding-20021209/lib/iconv_hook.h 到 mod_encoding-20021209/iconv_hook/iconv_hook.h
4. 修改 regex.h
windows 沒有的 sys/types.h 改為 stddef.h
將 #include <sys/types.h> 註解
加入 #include <stddef.h>
5. 修改 mod_encoding.c
a. 在 #include <httpd.h> 上加入 #include "regex.h"
b. 加入
#include <apr_strings.h>
#include "iconv_hook/iconv.h"
c. 修改 548 行
windows 沒有 index 改用 strchr 取代
if ((user = index(r->user, '\\')) == NULL)
改為
if ((user = strchr(r->user, '\\')) == NULL)
6. 修改 iconv_hook_eucjp.c、iconv_hook_mssjis.c、iconv_hook_ucs2_cp932.c、iconv_hook_utf8_cp932.c、iconv_hook_utf8_eucjp.c
(在 mod_encoding-20021209/lib)
windows 沒有 dirent.h 和 unistd.h
註解
//#include <dirent.h>
//#include <unistd.h>
加入
#include <windows.h>
7. 修改 identify_encoding.h
(在 mod_encoding-20021209/lib)
因為 windows 沒有 strcasecmp 和 strncasecmp 所以改用 stricmp 和 strncmp
加入
#define strcasecmp stricmp
#define strncasecmp strncmp
8. 使用 apxs 編譯
cd mod_encoding-20021209/
c:\apache2\bin\apxs -llibhttpd -llibapr-1 -llibaprutil-1 -c mod_encoding.c ./lib/iconv_hook.c ./lib/iconv_hook_default.c ./lib/iconv_hook_eucjp.c ./lib/iconv_hook_ja_auto.c ./lib/iconv_hook_mssjis.c ./lib/iconv_hook_ucs2_cp932.c ./lib/iconv_hook_utf8_cp932.c ./lib/iconv_hook_utf8_eucjp.c ./lib/identify_encoding.c
如果沒有 apxs 可以自行編譯,指令如下
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fomod_encoding.lo mod_encoding.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook.lo ./lib/iconv_hook.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_default.lo ./lib/iconv_hook_default.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_eucjp.lo ./lib/iconv_hook_eucjp.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_ja_auto.lo ./lib/iconv_hook_ja_auto.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_mssjis.lo ./lib/iconv_hook_mssjis.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_ucs2_cp932.lo ./lib/iconv_hook_ucs2_cp932.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_utf8_cp932.lo ./lib/iconv_hook_utf8_cp932.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/iconv_hook_utf8_eucjp.lo ./lib/iconv_hook_utf8_eucjp.c
cl.exe /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\apache2\include" /c /Fo./lib/identify_encoding.lo ./lib/identify_encoding.c
link kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"c:\apache2\lib" /out:mod_encoding.so libhttpd.lib libapr-1.lib libaprutil-1.lib ./lib/identify_encoding.lo ./lib/iconv_hook_utf8_eucjp.lo ./lib/iconv_hook_utf8_cp932.lo ./lib/iconv_hook_ucs2_cp932.lo ./lib/iconv_hook_mssjis.lo ./lib/iconv_hook_ja_auto.lo ./lib/iconv_hook_eucjp.lo ./lib/iconv_hook_default.lo ./lib/iconv_hook.lo mod_encoding.lo
9. 複製 mod_encoding.so 到 apache2/modules/
10.
加入以下的 config 註解掉的為 web-dav 所用,依需求自行開啟
#LoadModule headers_module modules/mod_headers.so
LoadModule encoding_module modules/mod_encoding.so
#<IfModule mod_headers.c>
# Header add MS-Author-Via "DAV"
#</IfModule>
<IfModule mod_encoding.c>
EncodingEngine on
NormalizeUsername on
SetServerEncoding UTF-8
DefaultClientEncoding UTF-8 Big5
# AddClientEncoding "(Microsoft .* DAV $)" UTF-8 Big5
# AddClientEncoding "Microsoft .* DAV" UTF-8 Big5
# AddClientEncoding "Microsoft-WebDAV*" UTF-8 Big5http://www.blogger.com/img/blank.gif
</IfModule>
Ref
http://webdav.todo.gr.jp/
http://blog.makk.idv.hk/post/31/