I have configured my Apache by myself and have configured CGI on my localhost, but I received:
Forbidden You don't have permission to access /[username/**.cgi on this server.
My http.conf(/etc/apache2/httpd.conf)
Before: #LoadModule userdir_module libexec/apache2/mod_userdir.so
After: LoadModule userdir_module libexec/apache2/mod_userdir.so
Before: #Include /private/etc/apache2/extra/httpd-userdir.conf
After: Include /private/etc/apache2/extra/httpd-userdir.conf
Before: #AddHandler cgi-script .cgi
After: AddHandler cgi-script .cgi .ru .pl
My [username].conf(/etc/apache2/users/[username].conf)
<Directory "/Users/[username]/Sites/">
AllowOverride All
Options Indexes FollowSymLinks MultiViews +ExecCGI
AddHandler cgi-script .cgi
Require all granted
</Directory>
My cgi file (Users/[username]/Sites/**.cgi)
#!/usr/bin/perl
print "Content-Type: text/html \n\n"
str = "Hello World"
print str
print "\n"
my Apache version:
Server version: Apache/2.4.18 (Unix)
And I have tried this command:
$ sudo chmod 755 ~/Sites
$ sudo chmod 755 ~/Sites/**.cgi
~
? That needs to be readable and executable by the apache user, too, or else it won't be able to reach~/Sites
. – Dave Sherohman Jul 26 '16 at 8:21str = "Hello World"
is wrong. Variables need to have a$
sigil, so it needs to be$str = "foo"
andprint $str
. That is not the issue here though. – simbabque Jul 26 '16 at 9:13