Static files are getting served (example, http://iamshobhit.com/media/css/home.css )
But urls which mod_wsgi/django are supposed to take care of, just wait forever for response (example, http://iamshobhit.com )
Apache error log (LogLevel debug) shows:-
[Fri Dec 06 04:23:27.256038 2013] [:info] [pid 4980:tid 140580561024832] mod_wsgi (pid=4980): Attach interpreter ''.
[Fri Dec 06 04:24:19.339088 2013] [authz_core:debug] [pid 4980:tid 140580260644608] mod_authz_core.c(802): [client 175.100.182.59:56886] AH01626: authorization result of Require all granted: granted
[Fri Dec 06 04:24:19.339370 2013] [authz_core:debug] [pid 4980:tid 140580260644608] mod_authz_core.c(802): [client 175.100.182.59:56886] AH01626: authorization result of <RequireAny>: granted
[Fri Dec 06 04:24:19.339661 2013] [authz_core:debug] [pid 4980:tid 140580260644608] mod_authz_core.c(802): [client 175.100.182.59:56886] AH01626: authorization result of Require all granted: granted
[Fri Dec 06 04:24:19.339732 2013] [authz_core:debug] [pid 4980:tid 140580260644608] mod_authz_core.c(802): [client 175.100.182.59:56886] AH01626: authorization result of <RequireAny>: granted
[Fri Dec 06 04:24:19.359602 2013] [:info] [pid 4980:tid 140580260644608] mod_wsgi (pid=4980): Create interpreter 'iamshobhit.com|'.
[Fri Dec 06 04:24:19.361155 2013] [:info] [pid 4980:tid 140580260644608] [client 175.100.182.59:56886] mod_wsgi (pid=4980, process='', application='iamshobhit.com|'): Loading WSGI script '/home/ubuntu/www/mkapp/marketing_app/wsgi.py'.
and then stops producing any further output. The browser waits forever for response and finally says "No data received"
Any Ideas as to what I might be missing?
I have been struggling with this for two days now, and I am still where I started...
Here's the server config -
AWS free micro-instance, Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-57-virtual x86_64)
Apache/2.4.6 mod_wsgi/3.4 Python/2.7.3 Django/1.6.0
Here are some config files I think might be important
httpd.conf
WSGIScriptAlias / /home/ubuntu/www/mkapp/marketing_app/wsgi.py
WSGIPythonPath /home/ubuntu/www/mkapp
WSGIApplicationGroup %{GLOBAL}
<Directory /home/ubuntu/www/mkapp/marketing_app>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
VirtualHost config
<VirtualHost *:80>
ServerName iamshobhit.com
ServerAlias www.iamshobhit.com
ServerAdmin shobhit.v87@gmail.com
Alias /robots.txt /home/ubuntu/www/mkapp/files/media/robots.txt
Alias /favicon.ico /home/ubuntu/www/mkapp/files/media/favicon.ico
Alias /media/ /home/ubuntu/www/mkapp/files/media/
<Directory /home/ubuntu/www/mkapp/files/media>
Require all granted
</Directory>
WSGIScriptAlias / /home/ubuntu/www/mkapp/marketing_app/wsgi.py
<Directory /home/ubuntu/www/mkapp/marketing_app>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
wsgi.py
import os
import sys
ppath = '/home/ubuntu/www/mkapp'
sys.path.append(ppath)
os.environ.setdefault("PYTHONPATH", ppath)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "marketing_app.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Any help is appreciated.
Thanks,
I suppose you have installed the module libapache2-mod-wsgi sudo apt-get install libapache2-mod-wsgi
if that a case you don't have to use the file wsgi.py like a python file but it should be a .wsgi file i mean you should create a file with the extension file.wsgi if you want to load it with your apache server
so wsgi.py ====> filename.wsgi
import os, sys
wsgi_dir = os.path.abspath(os.path.dirname(__file__))
project_dir = os.path.dirname(wsgi_dir)
sys.path.append(project_dir)
sys.path.append('/home/ubuntu/www/mkapp')
os.environ['PYTHON_EGG_CACHE'] = '/home/ubuntu/www/mkapp/.python-egg'
project_settings = os.path.join(project_dir,'settings')
os.environ['DJANGO_SETTINGS_MODULE'] ='marketing_app.settings'
import django.core.handlers.wsgi
application =django.core.handlers.wsgi.WSGIHandler()
1 - if your apache is installed from source (i mean download and install with command) add the line LoadModule wsgi_module modules/mod_wsgi.so in the virtualhost config you don't have to grant something else.
Virtualhost Config:
<VirtualHost *:80>
Listen 81
LoadModule wsgi_module modules/mod_wsgi.so
ServerName iamshobhit.com
ServerAlias www.iamshobhit.com
ServerAdmin shobhit.v87@gmail.com
Alias /robots.txt /home/ubuntu/www/mkapp/files/media/robots.txt
Alias /favicon.ico /home/ubuntu/www/mkapp/files/media/favicon.ico
Alias /media/ /home/ubuntu/www/mkapp/files/media/
WSGIScriptAlias / /home/ubuntu/www/mkapp/marketing_app/filename.wsgi
<Directory /home/ubuntu/www/mkapp/marketing_app>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2- if the apache server is installed from package (apache2) you have only to enable the mod_wsgi module
<VirtualHost *:80>
ServerName iamshobhit.com
ServerAlias www.iamshobhit.com
ServerAdmin shobhit.v87@gmail.com
WSGIScriptReloading On
WSGIProcessGroup servername
WSGIDaemonProcess servername user=username processes=10 threads=1 maximum-requests=500
Alias /robots.txt /home/ubuntu/www/mkapp/files/media/robots.txt
Alias /favicon.ico /home/ubuntu/www/mkapp/files/media/favicon.ico
Alias /media/ /home/ubuntu/www/mkapp/files/media/
WSGIScriptAlias / /home/ubuntu/www/mkapp/marketing_app/filename.wsgi
<Directory /home/ubuntu/www/mkapp/marketing_app>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Don't have that stuff in httpd.conf. Move:
WSGIApplicationGroup %{GLOBAL}
into the VirtualHost definition.
Read:
as to why WSGIApplicationGroup of %{GLOBAL} may be required. For you that is not being picked up with the configuration you had and so you are likely using a third party Python package with a C extension which doesn't work with sub interpreters and so it is deadlocking.
Read:
and consider why you are still using embedded mode.
Also go try with a WSGI hello world program rather than your Django application. This most likely will confirm there is nothing wrong with Apache/mod_wsgi but that issues are caused by your application and the modules it is loading.
Try by adding the following to the wsgi file:
ppath2 = '/home/ubuntu/www/mkapp/marketing_app'
sys.path.append(ppath2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.