apache2.4.52(ubuntu)配置cgi不执行脚本,浏览器直接呈现代码

apache2.4.52(ubuntu)配置cgi不执行脚本,浏览器直接呈现代码

Ubuntu 11.4.0-1ubuntu1~22.04 apache 2.4.52 safri chrome

conf-启用/serve-cgi-bin.conf

ScriptAlias /cgi-bin/ /var/www/html/cgi-bin/
<Directory "/var/www/html/cgi-bin">
    AllowOverride ALL
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Require all granted
    **AddHandler cig-script .cgi .pl .py .sh**
</Directory>

/etc/apache2/mods-enabled/cgi.load

LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so
AddHandler cgi-script .cgi .pl .py .sh       

CGI脚本

#!/usr/bin/python3
import cgi
 
form = cgi.FieldStorage()
 
print('Content-type: text/html\n')
print('<title>Reply Page</title>')
 
if not 'user' in form:
    print('<h1>Who are you?</ht>')
else:
    print('<ht1>Hello <i>%s</i></ht1>' %cgi.escape(form['user'].value))

我已经更改了执行权限,加载 cgi 并重新启动服务

chmod 755 cgi-script.py
sudo a2enmod cgi

下一个是error.log

[Tue Oct 17 01:13:21.391107 2023] [so:warn] [pid 62276] AH01574: module cgi_module is already loaded, skipping

相关内容