SQLite error attempt to write to a read-only database - django

I've been struggling to deploy my django project with Apache and mod_wsgi. I've had many problems that I managed to handle, but this one just seems not to be solvable.
I get the following error in my apache log when I enter the address setakshop.ir:8080 :
[Wed May 27 05:54:24 2015] [error] Internal Server Error: /en-gb/
[Wed May 27 05:54:24 2015] [error] Traceback (most recent call last):
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 87, in get_response
[Wed May 27 05:54:24 2015] [error] response = middleware_method(request)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/oscar/apps/basket/middleware.py", line 26, in process_request
[Wed May 27 05:54:24 2015] [error] strategy = selector.strategy(request=request, user=request.user)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/oscar/apps/partner/strategy.py", line 39, in strategy
[Wed May 27 05:54:24 2015] [error] return Default(request)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/oscar/apps/partner/strategy.py", line 57, in __init__
[Wed May 27 05:54:24 2015] [error] if request and request.user.is_authenticated():
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 224, in inner
[Wed May 27 05:54:24 2015] [error] self._setup()
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 357, in _setup
[Wed May 27 05:54:24 2015] [error] self._wrapped = self._setupfunc()
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/middleware.py", line 22, in <lambda>
[Wed May 27 05:54:24 2015] [error] request.user = SimpleLazyObject(lambda: get_user(request))
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/middleware.py", line 10, in get_user
[Wed May 27 05:54:24 2015] [error] request._cached_user = auth.get_user(request)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py", line 152, in get_user
[Wed May 27 05:54:24 2015] [error] user_id = request.session[SESSION_KEY]
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/base.py", line 49, in __getitem__
[Wed May 27 05:54:24 2015] [error] return self._session[key]
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/base.py", line 175, in _get_session
[Wed May 27 05:54:24 2015] [error] self._session_cache = self.load()
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/db.py", line 29, in load
[Wed May 27 05:54:24 2015] [error] self.create()
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/db.py", line 41, in create
[Wed May 27 05:54:24 2015] [error] self.save(must_create=True)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/db.py", line 64, in save
[Wed May 27 05:54:24 2015] [error] obj.save(force_insert=must_create, using=using)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 589, in save
[Wed May 27 05:54:24 2015] [error] force_update=force_update, update_fields=update_fields)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 617, in save_base
[Wed May 27 05:54:24 2015] [error] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 698, in _save_table
[Wed May 27 05:54:24 2015] [error] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 731, in _do_insert
[Wed May 27 05:54:24 2015] [error] using=using, raw=raw)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 92, in manager_method
[Wed May 27 05:54:24 2015] [error] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 921, in _insert
[Wed May 27 05:54:24 2015] [error] return query.get_compiler(using=using).execute_sql(return_id)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 921, in execute_sql
[Wed May 27 05:54:24 2015] [error] cursor.execute(sql, params)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
[Wed May 27 05:54:24 2015] [error] return self.cursor.execute(sql, params)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
[Wed May 27 05:54:24 2015] [error] six.reraise(dj_exc_type, dj_exc_value, traceback)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
[Wed May 27 05:54:24 2015] [error] return self.cursor.execute(sql, params)
[Wed May 27 05:54:24 2015] [error] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 485, in execute
[Wed May 27 05:54:24 2015] [error] return Database.Cursor.execute(self, query, params)
[Wed May 27 05:54:24 2015] [error] OperationalError: attempt to write a readonly database
Now I googled this error and searched a lot, I mean a lot! I know that the db.sqlite file must have write permissions and it should be owned by apache ( www-data ), also the directory containing it must have write permissions and be owned by www-data. and I have done these two things. I don't have selinux installed, I've ran ./manage.py migrate, and I don't know what else I can do to make this work, I even chmoded both the directory and the db.sqlite file to 777 to just see if it will work, but it didn't and I know that's not a safe thing to do.
now for your information this is the folder containing the db.sqlite file:
-rw-rw-r-- 1 ashkan ashkan 382 Jan 30 11:54 README.rst
-rw-rw-r-- 1 ashkan ashkan 0 Jan 30 11:54 __init__.py
drwxrwxr-x 4 ashkan ashkan 4096 Feb 6 15:15 apps
-rwxrwxrwx 1 www-data www-data 741376 May 27 09:11 db.sqlite
drwxrwxr-x 7 ashkan ashkan 4096 Jan 30 11:54 deploy
drwxrwxr-x 2 ashkan ashkan 4096 Jan 30 11:54 fixtures
drwxrwxr-x 2 ashkan ashkan 4096 Feb 22 00:14 i18n
drwxrwxr-x 3 ashkan ashkan 4096 Feb 23 21:45 locale
drwxr-xr-x 2 ashkan ashkan 4096 May 26 08:33 logs
-rwxrwxr-x 1 ashkan ashkan 242 May 26 00:22 manage.py
lrwxrwxrwx 1 ashkan ashkan 10 May 25 23:15 oscar -> i18n/oscar
drwxrwxr-x 4 ashkan ashkan 4096 Jan 30 21:53 public
-rw-rw-r-- 1 ashkan ashkan 14306 May 26 00:07 settings.py
-rw-r--r-- 1 ashkan ashkan 10230 May 26 00:23 settings.pyc
-rw-rw-r-- 1 ashkan ashkan 14876 Feb 6 14:26 settings.py~
-rw-rw-r-- 1 ashkan ashkan 293 Jan 30 11:54 settings_mysql.py
-rw-rw-r-- 1 ashkan ashkan 266 May 26 00:16 settings_postgres.py
-rw-rw-r-- 1 ashkan ashkan 162 Jan 30 11:54 settings_sphinx.py
drwxrwxr-x 2 ashkan ashkan 4096 Feb 23 21:45 static
drwxrwxr-x 3 ashkan ashkan 4096 Jan 30 11:54 templates
-rwxrwxr-x 1 ashkan ashkan 1114 Jan 30 11:54 test_migrations.sh
-rwxrwxr-x 1 ashkan ashkan 1138 Jan 30 11:54 update_latest.sh
-rw-rw-r-- 1 ashkan ashkan 1573 Jan 30 11:54 urls.py
-rw-rw-r-- 1 ashkan ashkan 1427 Jan 30 21:53 urls.pyc
drwxr-xr-x 2 ashkan ashkan 4096 Jan 30 20:58 whoosh_index
-rw-rw-r-- 1 ashkan ashkan 778 May 26 00:23 wsgi.py
and this is the directory containing the db.sqlite file:
-rw-rw-r-- 1 ashkan ashkan 866 Jan 30 11:54 README.rst
drwxrwxr-x 2 ashkan ashkan 4096 Jan 30 11:54 _fixtures
-rw-rw-r-- 1 ashkan ashkan 897149 Feb 6 15:34 alaki
-rw-rw-r-- 1 ashkan ashkan 1818857 Feb 6 15:37 alaki.txt
drwxrwxr-x 9 ashkan ashkan 4096 Jan 30 11:54 demo
-rw-rw-r-- 1 ashkan ashkan 443627 Feb 6 15:34 out
drwxrwxrwx 12 www-data www-data 4096 May 27 09:11 sandbox
drwxrwxr-x 5 ashkan ashkan 4096 Jan 30 11:54 us
any idea what's causing this problem? thank you.
update 1 :
here is my apache config :
Listen 8080
<VirtualHost *:8080>
WSGIDaemonProcess setak python-path=/home/ashkan/freshcopy/django-oscar/sites/sandbox:/usr/local/lib/python2.7/site-packages
WSGIProcessGroup setak
WSGIScriptAlias / /home/ashkan/freshcopy/django-oscar/sites/sandbox/wsgi.py
ServerAdmin admin#setakshop.ir
ServerName setakshop.ir:8000
DocumentRoot /var/www/
Alias /media/ /home/ashkan/freshcopy/django-oscar/sites/sandbox/public/media/
Alias /static/ /home/ashkan/freshcopy/django-oscar/sites/sandbox/public/static/
<Directory /home/ashkan/freshcopy/django-oscar/sites/sandbox>
<Files wsgi.py>
Order allow,deny
allow from all
</Files>
</Directory>
<Directory /home/ashkan/freshcopy/django-oscar/sites/sandbox/public/static>
Order allow,deny
allow from all
</Directory>
<Directory /home/ashkan/freshcopy/django-oscar/sites/sandbox/public/media>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
update 2 :
here is my wsgi.py :
import os
import sys
import site
import urllib
sys.stdout = sys.stderr
# Project root
root = '/home/ashkan/django-oscar/sites/sandbox'
sys.path.insert(0, root)
# Packages from virtualenv
activate_this = '/home/ashkan/django-oscar/oscar/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# Set environmental variable for Django and fire WSGI handler
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()
def application(environ, start_response):
environ['PATH_INFO'] = urllib.unquote(environ['REQUEST_URI'].split('?')[0])
return _application(environ, start_response)

Related

Truncated or oversized response headers in daemon mode

I've a weird error in a flask website.
Important : The first page (a form) is running, but when I submit, I've a 505.
I try severals things thaks to StackOverflow :), but I cannot find the solution.
Here the log :
Mon Feb 25 09:17:37.863313 2019] [wsgi:info] [pid 30874:tid 140525377849088] [remote 192.168.56.1:61092] mod_wsgi (pid=30874, process='flask_my_app', application=''): Loading WSGI script '/var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi'.
[Mon Feb 25 09:17:38.191855 2019] [wsgi:error] [pid 30874:tid 140525377849088] /home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
[Mon Feb 25 09:17:38.191899 2019] [wsgi:error] [pid 30874:tid 140525377849088] """)
[Mon Feb 25 09:17:44.995445 2019] [wsgi:error] [pid 30781:tid 140525239768832] [client 192.168.56.1:3595] Truncated or oversized response headers received from daemon process 'flask_my_app': /var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi, referer: http://vm.my_app/
==> /var/log/apache2/error.log <==
[Mon Feb 25 09:17:45.562808 2019] [core:notice] [pid 30767:tid 140525508945792] AH00051: child pid 30874 exit signal Segmentation fault (11), possible coredump in /etc/apache2
==> /var/log/apache2/my_app-error.log <==
[Mon Feb 25 09:17:45.589899 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Attach interpreter ''.
[Mon Feb 25 09:17:45.591070 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Adding '/var/www/my_app/my_app' to path.
[Mon Feb 25 09:17:45.595458 2019] [wsgi:info] [pid 30956:tid 140525508945792] mod_wsgi (pid=30956): Adding '/home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages' to path.
[Mon Feb 25 09:17:45.608611 2019] [wsgi:info] [pid 30956:tid 140525377849088] [remote 192.168.56.1:61092] mod_wsgi (pid=30956, process='flask_my_app', application=''): Loading WSGI script '/var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi'.
[Mon Feb 25 09:17:45.916197 2019] [wsgi:error] [pid 30956:tid 140525377849088] /home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
[Mon Feb 25 09:17:45.916224 2019] [wsgi:error] [pid 30956:tid 140525377849088] """)
My Virtual Host in Apache 2.7 is here :
<VirtualHost *:80>
ServerName vm.my_app
ServerAlias vm.my_app
DocumentRoot /var/www/my_app/my_app
LogLevel info
WSGIDaemonProcess flask_my_app python-path=/var/www/my_app/my_app:/home/vagrant/.virtualenvs/my_app/lib/python2.7/site-packages display-name=%{GROUP}
WSGIProcessGroup flask_my_app
WSGIScriptAlias / /var/www/my_app/my_app/flask_my_app/flask_my_app.wsgi
WSGIApplicationGroup %{GLOBAL}
#Alias /favicon.ico /var/www/my_app/my_app/static/favicon.ico
Alias /site_media/ /var/www/my_app/my_app/site_media/
Alias /media/ /var/www/my_app/my_app/media/
Alias /static/ /var/www/my_app/my_app/static/
AliasMatch /([/]*\.css) /var/www/my_app/my_app/static/css/$1
<Directory /var/www/my_app/my_app>
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/my_app/my_app/flask_my_app>
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/my_app-error.log
CustomLog ${APACHE_LOG_DIR}/my_app-access.log combined
</VirtualHost>
The python version is 2.7.12, and I use "virtual env wrapper".
The version of the wsgi module is old I think :
lrwxrwxrwx 1 root root 15 mai 3 2016 mod_wsgi.so -> mod_wsgi.so-2.7*
-rwxrwxrwx 1 root root 223K mai 3 2016 mod_wsgi.so-2.7*
The wsgi file is "classic", and the requirements.txt file :
$ cat ../requirements.txt
click==6.7
Flask==1.0.2
Flask-Assets==0.12
Flask-Caching==1.4.0
Flask-Login==0.4.1
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
pbr==5.1.1
psycopg2==2.7.5
six==1.12.0
SQLAlchemy==1.2.8
stevedore==1.30.0
webassets==0.12.1
Werkzeug==0.14.1
WTForms==2.2.1
Can anobody helps me ?
Thanks a lot
F.
It's maybe useful to others, that my issue was fixed by desactivating the SSL support !!!, in postgresql.conf :
80 ssl = off # (change requires restart)
the log :
==> /var/log/postgresql/postgresql-9.6-main.log <==
2019-03-07 15:28:28.573 CET [5346] [unknown]#[unknown] LOG: could not accept SSL connection: EOF detected

What is the issue with my wamp server

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More infortion.
After i went through the log file i found this but i dont know how to debug it
[Wed Sep 24 12:29:50.808777 2014] [mpm_winnt:notice] [pid 7716:tid 304] AH00364: Child: All worker threads have exited.
[Wed Sep 24 12:29:53.569982 2014] [mpm_winnt:notice] [pid 6836:tid 388] AH00430: Parent: Child process 7716 exited successfully.
[Wed Sep 24 12:38:59.563516 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured -- resuming normal operations
[Wed Sep 24 12:38:59.598518 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Wed Sep 24 12:38:59.598518 2014] [core:notice] [pid 4612:tid 388] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Wed Sep 24 12:38:59.600518 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00418: Parent: Created child process 5232
[Wed Sep 24 12:39:00.554573 2014] [mpm_winnt:notice] [pid 5232:tid 304] AH00354: Child: Starting 64 worker threads.
[Wed Sep 24 20:59:56.118653 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Wed Sep 24 20:59:58.571793 2014] [mpm_winnt:notice] [pid 5232:tid 304] AH00364: Child: All worker threads have exited.
[Wed Sep 24 21:00:23.437495 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00430: Parent: Child process 5232 exited successfully.
[Thu Sep 25 08:41:53.157396 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured -- resuming normal operations
[Thu Sep 25 08:41:53.166397 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Thu Sep 25 08:41:53.166397 2014] [core:notice] [pid 1032:tid 392] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Thu Sep 25 08:41:53.168397 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00418: Parent: Created child process 6796
[Thu Sep 25 08:41:55.282518 2014] [mpm_winnt:notice] [pid 6796:tid 316] AH00354: Child: Starting 64 worker threads.
[Thu Sep 25 10:46:27.453901 2014] [core:error] [pid 6796:tid 836] [client 127.0.0.1:4242] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:47:56.015967 2014] [core:error] [pid 6796:tid 844] [client 127.0.0.1:4282] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:53:11.816030 2014] [core:error] [pid 6796:tid 832] [client 127.0.0.1:4443] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:55:26.231718 2014] [core:error] [pid 6796:tid 852] [client 127.0.0.1:4476] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Request exceeded the limit of 10 internal redirects due to probable configuration error.
In combination with the the 500 (internal server) error message, it kind of sounds like you have a problem with the RedirectRule lines in your .htaccess file, that keep on redirecting the request in a loop.

Django Misconfiguration

I am trying to deploy mayan-edms a django web application on a RedHat5.6 server in production mode with apache webserver.
I have setup the database and the used a virtual-env to setup the env
This is my httpd.conf
WSGIScriptAlias /mayan /var/www/mayan/mayan/wsgi/dispatch.wsgi
WSGIPythonPath /var/www/mayan/mayan:/var/www/mayan/lib/python2.6/site-packages
<Directory /var/www/mayan/mayan>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
I am getting a 500 error if I start apache with this conf. Could anyone tell me where it is getting misconfigured?
This is the error
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] mod_wsgi (pid=21715): Exception occurred processing WSGI script '/var/www/mayan/mayan/wsgi/dispatch.wsgi'.
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] Traceback (most recent call last):
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] File "/var/www/mayan/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] self.load_middleware()
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] File "/var/www/mayan/lib/python2.6/site-packages/django/core/handlers/base.py", line 45, in load_middleware
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] mod = import_module(mw_module)
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] File "/var/www/mayan/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] __import__(name)
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] File "/var/www/mayan/mayan/apps/common/__init__.py", line 17
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] from .conf.settings import (AUTO_CREATE_ADMIN, AUTO_ADMIN_USERNAME,
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] ^
[Mon Jan 14 12:47:02 2013] [error] [client 130.229.146.48] SyntaxError: invalid syntax
This is my init.py around line 17
from django.db import transaction, DatabaseError
from navigation.api import register_links, register_top_menu
from .conf.settings import (AUTO_CREATE_ADMIN, AUTO_ADMIN_USERNAME, AUTO_ADMIN_PASSWORD, TEMPORARY_DIRECTORY)
from .conf import settings as common_settings
from .utils import validate_path
from .models import AutoAdminSingleton
Sounds like a Python version issue. RHEL 5.6 appears to be quite an old release, and anyway Red Hat are known for bundling old versions of Python. Looking at this table it seems likely that that version of RHEL was not even Python 2.4.
From the other side, the minimum Python version to run the current Django release is 2.7. Although that said, the requirements.txt file for your app actually asks for Django 1.3.5 - but you will still need at least Python 2.6 for that. You will either need to compile and install that version yourself, or upgrade your version of Red Hat.
You are using python 2.6, the documentation for installation seems to use python 2.7

Setting up Apache and Python WSGI to use VirtualEnv

I'm having trouble getting Apache/WSGI to use my VirtualEnv. I have added the following two lines (path on server is pointing to the actual location of site-packages in the target virtualenv) to my WSGI file:
import site
site.addsitedir('/sites/mysite/virtpy/lib/python2.6/site-packages')
(from http://www.foxhop.net/django-virtualenv-apache-mod_wsgi). However, when I try to load the url in the browser I get a 500. Checking the apache logs:
[Sun Jul 17 11:07:11 2011] [error] [client 94.170.105.142] app = import_module(appname)
[Sun Jul 17 11:07:11 2011] [error] [client 94.170.105.142] File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
[Sun Jul 17 11:07:11 2011] [error] [client 94.170.105.142] __import__(name)
[Sun Jul 17 11:07:11 2011] [error] [client 94.170.105.142] TemplateSyntaxError: Caught ImportError while rendering: No module named tagging
[Sun Jul 17 11:07:11 2011] [debug] mod_deflate.c(615): [client 94.170.105.142] Zlib: Compressed 629 to 387 : URL /
So I guess that the VirtualEnv isn't being loaded. Anyone know how to tell Apache / WSGI the correct virtualenv to use?
UPDATE
I have updated django.wsgi following Ken's advice, but now I am getting the following error in the apache log
[Sun Jul 17 16:46:36 2011] [info] [client 94.170.105.142] mod_wsgi (pid=11260, process='', application='igniteflow-django.com:8090|'): Loading WSGI script '/sites/igniteflow/apache/django.wsgi'.
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.105.142] mod_wsgi (pid=11260): Target WSGI script '/sites/igniteflow/apache/django.wsgi' cannot be loaded as Python module.
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.105.142] mod_wsgi (pid=11260): Exception occurred processing WSGI script '/sites/igniteflow/apache/django.wsgi'.
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.106.142] Traceback (most recent call last):
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.105.142] File "/sites/igniteflow/apache/django.wsgi", line 5, in <module>
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.105.142] execfile(activate_this, dict(__file__=activate_this))
[Sun Jul 17 16:46:36 2011] [error] [client 94.170.105.142] IOError: [Errno 13] Permission denied: '/root/.virtualenvs/igniteflow/bin/activate_this.py'
I assume this is because the virtualenv is in root and apache doesn't have permissions? I chowned the folder to root:www-data but it hasn't fixed the problem. Any suggestions?
In my app.wsgi file I have something like this. You will need to change it to put to where your virtual env is located, mine is under /opt/ve/ve_name/ in this example.
import os
# activate virtualenv
activate_this = os.path.expanduser("/opt/ve/ve_name/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))

Django WSGI daemon mode synchronization of requests

Running appache2 with the following /etc/httpd.conf:
<VirtualHost *:80>
WSGIDaemonProcess myapp user=pq group=pq processes=2 threads=1
WSGIProcessGroup myapp
LogLevel debug
<Directory /django/myapp/apache/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /django/myapp/apache/django.wsgi
</VirtualHost>
where this is my /django/myapp/apache/django.wsgi:
import os
import sys
sys.path.append('/django')
os.environ['PYTHONPATH'] = '/django'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
I have the following view:
def sleep(request):
print >> sys.stderr, '{', os.getpid()
time.sleep(5)
print >> sys.stderr, '}', os.getpid()
return index(request)
I make 4 concurrent requests and my error log shows:
[Wed Jan 12 12:59:56 2011] [error] {17160
[Wed Jan 12 13:00:01 2011] [error] }17160
[Wed Jan 12 13:00:01 2011] [error] {17157
[Wed Jan 12 13:00:06 2011] [error] }17157
[Wed Jan 12 13:00:06 2011] [error] {17160
[Wed Jan 12 13:00:11 2011] [error] }17160
[Wed Jan 12 13:00:11 2011] [error] {17157
[Wed Jan 12 13:00:16 2011] [error] }17157
Basically my requests were synchronized per webserver (not even per
process).
Why is this?
Edit: This is a single CPU machine and Apache2 is compiled with
prefork MMP. My client was 4 tabs in Chrome. Interesting, when I try
this with curl I get the expected:
[Wed Jan 12 18:10:18 2011] [error] {17160
[Wed Jan 12 18:10:18 2011] [error] {17157
[Wed Jan 12 18:10:23 2011] [error] }17160
[Wed Jan 12 18:10:23 2011] [error] {17160
[Wed Jan 12 18:10:23 2011] [error] }17157
[Wed Jan 12 18:10:23 2011] [error] {17157
[Wed Jan 12 18:10:28 2011] [error] }17160
[Wed Jan 12 18:10:28 2011] [error] }17157
Edit2: Looks like this is an issue with Chrome synchronizing requests. My (limited) tests showed that this only happens with Chrome and only when tabs are used. Multiple requests within a single tab are asynchronous.