Sunday, November 7, 2010

Enable python CGI script in user directory (public_html/cgi-bin)

edit /etc/httpd/conf/httpd.conf
add these section


<Directory "/home/*/public_html/cgi-bin">
    Options ExecCGI
    AddHandler cgi-script .py
</Directory>

Then restart the server
/usr/sbin/apachectl restart


If there is any error, check httpd error log
tail /var/log/httpd/error_log

[Mon Nov 08 10:21:05 2010] [error] [client 192.168.106.31] suexec policy violation: see suexec log for more details
[Mon Nov 08 10:21:05 2010] [error] [client 192.168.106.31] Premature end of script headers: ...py

error from suexec, check suexec log
tail /var/log/httpd/suexec.log

[2010-11-08 10:22:51]: uid: (500/s) gid: (500/500) cmd: ..py
[2010-11-08 10:22:51]: directory is writable by others: ..


The directory should not be writable by others (security reason)
chmod 711 /home/user-abc/public_html/cgi-bin

If there is another error, check both logs again.

No comments:

Post a Comment