官术网_书友最值得收藏!

  • Lighttpd
  • Andre Bogus
  • 259字
  • 2021-08-25 18:06:21

Chapter 3. More Virtual Hosting and CGI

In this chapter, we will learn:

  • How to set up virtual hosting
  • How to install MySQL server and configure with Lighttpd modules
  • How to configure SCGI and FastCGI with Lighttpd modules

Suppose that we want to host a lot of sites without restarting Lighttpd whenever a new site comes and goes. Given that all sites share the same configuration, we can do this using the line of mod_*vhost modules. To use them, we may include one of the following lines:

server.modules += ("mod_simple_vhost") # for simple virtual hosting
server.modules += ("mod_evhost") # for extended virtual hosting
server.modules += ("mod_mysqlvhost") # for virtual hosting with a MySQL database

The most basic, but an already usable module is mod_simple_vhost. With this simple virtual hosting solution, all we have to do is to supply a server root for virtual hosting, a default host name, and a document root, like this:

simple-vhost.server-root = "/var/www/vhost/"
simple-vhost.default-host = "myvirtualhost.net"
simple-vhost.document-root = "htdocs"

mod_simple_vhost intercepts each request and constructs a document path out of the server root, the host name (either from the request or the default), the document root, and the file path. Given http://some.virtualhost.net/some/file.html as the request URL, mod_simple_vhost would construct the path as:

"/var/www/vhost"/"some.virtualhost.net"/"htdocs"/"some/file.html"

If the file could not be found, mod_simple_vhost will see if the directory some.virtualhost.net exists in the server root . If so, it will return a file not found error (HTTP code 404). Otherwise, it will not even answer the request, as the domain is obviously not on this server.

主站蜘蛛池模板: 新沂市| 赤水市| 海淀区| 武冈市| 白朗县| 托克逊县| 嘉兴市| 邵武市| 崇明县| 宁都县| 灌阳县| 淅川县| 博白县| 包头市| 南和县| 盘山县| 榆中县| 临夏县| 黄石市| 伊通| 仁怀市| 无为县| 阿拉尔市| 刚察县| 天全县| 大同市| 庆元县| 临湘市| 镇雄县| 景东| 鱼台县| 吴堡县| 个旧市| 兴仁县| 乐山市| 吉木乃县| 天气| 新兴县| 东乡县| 德化县| 徐闻县|