【问题标题】:easy-acceptor ignoring :document-root option; not serving static fileseasy-acceptor 忽略 :document-root 选项;不提供静态文件
【发布时间】:2023-03-27 10:06:01
【问题描述】:

我正在尝试使用 Hunchentoot 从我的项目中的 www 目录提供静态文件。我的接受者定义为:

(defvar *acceptor* (make-instance 'easy-acceptor
        :port 4242
        :document-root (truename "./www/")))

然后我开始:

(start *acceptor*)

acceptor 有效,因为我可以使用define-easy-handler 创建一个根页面:

(define-easy-handler (index :uri "/") ()
  (with-html-output-to-string (_)
      (:html
       (:head
        (:title "Hello world")
       (:body
        (:h1 "Hello world!))))))

...当我浏览到 http://localhost:4242/ 时,我看到了那个页面。

但是我的www 目录没有提供静态文件。例如。如果我创建 www/jquery-3.2.1.min.js 并浏览到 http://localhost:4242/jquery-3.2.1.min.js 我会收到 404。

127.0.0.1 - [2017-08-11 08:08:02] "GET /jquery-3.2.1.min.js HTTP/1.1" 404 355 "-" "Mozilla/5.0 (X11; FreeBSD amd64; rv:54.0) Gecko/20100101 Firefox/54.0"

HELLOWORLD> (directory (make-pathname :directory '(:relative "www") :name :wild :type "js"))
(#P"/usr/home/duncan/code/helloworld/www/jquery-3.2.1.min.js")

【问题讨论】:

  • 我似乎无法重现该问题(除非我从 www 目录中删除权限)。
  • @jkiiski 哈! chmod -R 775 www 已修复。谢谢 :) (如果您提出答案,很高兴支持 + 接受您的建议)。

标签: common-lisp hunchentoot


【解决方案1】:

您必须确保目录及其中的文件具有适当的权限集。目录需要有执行x权限才能让服务器程序访问目录的内容,文件至少需要读取r权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-15
    • 2018-10-23
    • 2021-07-08
    • 2013-06-02
    • 2012-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多