guenchi
guenchi

Reputation: 61

403 forbidden when use CGI in apache in mac os x

mac 10.12.6

The config of apache

LoadModule cgi_module libexec/apache2/mod_cgi.so

ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/cgi-bin/$1"

<Directory "/Library/WebServer/cgi-bin/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>

AddHandler cgi-script .cgi

and the file ls -l

user:cgi-bin root# ls -l
total 8
-rwxr-xr-x@ 1 user  wheel  60 Oct 27 21:57 server.cgi

that's the test in command line

root# /library/webserver/cgi-bin/server.cgi
Content-type:text/plain
hello world

and if I go to

http://localhost/cgi-bin/server.cgi

its response:

Forbidden

You don't have permission to access /cgi-bin/server.cgi on this server.

I have try anything that I can do.

Upvotes: 0

Views: 942

Answers (1)

guenchi
guenchi

Reputation: 61

Yaha I found the problem

it's a problem with Apache 2.4

You have to check allow and deny rules

Check out http://httpd.apache.org/docs/2.4/upgrading.html#access

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The new directive is Require:

2.2 configuration:

Order allow,deny
Allow from all

2.4 configuration:

Require all granted

Upvotes: 3

Related Questions