我如何用密码保护并让 cgi-bin 正常工作?

我如何用密码保护并让 cgi-bin 正常工作?

这是从 sites-available 目录中获取的。这是 apache 的虚拟主机设置。

访问 myiphere/cgi-bin/ 会抛出 403。

/var/www2/ 的目录设置drwxrwxrwx 8 www-data www-data

NameVirtualHost  myiphere
<VirtualHost  myiphere>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www2/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www2/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

答案1

NameVirtualHost myiphere

切勿使用主机名作为虚拟主机;请改用以下名称(默认):NameVirtualHost *:80

<VirtualHost myiphere>

我也是一样。

<Directory />
        Options FollowSymLinks
        AllowOverride None
</Directory>

这不属于 vhost 内部;您只需在主服务器配置中设置一次即可。

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

不要改变脚本别名中的 CGI 选项;这一切都完成了为了你。

从以下更正的设置开始,并记住,如果没有 ServerName,什么都无法工作。

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>

  ServerName test.local

  ServerAdmin webmaster@localhost
  DocumentRoot /var/www2/

  <Directory /var/www2/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Order allow,deny
        Allow from all
  </Directory>

  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined
  ServerSignature On

</VirtualHost>

相关内容