Return to index
The Slug is a pet name for a nice piece of embedded hardware called NSLU2
and is made by Linksys. The Slug runs on Linux and
most Linux programs can be compiled to run on the Slug. The Slug is inexpensive (less then 100 US dollars) and does not consume
a lot of power. Which makes it perfect to run as a personel webserver.
Before you can start running your own Linux programs on the Slug you have to Unslung it first. If you are Dutch you should check out HCC Unix Unslung Demo
Log into your slug and go to your home directory.(The directory were you store your files)
Download the program with:
Finally add some HTML code to your page, look at the examples.
Webalizer 2.01 is a nice visual program that keeps track of your web statistics. I wrote this article to show how you can compile the Webalizer program on the NSLU2.
The program is not so easy to compile, because webalizer seems to have troubles finding the right libraries.
The other problem is that the standard DBase library on the slug is not V1.85 compatible. So that we have to compile BerkeyDB too, which will be explained later.
Webalizer uses the log files of your http daemon, this can be both Apache or Httpd and probably others. If you are using Apache then you can just use "ipkg install webalizer" to install the program on your NLSU2. If you want to use al the features of webalizer in combination with Thttpd then you need to compile webalizer with DNS support. This is because Thttpd does not have build in reverse DNS lookup. Also if you want to modify the source to your own wishes you need to compile the program.
First we need the developement enviroment again, if you have not installed it yet then now it is the time:
Be patient this will install at least 130 mb in programs and this will take a while.
Make sure that libgd is installed. If not install with:
Next we have to install the BerkeleyDB, Webalizer uses this program to look up where you visitors are coming from. This step can be skipped is you do not want to keep track of where you visitors are visiting from. Compiling the BerkeleyDB will take at least 45 minutes. Go to your home directory and download the BerkeleyDB:
Unzip the file and change the directory with:
Now we need to run the configure program with the following parameters:
Build the library and be very patient with:
Now we can download the Webalizer program:
The program has trouble finding the libraries, so run configure with the following options
Before we can run make, we have to modify the Makefile else the linker has problems to finding the libraries.
These lines should be modified and look like this:
Next we compile and install the program:
Your program is now ready for use.
Still working on this one. Work is in progress but I still have some problems to solve.
download GeoIP.dat from http://www.maxmind.com/app/ip-location
download GeoIP clib from same site http://geolite.maxmind.com/download/geoip/api/c/
More soon
Common Gateway Interface is a way of creating dynamic html. Depending on the information available it will create and output an modified html to the browser. CGI can also output other formats like images, my visitors counter works with CGI
Ok, so how does CGI work. When you type in an URL in your browser, your browser will try to download the file from the server and display it on your computer. Some times the requested URL is not a file but a program, this is the case with CGI, but also with PHP and some other formats. When the requested file is a program, the complete URL that your browser is requestion for is send to the program, the program then assembles a file which get returned to the browser and is displayed, which gives you the freedom to create whatever you want to other to see on his/her browser
Before we begin you have to create a directory cgi-bin in your web root, for example /www/cgi-bin. Next you have to tell your server that you want to use CGI programs. In the case of Thttpd, the server I am using for the NLSU2, edit etc/thttpd.conf (etc/thttpd.conf is the standard configuration file, you might have created a different one if you have more then one thttpd program running, for example I am using /etc/thttpd-website.conf) and change the line cgipat to cgipat=/cgi-bin/* (if you are using virtual hosts like me use cgipat=/*/cgi-bin/* instead)
Now we are ready to create our first CGI program. Make sure you have the development setup again (see the other 2 articles). Make a directory called c in your home directory. And start editing a file called gateway.c (with vi or any other editor you want to use)
Compile the file with:
Copy the file gateway.cgi to your cgi-bin directory. Make the file world readable with chmod 755 gateway.cgi. And run the file from your browser with <your-domain>/cgi-bin/gateway.cgi
If it doens't work on yours, here is how it should look
While compiling C is not problem for the gcc compiler, if you try to compile a C++ program it will give you a million of errors. This is because gcc cannot find the right libraries. Try compiling your C++ program with gcc filename.cpp -lstdc++ -Xlinker -rpath -Xlinker /opt/lib -o filename And run the program with ./filename
Return to index
| |||||
| |||||