How to setup a webserver in common lisp?
Asked Answered
H

4

15

Several months ago, I was inspired by the magnificent book ANSI Common Lisp written by Paul Graham, and the statement that Lisp could be used as a secret weapon in your web development, published by the same author on his blog. Wow, that is amazing. That is something that I have been looking for long time. The author really developed a successful web applcation and sold it to Yahoo.

With those encouraging images, I determined to spend some time (1 year or 2 year, who knows) on learning Common Lisp. Maybe someday I will development my web application and turn into a great Lisp expert. In fact, this is the second time for me to get to study Lisp. The first time was a couple of years ago when I was fascinated by the famous book SICP but found later Scheme was so unbelievably immature for real life application.

After reading some chapters of ANSI Common Lisp, I was pretty sure that is a great book full of detailed exploration of Common Lisp. Then I began to set up a web server in Common Lisp. After all, this should be the best way if you want to learn something. Demonstrations are always better than definations.

As suggested by the book Practical Common Lisp (by the way, this is also a great book), I chose to install AllegroServe on some Common Lisp implementation. Then, from somewhere else, I learned that Hunchentoot seems to be better than AllegroServe. (I don't remember where and whom this word is from. So don't argue with me.)

Ironically, you know what, I never could installed the two packages on any Common Lisp implementation. More annoyingly, I even don't know why. The machine always spit up a lot of jargon and lead me into a chaos. I've tried searching the internet and have not found anything.

Could anybody who has successfully installed these packages in Linux tell me how you did it? Have you run into any trouble? How did you figured out what is wrong and fixed it? The more detailed, the more helpful.

Housewifery answered 24/5, 2010 at 7:29 Comment(6)
Why is scheme too immature for a real life application? It's used by plenty of real life applications.Ninety
Thank you for the reply. Scheme has plenty of real life applications? Could you name some for me?Housewifery
Here's some examples of Scheme in real-world use: en.wikipedia.org/wiki/Scheme_%28programming_language%29#Usage (the first paragraph talks about academia, but the second is about "real-world")Vitta
#291533Ninety
I can't help much if you don't say what you tried or what you saw, but I had no trouble installing these in the same way I install all software on my Linux box: sudo apt-get install sbcl hunchentoot cl-aserve.Stan
The scheme report per se does not define all you'd want for "a real-life application", e.g. a simple web server. The things that are missing are available in the "major" scheme systems available, in "non-standard" ways.Slacks
A
6

Have you tried these instructions?

I already had a working SBCL installation so I've only followed the second half of the instructions. It sets up a very minimal web app, so it lets you see just how to structure your own web app.

These instructions might not be quite what you're looking for - they're for setting up a web server (on Ubuntu) with remote interaction with emacs/SLIME, but I guess "remote interaction" could just as well mean localhost.

Aec answered 24/5, 2010 at 9:10 Comment(1)
It works!!! Thanks a million. It is really helpful for Lisp newbies like me. I will write the installation steps down and put it here.Housewifery
H
6

Basically, these installation steps are from this article A Simple Lisp Webapp for beginners, recommended by Frank Shearar (thanks again). But I didn't follow the exact steps because (1) I'd like to install Common Lisp with a local user; (2) I am not familiar with a few things the author mentioned. You can check out the original article or you can just follow me here. I am afraid my instructions are much easier to follow. :)

Three packages need to be downloaded before installation. sbcl binary and source packages can be downloaded here, and smanek package can be downloaded here.

  • sbcl-1.0.38-x86-linux-binary.tar.bz2

  • sbcl-1.0.38-source.tar.bz2

  • smanek-trivial-lisp-webapp-3681c1

Note: The version number may have changed when you see this essay. So don't bother to get the exact packages. However, this is right packages working for me.

Here is what I do (replace YOURPATH with your real path and I assume you are using BASH):

1. Install the binary sbcl package

tar jxf sbcl-1.0.38-x86-linux-binary.tar.bz2

cd sbcl-1.0.38-x86-linux

INSTALL_ROOT=YOURPATH sh install.sh

cd ..

Well, the binary sbcl package has been installed now. When the install program complains with something like "no manual found", it is OK since the manual stuff is not included in the binary package. Let it be.

2. Set the PATH and SBCL_HOME

export PATH=YOURPATH/bin/:$PATH

export SBCL_HOME=YOURPATH/lib/sbcl/

3. Install the source sbcl package

tar jxf sbcl-1.0.38-source.tar.bz2

cd sbcl-1.0.38

sh make.sh

export SBCL_HOME=''

INSTALL_ROOT=YOUROTHTERPATH sh install.sh

cd ..

NOTE: You may need to specify another directory for installation, or it will be installed into the same directory the binary sbcl resides in.

4. Set the PATH and SBCL_HOME

export PATH=YOUROTHERPATH/bin/:$PATH

export SBCL_HOME=YOUROTHERPATH/lib/sbcl/

5. Install the smanek package

unzip smanek-trivial-lisp-webapp-36816c1.zip

cd smanek-trival-lisp-webapp-36816c1

cd scripts

./startserver.sh

When it says "Webserver started on port 8080", you can visit "http://localhost:8080" in your web browser. It is there, right?

6. A few notes

  • After putting the three packages in one directory, you can run the above scripts one by one or in a batch. Remember to replace the PATHs with your real paths.
  • I suspect Shaneal Manek has hacked the asdf and hunchentoot packages a lot, as I didn't find anything in the $HOME/.sbclrc and $HOME/.sbcl. Thank you, Shaneal Manek, you've helped a lot of people a lot.
  • I still feel hateful toward those who always says a lot but does a little. Even people are angry, it is still evident that it is what they say matters, not how they say it. Nevertheless, I was wrong to say something bad in a bad mood.
Housewifery answered 25/5, 2010 at 3:45 Comment(1)
+1 for telling us exactly how you got things working. Thanks!Aec
L
2

5 years later.

it very easy with quicklisp. I assume you have installed SBCL or other CL implementation.

  1. Go to your REPL and evalute

(ql:quickload :aserve)

  1. start AllegroServe

(net.aserve:start :port 8000)

  1. publish some HTML files

(net.aserve:publish-file :path "/" :file "~/hello.html")

  1. Go to http://localhost:8000/

Happy hacking!.

read more about Introduction to AllegroServe Tutorial

Laverty answered 26/10, 2017 at 6:47 Comment(0)
N
0

Paul Graham has, for starters :-)

I too have found Common Lisp a lot of work to get past step one. The environment is terrible when you're just getting started, there's not a clear One True Path to get to the point where you can bang in some code and see some results (like there is with Python, for example). Like you, I wasted a lot of time jumping from one implementation to another. So my advice is:

I suggest you just pick one and ignore all other advice until you get it going.

If you're not in the mood, just get Apache and write some PHP :-)

Ninety answered 24/5, 2010 at 7:39 Comment(7)
By the way, my answer is pretty brusque -- sorry for the tone, but your question is very aggressive.Ninety
@Matt -1 because two wrongs don't make a right. (I've also edited things a bit to make the asker seem a bit nicer)Copacetic
@Earlz: fair enough. I've made it a little more polite, and added some well-intended advice.Ninety
Making him seem nicer doesn't make him nicer. Is he your sister?Sparkman
I apologize for the agressive word I just said. Really, it is not good to speak or write in a bad mood. And thank you, Earlz.Housewifery
Actually, I don't know that Paul Graham ever has. In his writing, I've only ever heard him mention running FreeBSD or Mac OS X.Stan
@Ken: the original question has been changed (not by the OP) since I wrote my answer. I shall leave my answer here as I believe it answers at least part of the OP's question.Ninety

© 2022 - 2024 — McMap. All rights reserved.