Apache2.0版本以上支持中文软件名文件下载

简介: 好久没写博文了,今天抽个小空写个故障解决方案吧!不过大多数基本是在网上找的的答案,这里我整理下大致步骤。如果有需要的朋友请参考! 故障描述:外网有一台apache服务器提供软件给客户下载,因为很多软件名是带有中文的,所以下载的时候失败,临时的解决方案是将中文名修改为一个英文名就OK了,但是这只是一时的解决步骤,最终的方案就是让apache支持中文软件名文件下载。
好久没写博文了,今天抽个小空写个故障解决方案吧!不过大多数基本是在网上找的的答案,这里我整理下大致步骤。如果有需要的朋友请参考!
故障描述:外网有一台apache服务器提供软件给客户下载,因为很多软件名是带有中文的,所以下载的时候失败,临时的解决方案是将中文名修改为一个英文名就OK了,但是这只是一时的解决步骤,最终的方案就是让apache支持中文软件名文件下载。
环境描述:
系统:红帽4.8     apache版本:2.2.11
不知道apache版本的哥们可以用如下命令参考:
/usr/local/apache2/bin/apachectl -v  
1、先确认mod_headers已经静态编译到apache中。
grep headers /usr/local/apache2/conf/httpd.conf
如果没有输出,那么你没有编译mod_headers到apache
解决办法:
下载和你apache版本相对应的源码包,下载后解压到当前目录
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11/modules/metadata
/usr/local/apache2/bin/apxs -i -a -c mod_headers.c
编译完成之后,再确认一下httpd.conf是否有mod_headers.so文件,如果有则说明已经加载成功!
grep headers /usr/local/apache2/conf/httpd.conf
LoadModule headers_module     modules/mod_headers.so
2、下载相关文件并解压
WebDAV Resources JP有Apache2对应的mod_encoding的最新版本下载
wget http://webdav.todo.gr.jp/download/experimental/mod_encoding.c.apache2.20040616
wget http://webdav.todo.gr.jp/download/mod_encoding-20021209.tar.gz
tar zxfv mod_encoding-20021209.tar.gz
cp mod_encoding.c.apache2.20040616 mod_encoding-20021209/mod_encoding.c
3、iconv_hook编译和安装,安装mod_encoding前首先需要安装iconv_hook。
cd mod_encoding-20021209/lib
./configure
make
mke install
完成上面操作后,iconv_hook相关的so文件放到/usr/local/lib下面。
要系统能够搜索到该so文件,需要让他自动加载
vi /etc/ld.so.conf
增加如下内容:
/usr/local/lib
增加完后执行如下命令:
PATH="$PATH:/sbin"
ldconfig
3、mod_encoding模块的编译安装
cd mod_encoding-20021209
./configure --with-apxs=/usr/local/apache2/bin/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 -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:228: warning: assignment makes pointer from integer without a cast
mod_encoding.c:235: error: `regex_t' undeclared (first use in this function)
mod_encoding.c:235: error: (Each undeclared identifier is reported only once
mod_encoding.c:235: error: for each function it appears in.)
mod_encoding.c:235: error: syntax error before ')' token
mod_encoding.c: At top level:
mod_encoding.c:241: error: syntax error before "return"
mod_encoding.c: In function `set_server_encoding':
mod_encoding.c:267: warning: assignment makes pointer from integer without a cast
mod_encoding.c: In function `add_client_encoding':
mod_encoding.c:293: error: `REG_EXTENDED' undeclared (first use in this function)
mod_encoding.c:293: error: `REG_ICASE' undeclared (first use in this function)
mod_encoding.c:293: error: `REG_NOSUB' undeclared (first use in this function)
mod_encoding.c:298: warning: assignment makes pointer from integer without a cast
mod_encoding.c: In function `default_client_encoding':
mod_encoding.c:324: warning: assignment makes pointer from integer without a cast
mod_encoding.c: At top level:
mod_encoding.c:355: warning: initialization from incompatible pointer type
mod_encoding.c:359: warning: initialization from incompatible pointer type
mod_encoding.c:363: warning: initialization from incompatible pointer type
mod_encoding.c:367: warning: initialization from incompatible pointer type
mod_encoding.c:371: warning: initialization from incompatible pointer type
mod_encoding.c: In function `mod_enc_parse':
mod_encoding.c:553: warning: passing arg 2 of `ap_pbase64encode' makes pointer from integer without a cast
mod_encoding.c:555: 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] 错误 1
解决该错误很简单,打开mod_encoding.c文件
找到如下内容:
#include
在上述内容中增加如下内容:
#include
再重新./configure,make即可!如果还不行那上网查相关资料吧!
查看是否在当前目录下是否生成了mod_encoding.o文件,生成后继续执行如下命令:
gcc -shared -o mod_encoding.so mod_encoding.o -Wc,-Wall -L/usr/local/lib -Llib -liconv_hook
执行上述命令后不会有任何输出提示,再次确认是否生成了mod_encoding.so文件,并将该文件拷贝到你自己的apache的模块存放目录,我的就是/usr/local/apache2/modules
cp mod_encoding.so /usr/local/apache2/modules/mod_encoding.so
4、httpd.conf文件增加如下内容是为了更好的支持中文软件名称:
LoadModule encoding_module modules/mod_encoding.so

Header add MS-Author-Via "DAV"


  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

5、重新启动apache,将带有中文名称的软件放到你的web服务器的发布目录下测试是否可以正常下载?
6、我这里小测试一下:
img_71e954b63469abdc195f8c9b3840832d.jpg
 

 
目录
相关文章
|
缓存 安全 Java
阿里云数据库 SelectDB 内核 Apache Doris 2.0.6 版本正式发布
阿里云数据库 SelectDB 内核 Apache Doris 2.0.6 版本正式发布
1166 1
|
运维 Linux Apache
LAMP架构调优(一)——隐藏Apache版本信息
LAMP架构调优(一)——隐藏Apache版本信息
112 1
|
2月前
|
SQL 存储 JSON
Apache Doris 2.1.10 版本正式发布
亲爱的社区小伙伴们,Apache Doris 2.1.10 版本已正式发布。2.1.10 版本对湖仓一体、半结构化数据类型、查询优化器、执行引擎、存储管理进行了若干改进优化。欢迎大家下载使用。
137 5
|
SQL 消息中间件 关系型数据库
Apache Doris Flink Connector 24.0.0 版本正式发布
该版本新增了对 Flink 1.20 的支持,并支持通过 Arrow Flight SQL 高速读取 Doris 中数据。
381 21
|
6月前
|
存储 SQL Java
Apache Doris 2.1.9 版本正式发布
Apache Doris 2.1.9 版本正式发布,欢迎使用~
202 4
|
11月前
|
Dubbo 安全 应用服务中间件
Apache Dubbo 正式发布 HTTP/3 版本 RPC 协议,弱网效率提升 6 倍
在 Apache Dubbo 3.3.0 版本之后,官方推出了全新升级的 Triple X 协议,全面支持 HTTP/1、HTTP/2 和 HTTP/3 协议。本文将围绕 Triple 协议对 HTTP/3 的支持进行详细阐述,包括其设计目标、实际应用案例、性能测试结果以及源码架构分析等内容。
577 112
|
12月前
|
前端开发 Java API
Apache Seata(incubating) 首个版本重磅发布!
2.1.0 是 Seata 进入 Apache 基金会的第一个 Release Version。此次发布将 io.seata 包名更改为 org.apache.seata。除了按原有的 Roadmap 技术演进外,2.1.0 进行了大量兼容性工作,实现了 API、数据和协议的兼容。用户无需修改原有的 API 和配置,即可实现到 Apache 版本的平滑升级。
302 111
Apache Seata(incubating) 首个版本重磅发布!
|
9月前
|
SQL 存储 分布式计算
Apache Doris 2.1.8 版本正式发布
该版本持续在湖仓一体、异步物化视图、查询优化器与执行引擎、存储管理等方面进行改进提升与问题修复,进一步加强系统的性能和稳定性,欢迎大家下载体验。
253 13
|
SQL 存储 Apache
Apache Doris 2.1.3 版本正式发布
Apache Doris 2.1.3 版本正式发布!该版本在功能特性上对数据湖、物化视图、负载管理等方面进行了多项更新,进一步简化湖仓一体架构、加速了查询性能。 欢迎大家下载体验~
633 1

推荐镜像

更多