项目

通用

个人资料

操作

将 W3C 标记验证器与 Lighttpd 配合使用

这是一个快速指南,可帮助您配置 w3c-markup-validator 以与 Lighttpd 配合使用。

'''本示例在 Ubuntu Feisty 和 Ubuntu Gutsy 上测试通过(但也应适用于任何基于 Debian 的系统),并与 w3c-markup-validator v0.7.4 配合使用。'''

Lighttpd 不太懂 Apache

前段时间,我将许多 Web 服务器从 Apache 切换到了 Lighttpd(有些仍然使用 Apache,因为有 Subversion)。
当我这样做时,我很高兴看到几乎所有东西都完美运行——几乎。

唯一明显不起作用的是 w3c-markup-validator。如果您在内部网络中开发,无法直接从外部访问,那么使用在线版本并不总是可行的选择。

w3c-markup-validator 是通过一些仅适用于 Apache 的指令配置的。我费了很大力气,试图找出如何在 Lighttpd 中重现配置(我甚至不确定是否可能)。

开始吧!

首先,您需要启用几个模块

lighty-enable-mod alias
lighty-enable-mod cgi
invoke-rc.d lighttpd restart

然后,在 {{{/etc/lighttpd/conf-available/}}} 中创建一个新的配置文件。例如,将其命名为 {{{20-w3c-markup-validator.conf}}} (您需要它在其他模块之后启动)。

将这些行粘贴到文件中

## W3C markup validator service

$HTTP["remoteip"] == "127.0.0.1" {
        alias.url += (
                "/validator/checklink" => "/usr/lib/cgi-bin/checklink",
                "/validator/check" => "/usr/lib/cgi-bin/check",
                "/validator/" => "/usr/share/w3c-markup-validator/html/" 
        )

        cgi.assign += ("/check" => "")
}

对于仅使用 lighttpd 的 Debian 用户(其他发行版不清楚),还有其他事情要做

以 root 身份编辑:/etc/w3c/validator.conf

 Allow Private IPs = yes 

然后始终以 root 身份

# cd /etc/apache2/conf.d
# cp  w3c-markup-validator.conf  w3c-markup-validator.conf.bak
# rm -rf  w3c-markup-validator.conf
# ln -s /etc/w3c/apache.conf w3c-markup-validator.conf

在 Debian unstable 中,将以上行替换为

# ln -s /etc/w3c/apache.conf w3c-markup-validator.conf


# ln -s /etc/w3c/w3c-markup-validator-apache.conf w3c-markup-validator.conf

最后,启用这个新模块

lighty-enable-mod w3c-markup-validator
invoke-rc.d lighttpd restart

现在,尝试访问 {{{http://localhost/validator/}}},您就完成了。

dotfolios 近 13 年前更新 · 11 次修订