FreeBSD: Configuring Apache to permit CGI
In httpd.conf file make sure the "cgi" LoadModule directive has not been commented out.
A correctly configured directive may look like this:
Explicitly using Options to permit CGI execution
To allow CGI program execution for any file ending in .cgi in users' directories, you can use the following configuration.
If you wish designate a cgi-bin subdirectory of a user's directory where everything will be treated as a CGI program, you can use the following.
A example to Monitor CPU Temperature
cputemp.cgi
A correctly configured directive may look like this:
<IfModule mpm_prefork_module>
LoadModule cgi_module libexec/apache24/mod_cgi.so
</IfModule>
Explicitly using Options to permit CGI execution
To allow CGI program execution for any file ending in .cgi in users' directories, you can use the following configuration.
<VirtualHost *:80>
DocumentRoot "/usr/local/www/apache24/e"
ServerName www.example.com
ErrorLog "/var/log/e-error_log"
CustomLog "/var/log/e-access_log" common
<Directory "/usr/local/www/apache24/e/">
Order allow,deny
Allow from all
Require all granted
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
</VirtualHost>
<Directory "/home/*/public_html">
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
If you wish designate a cgi-bin subdirectory of a user's directory where everything will be treated as a CGI program, you can use the following.
<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
A example to Monitor CPU Temperature
cputemp.cgi
#!/bin/sh
set -f
echo "Content-type: text/plain; charset=iso-8859-1"
echo
date
echo
sysctl dev.cpu | grep temperature
exit 0
Comments
Post a Comment