Debian配置Apache2支持mod-python和cgi模块

Ubuntu好像是直接支持的,现在回到Debian有点不适应了。需要人工配置一下:

一、mod-python

安装模块:apt-get install libapache2-mod-python

编辑文件:/etc/apache2/sites-available/000-default

增加如下内容:

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                AddHandler mod_python .py
                PythonHandler mod_python.publisher
                PythonDebug On
        </Directory>

重启服务:/etc/init.d/apache2 restart

参考:https://www.howtoforge.com/embedding-python-in-apache2-with-mod_python-debian-etch

 二、cgi

默认Apache2已经安装该模块了,只不过没有启用而已。

开启方式:sudo a2enmod cgi

编辑文件:/etc/apache2/sites-available/000-default

增加如下内容:

        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>

重启服务:/etc/init.d/apache2 restart

注意:/usr/lib/cgi-bin/是存放cgi脚本的位置,当然你也可以设置其它位置。

原文地址:https://www.cnblogs.com/wzc0066/p/5843311.html