1
votes

I have seen plenty of previous messages related to my problem, but no answer could get rid of my "500 Server internal Error" so I try to post my conf to get help.

Error Message:

[Fri Jun 24 17:05:23.631270 2016] [authz_core:error] [pid 15187:tid 140715758237440] [client 127.0.0.1:47873] AH01630: client denied by server configuration: /home/www/waves/

[Fri Jun 24 17:05:23.631568 2016] [:error] [pid 15186:tid 140715648984832] ['/home/marc/.virtualenvs/waves/lib/python2.7/site-packages', '/home/www/waves', '/usr/local/lib/python2.7/dist-packages/setuptools-20.6.7-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']

[Fri Jun 24 17:05:23.631660 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi (pid=15186): Target WSGI script '/home/www/waves/waves_services/wsgi.py' cannot be loaded as Python module.

[Fri Jun 24 17:05:23.631675 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi (pid=15186): Exception occurred processing WSGI script '/home/www/waves/waves_services/wsgi.py'.

[Fri Jun 24 17:05:23.631686 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] Traceback (most recent call last):

[Fri Jun 24 17:05:23.631710 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] File "/home/www/waves/waves_services/wsgi.py", line 18, in

[Fri Jun 24 17:05:23.631731 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] from django.core.wsgi import get_wsgi_application

[Fri Jun 24 17:05:23.631743 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] ImportError: No module named django.core.wsgi

My django app do not load in apache wsgi mode, I tried many solutions but still don't work. Here is my confs files : Virtual host :

<VirtualHost *:80>

ServerName dev.www.waves.com
ServerAlias www.waves.com
ServerAdmin [email protected]

DocumentRoot /home/www/waves
Alias media/ /home/www/waves/media/
Alias static/ /home/www/waves/static/

<Directory /home/www/waves>
   Require all granted
</Directory>

<Directory /home/www/waves/staticfiles>
   Require all granted
</Directory>

<Directory /home/www/waves/media>
   Require all granted
</Directory>

WSGIDaemonProcess waves python-path=/home/marc/.virtualenvs/waves/lib/python2.7/site-packages:/home/www/waves
WSGIProcessGroup waves
WSGIScriptAlias /waves /home/www/waves/waves_services/wsgi.py

<Directory /home/www/waves/waves_services>
  <Files wsgi.py>
    Require all granted
  </Files>
</Directory>

<Directory /home/marc/.virtualenvs/waves/lib/python2.7/>
Require all granted
</Directory>

My wsgy.py content :

from __future__ import unicode_literals
import os
import sys
import site

print sys.path
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "waves_services.settings.production")
application = get_wsgi_application()

I traced to sys.path content in apache error log, and the virtualenv in in sys.path. Django is installed in this virtualenv (I had first tried to install django 'globally' but the error was just moved to the first 'application specific' import : environ contained in my settings file. The virtual env was created with virtualenvwrapper (any impact ?)

I tried as well to change ownership of virtualenv file, changed 'execution' flag as well, but still I get this ... 500 Server Error.

I would be grateful to get a clue of what is happening ! thanxs

1
Hello, yes django is installed in a virtualenv. To pe more precise here is a sample of my sites-packages ll result: django mptt Django-1.9.6.dist-info django_cors_headers-1.1.0-py2.7.egg-info django_countries django_countries-3.4.1.dist-info django_crontab django_debug_toolbar-1.4.dist-info django-eav.egg-link ...marcoooo
Is that virtualenv accessible to apache? this is often a probleme4c5
Hello, do you mean configured in virtual host <Directory> or file permissions ? Permissions are set as follow on virtual env dir : 775 for dirs, 644 for files, all marked in www-data group, but owned by me (ie marc)marcoooo
No, what is mean is does the apache user have access to the virtualenv foldere4c5
Ok, if it is only related to 'apache' user (www-data), I changed group of my virtualenv directory to www-data, with no change in my error. still can't find django core module. I even tried to change ownership to www-data, (in this case, I think I won't be able to make any more pip install in this virtual env from 'marc' user?) stille same error.marcoooo

1 Answers

1
votes

Several things to check for.

  1. Make sure that the virtualenv has django (pip freeze | grep django)
  2. Check if apache user can access the virtualenv by checking the folder permissions
  3. if you are using apache 2.4 + change the following

    Order deny,allow Allow from all

    to

    Require all granted

Edit suggested by @marcoooo (OP) : don't put virtualenv base dir under any home dir which do not have 'x' flag, apache www-data user won't be able to activate the virtualenv either.... Many thanxs to e4c5 for his help, and saved my day (and nights)