Fórum Ubuntu Linux - PT

Suporte Técnico => Servidores => Tópico iniciado por: hcbravin em 21 de Setembro de 2014, 12:28

Título: Configuração do Apache para rodar Python CGI
Enviado por: hcbravin em 21 de Setembro de 2014, 12:28
Bom dia pessoal. Estou travando uma batalha a dias e não to conseguindo sair do lugar. Estou tentando rodar Python CGI no meu computador mas não sei onde estou errando, poderiam me ajudar?

Tenho instalado
Ubuntu 14.04
Apache 2
Python
libapache2-mod-python
PHP5

Todos instalados pelo apt.

As configurações são:
(Estou postando no pastebin para não ficar extenso demais aqui.)

/etc/apache2/apache2.conf -> http://pastebin.com/7wcxX1j7 (http://pastebin.com/7wcxX1j7)
/etc/apache2/sites-avaliabe/000-default.conf -> http://pastebin.com/5tuMCVCz (http://pastebin.com/5tuMCVCz)
/etc/apache2/sites-enable/000-default.conf -> http://pastebin.com/aUzFHrJ4 (http://pastebin.com/aUzFHrJ4)

Quando tento entra na pasta aparece isso no navegador:

Forbidden

You don't have permission to access /cgi-bin/ on this server.
Apache/2.4.7 (Ubuntu) Server at localhost Port 80

Quando tento rodar um script .py dentro da pasta cgi-bin aparece isso no navegador:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
Título: Re: Configuração do Apache para rodar Python CGI
Enviado por: zekkerj em 22 de Setembro de 2014, 11:28
Mostre as 20 últimas linhas do arquivo "/var/log/apache2/error_log".

tail -20 /var/log/apache2/error_log
Título: Re: Configuração do Apache para rodar Python CGI
Enviado por: hcbravin em 23 de Setembro de 2014, 23:38
[Tue Sep 23 12:16:40.250675 2014] [mpm_prefork:notice] [pid 1433] AH00169: caught SIGTERM, shutting down
[Tue Sep 23 17:13:27.934923 2014] [:notice] [pid 1397] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Tue Sep 23 17:13:27.949045 2014] [:notice] [pid 1397] mod_python: using mutex_directory /tmp
[Tue Sep 23 17:13:29.958100 2014] [mpm_prefork:notice] [pid 1397] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 mod_python/3.3.1 Python/2.7.6 configured -- resuming normal operations
[Tue Sep 23 17:13:29.958157 2014] [core:notice] [pid 1397] AH00094: Command line: '/usr/sbin/apache2'
[Tue Sep 23 17:39:22.138359 2014] [mpm_prefork:notice] [pid 1397] AH00169: caught SIGTERM, shutting down
[Tue Sep 23 18:04:08.377789 2014] [:notice] [pid 1504] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Tue Sep 23 18:04:08.391915 2014] [:notice] [pid 1504] mod_python: using mutex_directory /tmp
[Tue Sep 23 18:04:11.077116 2014] [mpm_prefork:notice] [pid 1504] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 mod_python/3.3.1 Python/2.7.6 configured -- resuming normal operations
[Tue Sep 23 18:04:11.077180 2014] [core:notice] [pid 1504] AH00094: Command line: '/usr/sbin/apache2'
[Tue Sep 23 23:22:16.192516 2014] [mpm_prefork:notice] [pid 1504] AH00169: caught SIGTERM, shutting down
[Tue Sep 23 23:23:25.270867 2014] [:notice] [pid 1419] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Tue Sep 23 23:23:25.346408 2014] [:notice] [pid 1419] mod_python: using mutex_directory /tmp
[Tue Sep 23 23:23:27.427361 2014] [mpm_prefork:notice] [pid 1419] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 mod_python/3.3.1 Python/2.7.6 configured -- resuming normal operations
[Tue Sep 23 23:23:27.427423 2014] [core:notice] [pid 1419] AH00094: Command line: '/usr/sbin/apache2'
[Tue Sep 23 23:36:42.458722 2014] [cgi:error] [pid 1701] [client 127.0.0.1:43019] AH01215:   File "/home/henrique/BackUp/ServidorWeb/www/cgi-bin/hello.py", line 10
[Tue Sep 23 23:36:42.458812 2014] [cgi:error] [pid 1701] [client 127.0.0.1:43019] AH01215:     print '<h2>'+ % __version__ +'</h2>'
[Tue Sep 23 23:36:42.458825 2014] [cgi:error] [pid 1701] [client 127.0.0.1:43019] AH01215:                   ^
[Tue Sep 23 23:36:42.458840 2014] [cgi:error] [pid 1701] [client 127.0.0.1:43019] AH01215: SyntaxError: invalid syntax
[Tue Sep 23 23:36:42.460899 2014] [cgi:error] [pid 1701] [client 127.0.0.1:43019] End of script output before headers: hello.py
Título: Re: Configuração do Apache para rodar Python CGI
Enviado por: zekkerj em 24 de Setembro de 2014, 14:59
Bem, o motivo do erro está aí; agora é corrigir o programa fonte e testar novamente.

PS: Você precisa mesmo de CGI? Pq tem formas bem melhores de trabalhar, tanto em termos de desempenho quanto de segurança...
Título: Re: Configuração do Apache para rodar Python CGI
Enviado por: hcbravin em 26 de Setembro de 2014, 14:43
Então o erro está no Script ... Sim infelizmente tem que ser. É um projeto de Pesquisa onde meu orientador quer rodar umas coisas no Google App Engine (GAE), e é encima de Python lá.

De qualquer forma, muito obrigado pela ajuda.
Título: Re: Configuração do Apache para rodar Python CGI
Enviado por: zekkerj em 26 de Setembro de 2014, 17:53
Veja só, o fato de precisar ser Python não quer dizer que precise ser CGI...