Lighttpd + cgi-bin + C++

1. Lighttpd + cgi-bin + C++

Rodrigo Ferreira Valentim
engos

(usa openSUSE)

Enviado em 25/10/2007 - 10:35h

Olá pessoal do VOL!

Tenho um programa que funciona muito bem pelo apache, bastando fazer a configuração básica dele para cgi e deixando lá o programa, que vou chamar de "prog".

Ao tentar usar o lighttpd verifiquei que no arquivo de log diz que não pode ser encontrado o "prog", mas ele funciona sem problemas pelo apache com o mesmo usuário e grupo.

Abaixo segue meus arquivos de configuração e log, o que quero é simplesmente usar o lighttpd no lugar do apache para testes.


srv:/var/log/lighttpd# ls -la /usr/lib/cgi-bin/prog
-rwxr-xr-x 1 root root 5054817 2007-10-24 09:19 /usr/lib/cgi-bin/prog



# Debian lighttpd configuration file
#
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
# "mod_evasive"
)

server.document-root = "/var/www/"

server.errorlog = "/var/log/lighttpd/error.log"

index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )

accesslog.filename = "/var/log/lighttpd/access.log"

url.access-deny = ( "~", ".inc" )

alias.url = ("/cgi-bin/" => "/usr/lib/cgi-bin/")

debug.log-request-header = "enable"
debug.log-response-header = "enable"
debug.log-request-handling = "enable"
debug.log-file-not-found = "enable"

server.port = 8081

server.pid-file = "/var/run/lighttpd.pid"

dir-listing.encoding = "utf-8"
server.dir-listing = "enable"

server.username = "www-data"
server.groupname = "www-data"

$HTTP["remoteip"] =~ "127.0.0.1" {
alias.url += (
"/doc/" => "/usr/share/doc/",
"/images/" => "/usr/share/images/"
)
$HTTP["url"] =~ "^/doc/|^/images/" {
dir-listing.activate = "enable"
}
}

include_shell "/usr/share/lighttpd/create-mime.assign.pl"

include_shell "/usr/share/lighttpd/include-conf-enabled.pl"




srv:/etc/lighttpd/conf-enabled# ls -la
total 8
drwxr-xr-x 2 root root 4096 2007-10-16 15:13 .
drwxr-xr-x 4 root root 4096 2007-10-25 10:25 ..
lrwxrwxrwx 1 root root 40 2007-10-16 15:13 10-cgi.conf -> /etc/lighttpd/conf-available/10-cgi.conf
srv:/etc/lighttpd/conf-enabled#




srv:/etc/lighttpd/conf-available/10-cgi.conf

server.modules += ( "mod_cgi" )

alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )

$HTTP["host"] == "localhost" {
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
}
}

$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
}

cgi.assign = (
".pl" => "/usr/bin/perl",
".php" => "/usr/bin/php-cgi",
".py" => "/usr/bin/python",
"" => "",
)





srv:/var/log/lighttpd/access.log

192.168.XXX.XXX 192.168.XXX.XXX:8081 - [25/Oct/2007:10:13:30 -0300] "GET /cgi-bin/prog HTTP/1.1" 404 345 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1)"




srv:/var/log/lighttpd# vi error.log

2007-10-25 10:13:19: (log.c.135) server stopped
2007-10-25 10:13:20: (log.c.75) server started
2007-10-25 10:13:30: (request.c.291) fd: 6 request-len: 441
GET /cgi-bin/prog HTTP/1.1^M
Host: 192.168.XXX.XXX:8081^M
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (De
bian-2.0.0.6-0etch1)^M
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/
*;q=0.5^M
Accept-Language: en-us,en;q=0.5^M
Accept-Encoding: gzip,deflate^M
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7^M
Keep-Alive: 300^M
Connection: keep-alive^M

2007-10-25 10:13:30: (response.c.202) -- splitting Request-URI
2007-10-25 10:13:30: (response.c.203) Request-URI : /cgi-bin/prog
2007-10-25 10:13:30: (response.c.204) URI-scheme : http
2007-10-25 10:13:30: (response.c.205) URI-authority: 192.168.XXX.XXX:8081
2007-10-25 10:13:30: (response.c.206) URI-path : /cgi-bin/prog
2007-10-25 10:13:30: (response.c.207) URI-query :
2007-10-25 10:13:30: (response.c.257) -- sanatising URI
2007-10-25 10:13:30: (response.c.258) URI-path : /cgi-bin/prog
2007-10-25 10:13:30: (mod_access.c.135) -- mod_access_uri_handler called
2007-10-25 10:13:30: (response.c.372) -- before doc_root
2007-10-25 10:13:30: (response.c.373) Doc-Root : /var/www/
2007-10-25 10:13:30: (response.c.374) Rel-Path : /cgi-bin/prog
2007-10-25 10:13:30: (response.c.375) Path :
2007-10-25 10:13:30: (response.c.423) -- after doc_root
2007-10-25 10:13:30: (response.c.424) Doc-Root : /var/www/
2007-10-25 10:13:30: (response.c.425) Rel-Path : /cgi-bin/prog
2007-10-25 10:13:30: (response.c.426) Path : /var/www/cgi-bin/prog
2007-10-25 10:13:30: (response.c.443) -- logical -> physical
2007-10-25 10:13:30: (response.c.444) Doc-Root : /var/www/
2007-10-25 10:13:30: (response.c.445) Rel-Path : /cgi-bin/prog
2007-10-25 10:13:30: (response.c.446) Path : /usr/lib/cgi-bin/, /usr/lib/cgi-bin/prog
2007-10-25 10:13:30: (response.c.463) -- handling physical path
2007-10-25 10:13:30: (response.c.464) Path : /usr/lib/cgi-bin/, /usr/lib/cgi-bin/prog
2007-10-25 10:13:30: (response.c.520) -- file not found
2007-10-25 10:13:30: (response.c.521) Path : /usr/lib/cgi-bin/, /usr/lib/cgi-bin/prog
2007-10-25 10:13:30: (response.c.111) Response-Header:

HTTP/1.1 404 Not Found^M
Content-Type: text/html^M
Content-Length: 345^M
Date: Thu, 25 Oct 2007 13:13:30 GMT^M
Server: lighttpd/1.4.13^M
^M



  


2. Consegui!

Rodrigo Ferreira Valentim
engos

(usa openSUSE)

Enviado em 25/10/2007 - 13:51h

Estava redirecionando a cgi para o diretório (como no apache), mas no caso do lighttpd é necessário redirecionar para a cgi em si.

Verifique como ficou meu arquivo:

srv:/etc/lighttpd# cat conf-available/10-cgi.conf

## CGI programs allow you to enhance the functionality of the server in a very
## straight and simple way..
##
## Documentation: /usr/share/doc/lighttpd-doc/cgi.txt
## http://www.lighttpd.net/documentation/cgi.html

server.modules += ( "mod_cgi" )

alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )

$HTTP["host"] == "localhost" {
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
}
}

$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "/usr/lib/cgi-bin/prog" )
}

cgi.assign = (
".pl" => "/usr/bin/perl",
".php" => "/usr/bin/php-cgi",
".py" => "/usr/bin/python",
)







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts