# lighttpd with cgi-bin apps does not work for me

## awx

I hope someone here can help me with this problem. I don't know a whole lot about cgi-bin stuff or lightttpd so there's probably an easy answer to this, but....

I want to run apcupsd and cgiirc using lighttpd as the web server but this doesn't work. FYI, phpsysinfo does work fine thru lighttpd with php 5.0.5 though it is not a cgi-bin app.

The history here is this:

I had apache2 installed, it worked.

Installed apcupsd and it worked with apache2.

Installed lighttpd and switched from apache2 to it, apcupsd stopped working (the web part only).

Removed apache2 and all dependencies.

installed cgiirc and it does not work

By "not working", I mean the URL that worked when apache2 was running (for instance http://arts-antec/apcupsd/) now returns a 404 error with lighttpd. I've tried calling the files directly but that hasn't worked either, (calling http://arts-antec/apcupsd/multimon.cgi results in a 403 error).

Lighttpd was installed with +fastcgi but I'm not really sure what is best. This server is only rarely used by me so performance is not important. I could remove fastcgi if it would help.

Things that I have tried:

searching the Gentoo forums

editting /etc/vhosts/webapp-config to specify lighttpd as server

remerging cgiirc

looking through lighttpd config files for something relating to my problem (including the mod_cgi and mod_fastcgi configs but I don't have any idea what should be in those).

What can I do to get these two apps working?

----------

## awx

anyone? any ideas of things to try?

----------

## tutaepaki

Have you tried a simple cgi script like printenv.cgi in the cgi directory to see if that works? The will either eliminate, or confirm lighthttpd as the source of the problem.

----------

## awx

I don't have any cgi by that name. If it matters, I no longer have gentoo-webroot-default (or whatever it's name is) installed. Where can I get this cgi?

My /var/www/localhost/cgi-bin/ dir only contains a "cgiirc-0.5.7" directory.

----------

## tutaepaki

It doesn't have to be that one in particular. Try something like:

```
#!/usr/bin/perl

#

print "Content-type: text/html\n\n";

print "<html><head><title>A test cgi</title></head>\n";

print "<body><h1 align=\"center\">A test cgi</h1>\n";

print "<h2>This is a test page to see if lighthttpd does CGIok</h2>\n";

print "</body></html>\n";

exit;
```

Did you change the "server.document.root" parm? By default, it's set to /var/www/localhost/htdocs. So you won't be able to access any cgi in /var/www/localhost/cgi-bin. (you'll get a 404)

----------

## awx

No, I did not change the root pref in lighttpd.

I copied that HTML code into a new doc with nano and saved it to /var/www/localhost/cgi-bin/text.cgi and it can be accessed from this URL "http://arts-kurobox/cgi-bin/test.cgi". So it is working.

Also, apcupsd does not put it's files in /var/www/localhost/cgi-bin. Instead, they are in /var/www/localhost/htdocs/apcupsd/ as 4 xxx.cgi files. cgiirc is in cgi-bin but it also put an empty folder in htdocs with only two .webapp files.

----------

## awx

Ahh, I am able to call cgi-irc with this URL http://arts-kurobox/cgi-bin/cgiirc-0.5.7/irc.cgi

But will I have to hardcode the version number into my URL like that? Is that what's intended?

apcupsd still cannot be called, either with the old URL which worked with apache nor by calling the .cgi files directly.

----------

## tutaepaki

You could either create an index page with links to the pathname with the version in it, or create a symbolic link in the cgi bin directory. Call it something like cgiirc and link it to the real directory. 

It looks like your docroot is set to /var/www/localhost, so you should specify /htdocs/apcupsd/xxxx.cgi to access the apcupsd cgi scripts.

----------

## awx

 *tutaepaki wrote:*   

> It looks like your docroot is set to /var/www/localhost, so you should specify /htdocs/apcupsd/xxxx.cgi to access the apcupsd cgi scripts.

 

But that doesn't work.   :Sad: 

----------

## tutaepaki

Possibly it could be permissions on the directories/files? The ID your lighthttpd server runs as will need read/execute on the apcupsd dirs & files.

----------

## awx

 *tutaepaki wrote:*   

> Possibly it could be permissions on the directories/files? The ID your lighthttpd server runs as will need read/execute on the apcupsd dirs & files.

 

I believe they are correct but I will double check.

----------

