微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

apache .gz用于Linux文档的gzip内容处理程序/ usr / share / doc和localhost / doc /

我怎样才能为apache .gz gzip内容创build一个简单的内容处理程序。 我想要它解压缩说:http://localhost/doc/FAQ/Linux-FAQ.gz并将其作为纯文本发送到浏览器。 在/ usr / share / doc和localhost / doc /中有很多Linux文档。 我不想用zless,zcat或vim来读取内容。 我使用apache浏览我的本地机器上的文档,并让我的网页浏览器将其作为标准文本复原,以便它不要求我每次下载* .gz文件

Alias /doc/ "/usr/share/doc/" Alias local.doc "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory>

但是现在我想把/ usr / share / doc /下的所有.gz文件作为纯文本进行编辑。 我想我可以用cgi-bin中的python脚本来做到这一点。 我正在为这些文件寻找一个不错的内容处理程序。 就像它处理PHP文件的方式.gz应该解压缩并发送到浏览器。

<IfModule mod_PHP5.c> AddType application/x-httpd-PHP .PHP .phtml .PHP3 AddType application/x-httpd-PHP-source .PHPs </IfModule> LoadModule PHP5_module /usr/lib/apache2/modules/libPHP5.so

我看到有一个mod_deflate,这将如何适用。 这可以处理gzip内容

这将使浏览文档变得更容易。 任何编程资源来帮助这里会很好。

将数据传递给Windows控制台控制处理程序

C#Windows应用程序阻止Windowsclosures/注销

在共享ARM9 GPIO中断(linux)上需要帮助处理多个共享I2C MAX3107芯片

IPropertyStore接口不在属性处理程序中调用

如何确定代码是否在信号处理程序环境中运行?

使用filter处理程序扩展Windowssearch索引,该处理程序使用C#/ .NET自定义文件格式

Nginx的gzipfilter不能与我的自定义处理程序一起工作

字符设备捕获多个(int)ioctl参数

从Chrome使用协议处理程序(ie:url)打开Internet Explorer

为什么我不能处理NMI?

我以前使用过这样的js / css文件(我修改了下面的内容以符合你的需求)。 将其添加到您的虚拟主机条目中:

Alias /doc/ "/usr/share/doc/" Alias local.doc "/usr/share/doc/" <Directory /usr/share/doc> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 AddEncoding gzip gz <FilesMatch ".gz$"> ForceType text/plain Header set content-encoding: gzip </FilesMatch> </Directory>

更新上面以匹配您的代码

在Ubuntu中,确保Headers模块已启用

$ sudo a2enmod headers $ sudo a2enmod deflate $ sudo apache2ctl restart

更新2:意识到“AddEncoding gzip gz”失踪..否则,文件不断尝试下载。

Update3:增加Apache模块deflate install命令。 这是我的deflate.conf:

<Ifmodulee mod_deflate.c> # these are kNown to be safe with MSIE 6 AddOutputFilterByType DEFLATE text/html text/plain text/xml # everything else may cause problems with MSIE 6 AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript AddOutputFilterByType DEFLATE application/RSS+xml </Ifmodulee>

你可以先尝试一些其他类型的文件(例如一个css文件)。 例:

cd /usr/share/doc cat ".styles { width: 50px; }" > test.css gzip -c test.css > test.css.gz

将此添加到您的虚拟主机:

<FilesMatch ".css.gz$"> ForceType text/css Header set content-encoding: gzip </FilesMatch>

测试http://127.0.0.1/doc/test.css和http://127.0.0.1/doc/test.css.gz ,看看你得到了什么结果。

cat /etc/apache2/mods-enabled/mime.conf | head -n 30 <Ifmodulee mod_mime.c> # # TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type. # TypesConfig /etc/mime.types # # AddType allows you to add to or override the MIME configuration # file mime.types for specific file types. # #AddType application/x-gzip .tgz # # AddEncoding allows you to have certain browsers uncompress # @R_485_4045@ion on the fly. Note: Not all browsers support this. # Despite the name similarity,the following Add* directives have # nothing to do with the FancyIndexing customization directives above. # AddEncoding x-compress .Z AddEncoding x-gzip .gz .tgz AddEncoding x-bzip2 .bz2 # # If the AddEncoding directives above are commented-out,then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-bzip2 .bz2

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐