1

I am deploying a Django project on Apache. and after configuration, I open the "localhost" in the browser, and nothing showed up and the status bar just keep saying "Waiting for localhost". Here is some info.

Environment:

OS: ubuntu 
Python: 2.7.3
Django: 1.8.2
Apache: 2.2.21
Django project: /var/www/ocr_service

Apache virtualhost:

WSGIScriptAlias / /var/www/ocr_service/ocr_service/wsgi.py
WSGIPythonPath /var/www/ocr_service
<VirtualHost *:80>
LogLevel info

ErrorLog /var/www/ocr_service/log/error.log
CustomLog /var/www/ocr_service/log/access.log combined

<Directory /var/www/ocr_service >
    <Files wsgi.py>
    Order deny,allow
    Allow from all
    </Files>
</Directory>
</VirtualHost>

Django.wsgi file:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ocr_service.settings")

application = get_wsgi_application()

I try with a empty django project and it works. These are what I did, can someone help me to see if somewhere is wrong?

apache2/error log report only the resuming normal operation message custom log report

  mod_wsgi (pid=10***, process='',application='127.0.1.1|') loading wsgi script '/var/www/ocr_service/ocr_service/wsgi.py"
JcBobo
  • 63
  • 7

1 Answers1

3

Try adding to the Apache configuration file:

WSGIApplicationGroup %{GLOBAL}

See:

As the log snippet shows the WSGI file at least being loaded, which would only happen if a request is received, the issue may that you are using third party extension modules for Python that will not work in sub interpreters properly and they deadlock and hang the request. Setting that directive avoids the problem.

Also recommended that you do not use embedded mode as you are, but use daemon mode instead:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • with WSGIApplicationGroup %{GLOBAL} is working but very slow (>3sec load static page). I will move to deamon mode now – JcBobo Jun 16 '15 at 13:47
  • 1
    The performance issue would likely be due to using prefork MPM, with the delay being that with many processes being used by Apache with that MPM, you are seeing the cost of loading the application into the process on each request. Times would improve once is loaded, but then with that MPM, and depending on Apache settings, the process can easily be shutdown and restarted, meaning application has to be reloaded again. In daemon mode the application code stays persistent. – Graham Dumpleton Jun 16 '15 at 20:45