Showing posts with label serveez-mg. Show all posts
Showing posts with label serveez-mg. Show all posts

Monday, January 24, 2011

Guile web madness: a mysql/php blog on serveez-mg -- take 1

Today's internet madness will be to set up a PHP/MySQL-based weblog on top of one of the Guile webservers.

The blog software for today will be b2evolution version 4.0.3.

The webserver for today will be serveez-mg version 0.2.  serveez-mg isn't really a Guile webserver, but, it is a software that I hacked on that has some Guile features, so I'm starting with what I know.

I'm starting off on my Fedora 14 box on x86_64.  I installed the mysql and phpMyAdmin packages.

So, b2evolution first says that you should use phpMyAdmin to make a database.  I could do this using the mysql command line tool, but, I'll need to get PHP working eventually.  May as well start now.


serveez-mg lacks an SAPI to use PHP directly, so I'm going to have to use it in cgi mode.

OK.

Part 1: setting up serveez-mg as a cgi-enabled webserver

On a Fedora 14 box, /var/www comes set up for Apache.  I don't really want to overwrite it, so I'll set up a parallel directory structure.

$ su 
$ mkdir /var/serveez-www
$ mkdir /var/serveez-www/html
$ mkdir /var/serveez-www/cgi-bin

serveez-mg needs a configuration file: `serveez.cfg'.

;; === Load convenience file  
(use-modules (serveez-mg lib))

;; === Greet the user
(printsln " "
          "** Welcome to Serveez" serveez-version
          "using Guile" guile-version
          (if have-debug
              "(debugging enabled)"
              ""
           ))

;; === Control protocol server for remote control.
(define-port! 'control-port `(
                              (proto . tcp)
                              (port . 42420)
                              (ipaddr . "127.0.0.11")
                              ))

(define-server! 'control-server)

(bind-server! 'control-port 'control-server)

(serveez-passwd "qruo5rZkLyu22")

;; === Web Server.
(define-port! 'http-port '(
                           ("proto"  . "tcp")
                           ("port"   . 80)
                           ("ipaddr" . "*")))

(define-server! 'http-server '(
              ;; standard properties                                           
              ("admin"        . "spike@xxxxxx.dyndns.org")
              ("host"         . "xxxxxx.dyndns.org")
              ("logfile"      . "http-access.log")
              ("logformat"    . "%h %i %u [%t] \"%R\" %c %l")
              ("indexfile"    . "index.html")
              ("docs"         . "/var/serveez-www/html")
              ("userdir"      . "public_html")
              ("type-file"    . "/etc/mime.types")             
              ("default-type" . "text/plain")
              ("nslookup"     . on)
              ("ident"        . yes)

              ;; cgi interface                                                 
              ("cgi-url"         . "/cgi-bin")
              ("cgi-dir"         . "/var/serveez-www/cgi-bin")
              ("cgi-application" . (("php"  . "php-cgi")))
                                   

Note in the last line how php applications are supposed to be associated with
the php-cgi interpreter.  This will be the source of some comedy in about four paragraphs.

(Wow, the default index file in serveez-mg tries to use the image internal-gopher-menu.  That's some old mojo.)

Part 2: making phpMyAdmin work

Fedora 14 installs phpMyAdmin to work gracefully with Apache and uses Apache aliases to translate paths to where it is installed.  That is not what I need.  So, I'm going to have to install phpMyAdmin by hand into serveez-mg's tree.

So I downloaded phpMyAdmin-3.3.9, unpacked it into the directory /var/serveez-www/cgi-bin/phpMyAdmin

In phpMyAdmin's manual, it tells you to unpack it, and then navigate to the setup folder.  I dutifully point my browser to http://127.0.0.1/cgi-bin/phpMyAdmin/setup and give it a try.  No joy.  So with about 20 minutes of debugging, I learn three important facts.
  1. serveez-mg only supports one default index file, which I've currently set to index.html.  I need to add support for multiple files so that I can put index.php as an alternate index file.
  2. That cgi-application alist in the serveez.cfg -- the one that is supposed to associate php files to the php-cgi executable -- does absolutely nothing.
  3. Thus, the only thing that would work in the cgi-bin directory are executable programs and shell scripts.
And, with dinner-time fast approaching, thus ends today's lesson.