我如何设置一个lighttpd服务器来提供一个主要的Apache服务器的所有图像/ JS / CSS文件?

我有一个Linux的Ubuntu的服务器上的Apache服务器。 我想configuration一个lighttpd服务器来提供所有的静态内容。

这是一个非常普遍的设置。 您可以通过Googlesearchfind许多高级指南。

但是对此的简要回答是编码相关的和服务器configuration相关的 。 您需要设置lightthd以与apache服务器类似的方式提供请求。 然后,你需要设置你的代码,从lighttpd服务器而不是Apache服务器查询你的images / js / css。

所以Apache服务器响应www.somesite.com,并在网页的请求源将会去css.somesite.com,js.somesite.com和images.somesite.com。 设置DNS将这三个子域指向您的lighttpd服务器。

您的DNS条目应该这样做(使用Alogging)

  • http://www.somesite.com – > apache服务器ip
  • css.somesite.com – > lighttpd服务器IP
  • js.somesite.com – > lighttpd服务器IP
  • images.somesite.com – > lighttpd ip服务器