在LispBox環境上安裝 portableaserve 的詳細過程

在LispBox環境上安裝 portableaserve 的詳細過程 html

打算邊讀邊實踐地學習 《實用 Common Lisp 編程》中 web 編程那部份內容,因而按照書上所講的準備先搭建一個 web 開發環境,書中的例子推薦使用 portableaserve ,開源軟件很不錯。 web

到這裏 http://portableaserve.sourceforge.net 下載了軟件包回來,解壓到 LispBox 目錄下,瀏覽一下readme 文檔,按照文檔說明進行安裝,在 REPL 界面上直接用 load 調用,結果返回錯誤:「There is no package named "FUNDAMENTAL-BINARY-INPUT-STREAM" .」 ,看來還須要先安裝一個這個包,如今就須要用到 LispBox 自帶的 quicklisp 來進行安裝這個包 「FUNDAMENTAL-BINARY-INPUT-STREAM」 了。 shell

參見這篇文檔(在 LispBox 中使用 quicklisp express

具體就兩條命令,看截圖更清楚: 編程

而後再執行這個命令試試: (ql:quickload "FUNDAMENTAL-BINARY-INPUT-STREAM"),結果失敗,顯示以下: ide

既然這樣,讓咱們再想一想辦法,先去查查這個包是個什麼東東,一查發現這應該是 gray streams ,而不是單獨這個名字,ok,那就安裝gray streams ,見下圖: 學習

裝了個 trivial-gray-streams ,而後繼續裝 portableaserve 的 INSTALL.lisp ,結果又出現問題了,顯示以下: 網站

沒辦法導入?看來還須要多蒐集一些周邊的知識,不然就這麼試一步,錯一步的,再繼續下去就沒耐心了,暫停安裝,先充電去也===========|||||||||||| ui

仍是不死心,切換到個人PC上,把 CCL 切換到 SBCL ,結果發現能夠安裝 portableaserve 了,不過安裝都磕磕碰碰、跌跌撞撞的,這裏是截圖: this


最後按照書中的說明執行下面這個語句也沒成功:

(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)驗證過。

相關文章
相關標籤/搜索