在LispBox环境上安装 portableaserve 的详细过程

在LispBox环境上安装 portableaserve 的详细过程

打算边读边实践地学习 《实用 Common Lisp 编程》中 web 编程那部分内容,于是按照书上所讲的准备先搭建一个 web 开发环境,书中的例子推荐使用 portableaserve ,开源软件很不错。

到这里 http://portableaserve.sourceforge.net 下载了软件包回来,解压到 LispBox 目录下,浏览一下readme 文档,按照文档说明进行安装,在 REPL 界面上直接用 load 调用,结果返回错误:“There is no package named "FUNDAMENTAL-BINARY-INPUT-STREAM" .” ,看来还需要先安装一个这个包,现在就需要用到 LispBox 自带的 quicklisp 来进行安装这个包 “FUNDAMENTAL-BINARY-INPUT-STREAM” 了。

参见这篇文档(在 LispBox 中使用 quicklisp 

具体就两条命令,看截图更清楚:

然后再执行这个命令试试: (ql:quickload "FUNDAMENTAL-BINARY-INPUT-STREAM"),结果失败,显示如下:

既然这样,让我们再想想办法,先去查查这个包是个什么东东,一查发现这应该是 gray streams ,而不是单独这个名字,ok,那就安装gray streams ,见下图:

装了个 trivial-gray-streams ,然后继续装 portableaserve 的 INSTALL.lisp ,结果又出现问题了,显示如下:

没办法导入?看来还需要多搜集一些周边的知识,否则就这么试一步,错一步的,再继续下去就没耐心了,暂停安装,先充电去也===========||||||||||||

还是不死心,切换到我的PC上,把 CCL 切换到 SBCL ,结果发现可以安装 portableaserve 了,不过安装都磕磕碰碰、跌跌撞撞的,这里是截图:


最后按照书中的说明执行下面这个语句也没成功:

(defpackage :com.gigamonkeys.web
            (:use :cl :net.aserve :com.gigamonkeys.html))

直接去作者网站查查,看看有什么勘误,发现作者已经把英文版全部公布到网上了(第26章的链接如下:http://www.gigamonkeys.com/book/practical-web-programming-with-allegroserve.html),

这里是关于web开发的内容:

But before I get to that, you need to know how to start AllegroServe and set it up to serve a few files. The first step is to load the AllegroServe code into your Lisp image. In Allegro, you can simply type (require :aserve). In other Lisps (or in Allegro), you can load PortableAllegroServe by loading the file INSTALL.lisp at the top of the portableaserve directory tree. Loading AllegroServe will create three new packages, NET.ASERVE, NET.HTML.GENERATOR, and NET.ASERVE.CLIENT.8

After loading the server, you start it with the function start in the NET.ASERVE package. To have easy access to the symbols exported from NET.ASERVE, from COM.GIGAMONKEYS.HTML (a package I'll discuss in a moment), and from the rest of Common Lisp, you should create a new package to play in like this:

CL-USER> (defpackage :com.gigamonkeys.web
            (:use :cl :net.aserve :com.gigamonkeys.html))
#<The COM.GIGAMONKEYS.WEB package>
Now switch to that package with this IN-PACKAGE expression:

CL-USER> (in-package :com.gigamonkeys.web)
#<The COM.GIGAMONKEYS.WEB package>
WEB> 
Now you can use the exported names from NET.ASERVE without qualification. The function start starts the server. It takes quite a number of keyword parameters, but the only one you need to pass is :port, which specifies the port to listen on. You should probably use a high port such as 2001 instead of the default port for HTTP servers, 80, because on Unix-derived operating systems only the root user can listen on ports below 1024. To run AllegroServe listening on port 80 on Unix, you'd need to start Lisp as root and then use the :setuid and :setgid parameters to tell start to switch its identity after opening the port. You can start a server listening on port 2001 like this:

WEB> (start :port 2001)
#<WSERVER port 2001 @ #x72511c72>

根据尝试的经过和结果,似乎可以得出一个结论:关于Web 开发的具体代码,作者只在 AllegroServe 环境下使用、验证过,没有在其他CommonLisp环境下(包括作者在前面章节使用的LispBox)验证过。

 

转载于:https://my.oschina.net/freeblues/blog/102803

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值