Instalando Apache com Python no Ubuntu 18.04

[fabio-plugin]
Pequeno e simples tutorial de como instalar e configurar o Python com o servidor Apache no servidor LTS do Ubuntu 18.04.
Primeiro instale o Apache e o Python
$ sudo apt-get update
$ sudo apt-get install apache2 python
Carregue o modulo cgid
$ sudo a2enmod cgid
Edite o arquivo cgi-enabled.conf
$ sudo vi /etc/apache2/conf-available/cgi-enabled.conf
# Processes .cgi and .py as CGI scripts
<Directory “/var/www/html/cgi-enabled”>
Options +ExecCGI
AddHandler cgi-script .cgi .py
DirectoryIndex index.py
</Directory>Crie o diretorio cgi-enabled
$ sudo mkdir /var/www/html/cgi-enabledAgora habilite o arquivo configurado e reinicie o apache
$ sudo a2enconf cgi-enabled
$ sudo systemctl reload apache2Crie o arquivo index.py e copie o contedudo logo abaixo

$ sudo vi /var/www/html/cgi-enabled/index.py

#!/usr/bin/env python
print “Content-type: text/html\n\n”
print “<html>\n<body>\n”
print “<h1>Python Script Test Page</h1>\n”
print “</body>\n</html>”

Com o comando abaixo de a seguinte permissão
$ chmod 705 /var/www/html/cgi-enabled/index.py

Agora acesse no seu browser
http://your_ip_adress/cgi-enabled/index.py