Sample Header Ad - 728x90

Lighttpd when running python CGI reports - 403 forbidden - Ubuntu

1 vote
1 answer
1193 views
I am starting a lighttpd service in my ubuntu.My idea here is to serve a python script through CGI. But, when I do this I get 403 forbidden? Please help how to debug and what am I missing here? vi /etc/lighttpd/lighttpd.conf server.document-root "/home/httpd" Enable, CGI in lighttpd. vi /etc/lighttpd/lighttpd.conf server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_cgi", "mod_rewrite", ) In order to get lighttpd to recognize any python scripts we need to add the following new section at the end of the file. $HTTP["url"] =~ "^/cgi-bin/" { cgi.assign = (".py" => "/usr/bin/python") } Give appropriate permission to the root folder. # chown www-data /home/httpd/cgi-bin # chgrp www-data /home/httpd/cgi-bin Now, write the hello.py vi /home/httpd/cgi-bin/hello.py #! /usr/bin/python # print "Content-Type: text/html\n\n" print ' ' print ' Raspberry Pi

for count in range(1,100) print'Hello World...' print "/p> Finally, restart the lighttpd service. #service lighttpd restart But, when I try to access the page it says- 403 forbidden Here is my folder with permission /home/httpd. /home/httpd$ ls -l total 8 drwxr-xr-x 2 www-data www-data 4096 Apr 3 17:56 cgi-bin drwxr-xr-x 2 www-data root 4096 Apr 3 16:41 html Here is the hello.py /home/httpd/cgi-bin$ ls -l total 4 -rwxrwxrwx 1 root www-data 244 Apr 3 17:56 hello.py The log says that it is still looking for php, html files rather than my python binary? read(7, "GET / HTTP/1.1\r\nHost: 10.0.2.15\r"..., 4159) = 328 stat("/home/httpd/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat("/home/httpd/index.php", 0x7ffee411b9f0) = -1 ENOENT (No such file or directory) stat("/home/httpd/index.html", 0x7ffee411b9f0) = -1 ENOENT (No such file or directory) stat("/home/httpd/index.lighttpd.html", 0x7ffee411b9f0) = -1 ENOENT (No such file or directory) setsockopt(7, SOL_TCP, TCP_CORK, , 4) = 0 writev(7, [{iov_base="HTTP/1.1 403 Forbidden\r\nContent-"..., iov_len=134}, {iov_base="

Asked by tannoy connect (299 rep)
Apr 11, 2020, 02:32 AM
Last activity: Apr 27, 2020, 11:55 PM