首页 文章

错误消息“禁止您无权访问此服务器上的/~ [uname] /*** . cgi . ”

提问于
浏览
1

我自己配置了我的Apache并在我的localhost上配置了CGI,但我收到了:

禁止您无权访问此服务器上的/[username/**.cgi .

我的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

我的[用户名] .conf(/ etc / apache2 / users / [用户名] .conf)

<Directory "/Users/[username]/Sites/">
  AllowOverride All
  Options Indexes FollowSymLinks MultiViews +ExecCGI
  AddHandler cgi-script .cgi
  Require all granted
</Directory>

我的cgi文件(Users / [username] / Sites / ** . cgi)

#!/usr/bin/perl                                                                                     
print "Content-Type: text/html \n\n"
str = "Hello World"
print str
print "\n"

我的Apache版本:

Server version: Apache/2.4.18 (Unix)

我尝试过这个命令:

$ sudo chmod 755 ~/Sites
$ sudo chmod 755 ~/Sites/**.cgi

1 回答

  • 0

    第一行必须是:

    #!/ usr / bin / perl -wT

    最后添加这两个标志(-wT)

相关问题