linux下apache支持中文名的解决方法
原日文网址:http://www.seya.org/mt/archives/2003/10/31_webdav2.html
1、下载相关文件并解压
WebDAV Resources JP有Apache2对应的mod_encoding的最新版本下载
# wget http://webdav.todo.gr.jp/download/mod_encoding-20021209.tar.gz
# wget http://webdav.todo.gr.jp/download/experimental/mod_encoding.c.apache2.20040616
# tar zxfv mod_encoding-20021209.tar.gz
# cp mod_encoding.c.apache2.20020616 mod_encoding-20021209/mod_encoding.c
2、iconv_hook编译和安装
安装mod_encoding前首先需要安装iconv_hook。
$ cd mod_encoding-20021209/lib
$ ./configure
$ make
# make install
完成上面操作后,iconv_hook相关so文件放到/usr/local/lib下面。
打开/etc/ld.so.conf文件,添加一行指向iconv_book的所在路径,即”/usr/local/lib”
# vi /etc/ld.so.conf
添加/usr/local/lib
# ldconfig
3、 mod_encoding模块的编译
进入mod_encoding-20021209.tar.gz的解压目录,即mod_encoding-20021209
–with-iconv-hook[=DIR] use iconv.h from iconv_hook in DIR
(default is /usr/local/include/iconv_hook)
# ./configure –with-apxs=/usr/sbin/apxs –with-iconv-hook=/usr/local/include
# make
我在执行make命令编译时,会报如下错误:
/usr/local/apache2/bin/apxs -c -I/usr/local/include -liconv_hook mod_encoding.c
/usr/local/apache2/build/libtool –silent –mode=compile gcc -prefer-pic -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/include -c -o mod_encoding.lo mod_encoding.c && touch mod_encoding.slo
mod_encoding.c: In function `get_client_encoding’:
mod_encoding.c:174: warning: assignment makes pointer from integer without a cast
mod_encoding.c:181: `regex_t’ undeclared (first use in this function)
mod_encoding.c:181: (Each undeclared identifier is reported only once
mod_encoding.c:181: for each function it appears in.)
mod_encoding.c:181: parse error before ‘)’ token
mod_encoding.c: At top level:
mod_encoding.c:187: parse error before “return”
mod_encoding.c: In function `set_server_encoding’:
mod_encoding.c:213: warning: assignment makes pointer from integer without a cast
mod_encoding.c: In function `add_client_encoding’:
mod_encoding.c:239: `REG_EXTENDED’ undeclared (first use in this function)
mod_encoding.c:239: `REG_ICASE’ undeclared (first use in this function)
mod_encoding.c:239: `REG_NOSUB’ undeclared (first use in this function)
mod_encoding.c:244: warning: assignment makes pointer from integer without a cast
mod_encoding.c: In function `default_client_encoding’:
mod_encoding.c:270: warning: assignment makes pointer from integer without a cast
mod_encoding.c: At top level:
mod_encoding.c:301: warning: initialization from incompatible pointer type
mod_encoding.c:305: warning: initialization from incompatible pointer type
mod_encoding.c:309: warning: initialization from incompatible pointer type
mod_encoding.c:313: warning: initialization from incompatible pointer type
mod_encoding.c:317: warning: initialization from incompatible pointer type
mod_encoding.c: In function `mod_enc_parse’:
mod_encoding.c:499: warning: passing arg 2 of `ap_pbase64encode’ makes pointer from integer without a cast
mod_encoding.c:501: warning: passing arg 3 of `apr_table_set’ makes pointer from integer without a cast
apxs:Error: Command failed with rc=65536
.
make: *** [mod_encoding.so] Error 1
原因很明显,是regex.h未包含进来,解决办法也很简单,用vi打开mod_encoding.c,
在#include <httpd.h>那一段的前面加上如下一行:
#include <regex.h>
再编译应该就可以通过了
#ls -l mod_encoding.o 查看是否已经生成了mod_encoding.o文件,如果是,则make成功继续下边的操作。
# gcc -shared -o mod_encoding.so mod_encoding.o -Wc,-Wall -L/usr/local/lib -Llib -liconv_hook
生成mod_encoding.so文件,将该文件拷贝到你的模块存放目录,一般为${APACHE_HOME}/modules/
# cp mod_encoding.so /usr/local/apache/modules/mod_encoding.so
4、 httpd.confd的設定
这个是我的设置文件
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 GBK
DefaultClientEncoding UTF-8 GBK GB2312
AddClientEncoding “(Microsoft .* DAV $)” UTF-8 GBK GB2312
AddClientEncoding “Microsoft .* DAV” UTF-8 GBK GB2312
AddClientEncoding “Microsoft-WebDAV*” UTF-8 GBK GB2312
</IfModule>
博客讲的不错啊
谢谢博主分享!看了
不错,路过留个脚印~~~没事就来.
以前好像读过相关的信息,不过还是不错,比较赞同!!
楼主来看看哈
博主,能不能换个友情链接呀
你的网站是啥
博主,你的空间是哪里的呀,速度很快呀
文章写的很不错。
很喜欢你写的文章,我可以转载吗?
可以
文章写的不错,拜读了!
支持
博主,你的空间是国内的还是国外的,最近被空间搞的没有脾气了,想找个好一点的空间,看你的博客访问速度不错,咨询一下,谢谢了!
国内的
第一次来,总得留个脚印先,祝你的博客越办越好,内容越来越丰富!