Cgi未执行python

0 投票
2 回答
2117 浏览
提问于 2025-04-15 18:59

我在用Python的时候遇到了CGI的问题。

我在

Options ExecCGI
AddHandler cgi-script cgi py pl

这个文件里添加了内容,路径是 /etc/apache2/sites-available/default。

现在Perl可以正常工作了,但Python却出现了500内部服务器错误。

编辑:

这是当前的'default'文件内容

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

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

            AddHandler mod_python .py
            PythonHandler mod_python.publisher
            PythonDebug On
    </Directory>

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin/">
            Options +ExecCGI
            AddHandler cgi-script .cgi .py .pl
            Allow from all
    </Directory>

有没有什么建议?

2 个回答

0

如果满足你的需求,可以试试用Python的CGI服务器,而不是用Apache服务器。

python -m CGIHTTPServer {port number:default 8000}
1

试着把 .py 文件的名字改成 .cgi,之前我这样做过,效果不错。

撰写回答