Midgard with Lighttpd

Posted on 2008-04-22 11:05:55 EEST.

Please. Read the whole this simple howto. It's adressed for developers who would like to have Midgard and Midgard2 available as web services on the same machine. Of course, you may still install or compile Apache 1.3 as the second web server.

First of all you need to install and configure Lighttpd web serwer. On debian I installed it using apt-get:

apt-get install lighttpd

Do not forget to stop Apache before installing lighttpd. If you do not, dpkg will return with failure status as lighttpd tries to bind to port 80 by default when package is installed.

Also, you need to have php5 compiled with fast-cgi support. Again, on debian install it quickly:

apt-get instal php5-cgi

Edit cgi's php.ini file (/etc/php5/cgi/php.ini), and add midgard support:

extension=midgard2.so
midgard.configuration="midgard"
midgard.http="on"

Then configure your new web server. I found these two sites very helpful to configue lighttpd server:

Later on, you need to install Midgard2 from trunk, which is going to be released as alpha2 soon.

In my case, I configured lighttpd with these options:

server.port = 81

Just to have both, Apache and lighttpd available. You may of course use different port if you like.

Enable required modules, mod_rewrite and mod_fastcgi:

server.modules              = (
        "mod_access",
        "mod_alias",
        "mod_accesslog",
        "mod_compress",
        "mod_rewrite",
        "mod_fastcgi",
)

Configure fastcgi:

fastcgi.server = (
    ".php" => (
            "localhost" =>
                    (
                            "socket" => "/tmp/php-fastcgi.socket",
                            "bin-path" => "/usr/bin/php5-cgi"
                    )
            )
    )

Configure virtual host:

$HTTP["host"] == "myhost" {
    server.port = 81
    server.document-root = "/var/lib/midgard/vhosts/myhost/8080"
    url.rewrite-once = ( "^(.*)\.*" => "midgard-root.php" )
}

I use virtual host on 8080 port with Apache, so I wanted to re use its DocumentRoot. You will change it of course, depending on your needs.

midgard-root.php file should be copied or symlinked from midcom's git repository. I do not have to remind that midcom itself should be installed and ready to use.

Do something you should never do in real life. It seems that lighttpd drops root privileges too quickly and php module is loaded with configured user and group privileges. At least I couldn't manage to open root's configuration files from system configuration directory( which is easily done with Apache ). To establish database connection(s) you must have all secret configuratoin readable for the whole world.

chmod 644 /etc/midgard-2.0/conf.d/*

After this, restart lighttpd:

/etc/init.d/lighttpd restart

And open http://myhost:81 with your favourite browser. If all went fine, you should have midcom's web page without style. Reason is that we do not make midcom-static exception in our hosts' rewrite condition.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS