domenica 31 maggio 2009

Hello World Wide Web: Part 2, deploying and testing

The binary helloweb is ready, now it's time to deploy it on the lighttpd web server and test it.

First, for convenience, we could move it to a directory that we decided to reserve to fastCGIs, for example /var/fastcgi.

Second we must instruct lighttpd to recognize helloweb has a fastCGI, so vi must set it up correctly; have a look at the directory /etc/lighttpd, it contains two other directories: conf-available and conf-enabled, the first one contains a collection of possible configuration files for different modules of the web server, the second one those effectively used. All the information about fastCGIs are in the file 10-fastcgi.conf and putting a symbolic link inside the conf-enabled directory makes this files actually used (after a web service restart).

A common 10-fastcgi.conf file looks like this:

server.modules += ( "mod_fastcgi" )

fastcgi.server = ( "/fastcgi/helloweb" =>;
((
"bin-path" => "/var/fastcgi/helloweb",
"socket" => "/tmp/helloweb.socket",
"check-local" => "disable"
)))

The line server.modules += ( "mod_fastcgi" ) loads the fastcgi module, the rest of the file instructs lighttpd about the usage of the fastcgi created in the previous post.
The instruction "/fastcgi/helloweb" informs the web server that an http request of URLs starting with /fastcgi/helloweb must be redirect to the fastcgi specified by the parameter "bin-path" (i.e. /var/fastcgi/helloweb).

Once modified the file, we must create a symbolic link to it in the directory conf-enabled:

ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/10-fastcgi.conf

then we must restart the web server:

/etc/init.d/lighttpd restart

Now it's time to test the program: point your browser to the URL http://ip-of-your-server/fastcgi/helloweb where ip-of-your-server is the ip of the server running lighttpd (if you don't know your ip, simply digit ifconfig at the prompt). If everything went well an exciting ""Hello World Wide Web" will appear.

Note: I had some problem in deploying the fastcgi because initially I put "fastcgi.server =" and "( "/fastcgi" =>" in two different lines in the configuration file, joining them in a single line made everything working well.

References: http://redmine.lighttpd.net/wiki/lighttpd/Docs%3AModFastCGI

Nessun commento:

Posta un commento