Make Apache virtual directory from the contents of a zip file

假如想象 提交于 2019-12-20 03:03:00

问题


I have a couple of compressed zip file with static HTML content (e.g. a directory tree of documentation with several static html pages that link to each other, images, css, etc.) For instance, the javadoc zip file serves as an equivalent example for my purpose.

My question is, if there's an apache module that would allow apache to "mount" a zip file as a virtual directory, whose contents are those of the zip file. The operating system in which I'm hosting apache is Mac OS X Snow Leopard.


回答1:


There is a zip filesystem for FUSE, which is supported on OS X via the MacFUSE project. This will let you mount a zip file via the mount command, thus allowing Apache -- or any other application -- to access its contents as a normal directory.

I don't have my Mac handy at the moment so I can't actually test it out.




回答2:


I'm not aware of any existing Apache modules to do this, but you could implement it without touching Apache internals by adding a CGI script which handles access to ZIP archives:

Action zip-archive /cgi-bin/ziphandler.cgi
AddHandler zip-archive .zip

This will make ziphandler.cgi get called for all accesses to .zip files, or (more importantly!) to files in "directories" under .zip files. From there, it should be pretty straightforward.




回答3:


Using proxy_http you can forward requests to Jetty which will serve any ZIP file.

Download Jetty Runner from here: http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-runner

You can run it using e.g. java -jar jetty-runner-9.3.0.M2.jar --port 8082 myZIPFile.zip. Now set up Apache to forward requests to localhost:8082. You can do that for even only one subdirectory.



来源:https://stackoverflow.com/questions/8420295/make-apache-virtual-directory-from-the-contents-of-a-zip-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!