Lighttpd howto setup cgi-bin access for perl programs
Lighttpd has mod_cgi module that allows you running perl and other server side programs (cgi-bin).
Step #1: Create a cgi-bin directory
First create cgi-bin directory for your domain.
# mkdir -p /home/lighttpd/theos.in/http/cgi-bin
Step # 2: Load mod_cgi module
Open lighttpd configuration file using text editor such as vi:
# vi /etc/lighttpd/ligttpd.conf
Now append or modify text as follows so that support for mod_cgi get loaded:
server.modules += ( "mod_cgi" )
Find out your virtual server configuration and append following text:
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( ".pl" => "/usr/bin/perl" )
}
Here is complete my config code:
$HTTP["host"] =~ "theos.in" {
server.document-root = "/home/lighttpd/theos.in/http"
server.errorlog = "/var/log/lighttpd/theos.in/error.log"
accesslog.filename = "/var/log/lighttpd/theos.in/access.log"
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( ".pl" => "/usr/bin/perl" )
}
}
Step # 3:Restart lighttpd
Restart lighttpd webserver
# /etc/init.d/lighttpd restart
Step # 4:Sample perl program
Create file/perl program /home/lighttpd/theos.in/http/cgi-bin/sample.pl:
#!/usr/bin/perl
print "Content-Type: text/plain", "\n\n";
print "Hi there! This is a sample perl program!!!", "\n";
Save and execute the program (http://yourdomain.com/cgi-bin/sample.pl).
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Lighttpd install perl, mysql support in chrooted jail
- Ultimate Lighttpd webserver security
- Lighttpd restrict or deny access by IP address
- The rise of bots, spammers, crack attacks and libwww-perl
- Lighttpd block wget useragent for specific urls
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



Recent Comments
Today ~ 5 Comments
Today ~ 12 Comments
Today ~ 2 Comments
Today ~ 18 Comments
Today ~ 5 Comments