Ubuntu Apache 无法访问 cgi-bin 文件夹
Ubuntu Apache can't access cgi-bin folder
我在 DigitalOcean 上创建了一个 Droplet,但无法 运行 cgi-bin 文件夹中的 python 脚本。我试过了
sudo a2enmod cgi
chmod a+rwx cgi-bin
也给文件 chmod 755 但它没有用。当我尝试访问 cgi-bin 文件夹时,它给出了 Forbidden 错误并显示 You don't have permission to access /cgi-bin/ on this server.
谁能帮忙?
我的配置文件
<VirtualHost *:80>
ScriptAlias /cgi-bin/ "/var/www/test/cgi-bin/"
<Directory /var/www/test/cgi-bin/>
AllowOverride All
Options ExecCGI
AddHandler cgi-script .cgi .pl .tcl .py
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/test/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks ExecCGI
Require all granted
</Directory>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/test"
</VirtualHost>
我还在文档根目录中创建了一个测试 python 文件,当我打开它时,它的行为就像一个文本文件。
您可以尝试将以下行添加到您的 httpd.conf
或网络服务器配置文件
<Files ~ "\.(py|cgi)$">
SetHandler python-script
Options +ExecCGI
</Files>
另请参阅:mod-python
我在 DigitalOcean 上创建了一个 Droplet,但无法 运行 cgi-bin 文件夹中的 python 脚本。我试过了
sudo a2enmod cgi
chmod a+rwx cgi-bin
也给文件 chmod 755 但它没有用。当我尝试访问 cgi-bin 文件夹时,它给出了 Forbidden 错误并显示 You don't have permission to access /cgi-bin/ on this server.
谁能帮忙?
我的配置文件
<VirtualHost *:80>
ScriptAlias /cgi-bin/ "/var/www/test/cgi-bin/"
<Directory /var/www/test/cgi-bin/>
AllowOverride All
Options ExecCGI
AddHandler cgi-script .cgi .pl .tcl .py
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/test/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks ExecCGI
Require all granted
</Directory>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/test"
</VirtualHost>
我还在文档根目录中创建了一个测试 python 文件,当我打开它时,它的行为就像一个文本文件。
您可以尝试将以下行添加到您的 httpd.conf
或网络服务器配置文件
<Files ~ "\.(py|cgi)$">
SetHandler python-script
Options +ExecCGI
</Files>
另请参阅:mod-python