Apache não está servindo meu aplicativo python

2

Então aqui está minha configuração do apache:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName 31.220.49.197
        WSGIDaemonProcess ts threads=25
        WSGIProcessGroup ts
        Alias /static /home/email-validator/static
        WSGIScriptAlias / /home/email-validator/index.wsgi

        # Set access permission
        <Directory />
                Allow from all
                Require all granted
        </Directory>

</VirtualHost>

Aqui está o meu index.wsgi:

import os
import sys
import site

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/email-validator')
sys.path.append('/home/email-validator/email_validator')

os.environ['DJANGO_SETTINGS_MODULE'] = 'email_validator.settings'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

EDITAR: apache error.log

[Sat Nov 15 12:28:09.374301 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:28:09.374426 2014] [core:notice] [pid 3827:tid 3074431616] AH00094: Command line: '/usr/sbin/apache2'
[Sat Nov 15 12:32:45.009711 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00491: caught SIGTERM, shutting down
[Sat Nov 15 12:32:46.137115 2014] [so:warn] [pid 4297:tid 3074935424] AH01574: module wsgi_module is already loaded, skipping
[Sat Nov 15 12:32:46.142088 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:32:46.142125 2014] [core:notice] [pid 4298:tid 3074935424] AH00094: Command line: '/usr/sbin/apache2'
[Sat Nov 15 12:42:04.023659 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00491: caught SIGTERM, shutting down
[Sat Nov 15 12:42:04.248193 2014] [so:warn] [pid 4409:tid 3074857600] AH01574: module wsgi_module is already loaded, skipping
[Sat Nov 15 12:42:04.252825 2014] [mpm_event:notice] [pid 4410:tid 3074857600] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sat Nov 15 12:42:04.252860 2014] [core:notice] [pid 4410:tid 3074857600] AH00094: Command line: '/usr/sbin/apache2'

ifconfig

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.2  P-t-P:127.0.0.2  Bcast:0.0.0.0  Mask:255.255.255.255
          inet6 addr: 2a02:4780:1:1::1:1f88/128 Scope:Global
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:20113 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9810 errors:0 dropped:3 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:23659654 (23.6 MB)  TX bytes:917246 (917.2 KB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.224.2.128  P-t-P:10.224.2.128  Bcast:10.224.2.128  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

Quando vou para http://31.220.49.197 apache não me serve app django. Quando eu faço service apache2 restart tudo fica bem O que estou fazendo errado? Esta configuração funciona em meus outros aplicativos.

    
por Marijus 15.11.2014 / 20:39

1 resposta

-1

Eu estava enfrentando o mesmo problema, mas, felizmente, depois de investigar as configurações do apache , consegui resolver isso.

Aqui está o meu arquivo de configuração do apache, ou seja, 000-default.conf , que serve a página padrão em vez do meu aplicativo. Nota *: Os exemplos estão sendo mostrados abaixo com a ajuda da configuração do AP Apache.

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName 31.220.49.197
    WSGIDaemonProcess ts threads=25
    WSGIProcessGroup ts
    Alias /static /home/email-validator/static
    WSGIScriptAlias / /home/email-validator/index.wsgi

    # Set access permission
    <Directory />
            Allow from all
            Require all granted
    </Directory>

</VirtualHost>

E depois de comentar a configuração padrão do virtualhost na porta 80 resolve o meu problema embora ainda estejamos recebendo os mesmos logs de erro:) .

isso significa comentar ou remover toda a seção padrão / primeiro <VirtualHost *:80> resolverá o problema.

Atualmente, estou tendo o Ubuntu 14.4 e esse problema surgiu após a atualização de 12.4.

    
por 06.06.2015 / 09:54