Django on CentOS

127 views
Skip to first unread message

Robin Fourcade

unread,
Nov 8, 2015, 7:25:25 PM11/8/15
to Django users
Hello,
I'm trying to run my django project on my CentOS server.


And at the end, they say that I just have to enter my server IP address and I'll have access to my project, but I only have a 500 error: Internal Server Error

However, when I shutdown apache and run: python manage.py runsever 0.0.0.0:80, everything works fine.

How is it possible to do without runsever, because I read somewhere that it what not the right thing to do.

Can somebody help me ?

Thanks,
Robin Fourcade.

James Schneider

unread,
Nov 8, 2015, 7:59:10 PM11/8/15
to django...@googlegroups.com


On Nov 8, 2015 11:25 AM, "Robin Fourcade" <fourca...@gmail.com> wrote:
>
> Hello,
> I'm trying to run my django project on my CentOS server.
>
> I followed this tutorial : http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django
>
> And at the end, they say that I just have to enter my server IP address and I'll have access to my project, but I only have a 500 error: Internal Server Error
>

What do your Apache access and error logs have to say?

> However, when I shutdown apache and run: python manage.py runsever 0.0.0.0:80, everything works fine.
>

Then it is likely an issue with your Apache setup.

> How is it possible to do without runsever, because I read somewhere that it what not the right thing to do.

You are correct. Apache or another production grade web server should be used when your site is made available on the Internet.

>
> Can somebody help me ?
>
> Thanks,
> Robin Fourcade.
>

> --

Robin Fourcade

unread,
Nov 8, 2015, 8:59:37 PM11/8/15
to Django users
Hi,
Thanks for your answer !
(I'd add that even if apache is running, if I run the server on the port 8000, I can acces the django project on this port without any issue)

Here's the log

[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi (pid=22420): Exception occurred processing WSGI script '/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most recent call last):
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self.load_middleware()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, in load_middleware
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._setup()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._wrapped = Settings(settings_module)
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi (pid=22420): Exception occurred processing WSGI script '/var/www/html/pizzaclub/public/pizzaclub.wsgi'., referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most recent call last):, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self.load_middleware(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, in load_middleware, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     for middleware_path in settings.MIDDLEWARE_CLASSES:, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._setup(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._wrapped = Settings(settings_module), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings, referer: http://212.227.107.82/
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] mod_wsgi (pid=22420): Exception occurred processing WSGI script '/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] Traceback (most recent call last):
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]     self.load_middleware()
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, in load_middleware
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]     self._setup()
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]     self._wrapped = Settings(settings_module)
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52] mod_wsgi (pid=22420): Exception occurred processing WSGI script '/var/www/html/pizzaclub/public/pizzaclub.wsgi'., referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52] Traceback (most recent call last):, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]     self.load_middleware(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, in load_middleware, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]     for middleware_path in settings.MIDDLEWARE_CLASSES:, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]     self._setup(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]     self._wrapped = Settings(settings_module), referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)), referer: http://212.227.107.82/
[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings, referer: http://212.227.107.82/

I think I've an issue with the python version. I installed django on python 2.7, but even if I make alias python=/usr/local/bin/python2.7, the log still shows python2.6, CentOS doesn't want to use the 2.7 version by default, even if I have this:

python --version

Python 2.7.8


So I'm a bit lost here. :/


Thanks again for your help.

Gergely Polonkai

unread,
Nov 9, 2015, 7:01:45 AM11/9/15
to Django users

Hello,

no, the problem is here:

[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings, referer:http://212.227.107.82/

It seems that your settings file is either missing, or Apache is misconfigured so mod_wsgi can not find it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d93b25b2-6a65-470c-83df-60b4e1514b2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robin Fourcade

unread,
Nov 9, 2015, 8:48:14 AM11/9/15
to Django users
Hello, thanks for the answer.

I've this code in my wsgi:

import os, sys
#Calculate the path based on the location of the WSGI script
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['DJANGO_SETTINGS_MODULE'] = 'pizzaclub.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

And I don't know how to find the error as it works well when I run the project with manage.py.

My settings file is there:
/var/www/html/pizzaclub/pizza_club/settings.py

I just added this in httpd.conf:

Include "/var/www/html/pizzaclub/public/django_wsgi.conf"


and this in the wsgi:

Alias /static/ /var/www/html/pizzaclub/public/static/
Alias /media/ "/var/www/html/pizzaclub/public/media/"

WSGIScriptAlias / "/var/www/html/pizzaclub/public/pizzaclub.wsgi"
WSGIPythonPath /var/www/html/emergence/:/var/www/html/pizzaclub/pizza_club:/var/www/html/pizzaclub/pizza_club/db:/var/www/html/pizzaclub/public/media:/var/www/html/pizzaclub/apache:/usr/bin/python

<Directory "/var/www/html/pizzaclub/public">
Allow from all
</Directory>

Gergely Polonkai

unread,
Nov 9, 2015, 9:51:01 AM11/9/15
to Django users
Hello,

there’s a lot that is not clear for me in your included config:

• Why are all those paths in WSGIPythonPath?
• Are there Python modules in those directories?
• Do I get it right that your application is installed under /var/www (which is generally a bad idea)?
• Is pizzaclub/settings.py available if you stand in any of those directories? (Ie. try cd <directory>; ls pizzaclub/settings.py)

Best,
Gergely

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

James Schneider

unread,
Nov 9, 2015, 9:54:41 AM11/9/15
to django...@googlegroups.com
On Sun, Nov 8, 2015 at 12:59 PM, Robin Fourcade <fourca...@gmail.com> wrote:
Hi,
Thanks for your answer !
(I'd add that even if apache is running, if I run the server on the port 8000, I can acces the django project on this port without any issue)


That simply means that the Django runserver management command has found all of the right pieces to run, and is (mostly) irrelevant to running your site using Apache/mod_wsgi.

 
Here's the log

[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi (pid=22420): Exception occurred processing WSGI script '/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most recent call last):
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self.load_middleware()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, in load_middleware
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._setup()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     self._wrapped = Settings(settings_module)
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No module named pizzaclub.settings


Aside from the path import issue that Gergely already pointed out, you actually have a larger problem. The version of mod_wsgi that Apache is using is compiled against the wrong version of Python per your mention of Python 2.7. Even with tweaking the location of the Python interpreter to a newer version, mod_wsgi needs to be compiled against the same version that you are running. This means you need to either find an RPM that does this for you somewhere, or you need to recompile mod_wsgi yourself against the version of Python you presumably installed manually.

This guide may help, although I've never done this myself and I can't vouch for its accuracy (especially given the typo in the URL). YMMV: https://www.fir3net.com/Programming/Python/how-do-i-compile-modwgsi-for-python-27.html

 
I think I've an issue with the python version. I installed django on python 2.7, but even if I make alias python=/usr/local/bin/python2.7, the log still shows python2.6, CentOS doesn't want to use the 2.7 version by default, even if I have this:

python --version

Python 2.7.8


Creating an alias will only affect your particular user environment (and creating an alias in that manner will likely break other things on the system you are trying to do that are expecting 2.6). Apache is running as a different user and does not have a shell environment where aliases can be applied. Either upgrade CentOS to a newer release that includes a more recent version of Python by default (which would include a matching version of mod_wsgi for Apache), or recompile mod_wsgi.

Reverting to an older version of Django is also not an option because none of the currently supported Django versions work with Python 2.6 (1.4LTS ended on Oct. 1, 2015). 

 -James

Robin Fourcade

unread,
Nov 9, 2015, 10:20:55 AM11/9/15
to Django users
Hi And thanks for your answer.


Le lundi 9 novembre 2015 10:51:01 UTC+1, Gergely Polonkai a écrit :
Hello,

there’s a lot that is not clear for me in your included config:

• Why are all those paths in WSGIPythonPath?


I copy-pasted django_wsgi.conf they gave here, and I replaced by the right paths.

• Are there Python modules in those directories?

Here's all my project:

+--- pizzaclub

|   +--- pizza_club

|   |   +--- settings.py

|   |   +--- wsgi.pyc

|   |   +--- settings.pyc

|   |   +--- wsgi.py

|   |   +--- __init__.pyc

|   |   +--- __init__.py

|   |   +--- templates

|   +--- public

|   |   +--- static

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- img

|   |   |   |   +--- js

|   |   |   |   +--- css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   +--- css

|   |   +--- statics

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- js

|   |   |   |   |   +--- jquery.js

|   |   |   |   |   +--- timeparse.js

|   |   |   |   |   +--- actions.js

|   |   |   |   |   +--- collapse.js

|   |   |   |   |   +--- related-widget-wrapper.js

|   |   |   |   |   +--- admin

|   |   |   |   |   |   +--- DateTimeShortcuts.js

|   |   |   |   |   |   +--- RelatedObjectLookups.js

|   |   |   |   |   +--- LICENSE-JQUERY.txt

|   |   |   |   |   +--- urlify.js

|   |   |   |   |   +--- inlines.min.js

|   |   |   |   |   +--- jquery.init.js

|   |   |   |   |   +--- jquery.min.js

|   |   |   |   |   +--- core.js

|   |   |   |   |   +--- prepopulate.min.js

|   |   |   |   |   +--- collapse.min.js

|   |   |   |   |   +--- inlines.js

|   |   |   |   |   +--- SelectFilter2.js

|   |   |   |   |   +--- actions.min.js

|   |   |   |   |   +--- calendar.js

|   |   |   |   |   +--- SelectBox.js

|   |   |   |   |   +--- prepopulate.js

|   |   |   |   +--- css

|   |   |   |   |   +--- dashboard.css

|   |   |   |   |   +--- changelists.css

|   |   |   |   |   +--- forms.css

|   |   |   |   |   +--- widgets.css

|   |   |   |   |   +--- rtl.css

|   |   |   |   |   +--- login.css

|   |   |   |   |   +--- ie.css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   |   +--- bootstrap.js

|   |   |   |   +--- bootstrap.min.js

|   |   |   |   +--- npm.js

|   |   |   +--- css

|   |   |   |   +--- styles.css

|   |   +--- urls.pyc

|   |   +--- media

|   |   +--- django_wsgi.conf

|   |   +--- __init__.pyc

|   |   +--- pizzaclub.wsgi

|   |   +--- urls.py

|   |   +--- __init__.py

|   +--- pizza_club_order

|   |   +--- migrations

|   |   |   +--- 0003_commande_cout.pyc

|   |   |   +--- 0003_commande_cout.py

|   |   |   +--- 0002_transaction.py

|   |   |   +--- 0006_pizza_taille.pyc

|   |   |   +--- 0002_transaction.pyc

|   |   |   +--- 0007_heures.py

|   |   |   +--- 0004_auto_20151025_2251.pyc

|   |   |   +--- __init__.pyc

|   |   |   +--- 0004_auto_20151025_2251.py

|   |   |   +--- 0005_auto_20151025_2251.py

|   |   |   +--- 0007_heures.pyc

|   |   |   +--- 0005_auto_20151025_2251.pyc

|   |   |   +--- __init__.py

|   |   |   +--- 0001_initial.pyc

|   |   |   +--- 0006_pizza_taille.py

|   |   |   +--- 0001_initial.py

|   |   +--- models.pyc

|   |   +--- admin.py

|   |   +--- urls.pyc

|   |   +--- views.pyc

|   |   +--- forms.pyc

|   |   +--- admin.pyc

|   |   +--- models.py

|   |   +--- __init__.pyc

|   |   +--- views.py

|   |   +--- forms.py

|   |   +--- urls.py

|   |   +--- __init__.py

|   |   +--- tests.py

|   |   +--- templates

|   |   |   +--- pizza_club_order

|   |   |   |   +--- intervenant.html

|   |   |   |   +--- inscription.html

|   |   |   |   +--- payement.html

|   |   |   |   +--- crediter.html

|   |   |   |   +--- accueil.html

|   |   |   |   +--- tresorerie.html

|   |   |   |   +--- login.html

|   |   |   |   +--- commander.html

|   |   |   |   +--- profil.html

|   |   |   +--- base.html

|   |   |   +--- .DS_Store

|   +--- manage.py

|   +--- db.sqlite3

|   +--- apache

|   +--- db.sql


Everything is here ! (It's quite a small project)

 
• Do I get it right that your application is installed under /var/www (which is generally a bad idea)?

You're right. I didn't know it was a bad idea, I followed the previous tutorial, which actually seems to be not so great.
 
• Is pizzaclub/settings.py available if you stand in any of those directories? (Ie. try cd <directory>; ls pizzaclub/settings.py)


It's available, as we can see in my tree.
 
Best,
Gergely

Thanks,
Robin. 

Robin Fourcade

unread,
Nov 9, 2015, 10:29:12 AM11/9/15
to Django users
Thanks for your answer James,
As this server is only the run this project, I can install another linux distribution.
I'm able to install theses :


Do you think it's better to install one or another ?

Actually, I already tried on Debian 7 and I followed some tutorial but I wasn't able to run the server neither. So if you know a great tutorial which shows how to install&run a django project on one of theses distributions, it would be perfect! :)

Thanks again !

Robin.

James Schneider

unread,
Nov 9, 2015, 7:00:35 PM11/9/15
to django...@googlegroups.com
Debian 7 should work fine and would be my personal preference (all of the Linux servers that I manager are Debian), as it includes Python 2.7.3 as the default Python version. Ubuntu would be my second choice. I can personally confirm that I've had Django working under Apache/WSGI on a Debian 7 machine at some point.

The ultimate choice, though, is up to you, and how familiar you are with the particular flavor of Linux you choose. You'll be in charge of maintaining the system, so it should be something you are comfortable with.

-James

Matthias Runge

unread,
Nov 10, 2015, 7:57:50 AM11/10/15
to django...@googlegroups.com
On 09/11/15 11:29, Robin Fourcade wrote:
> Thanks for your answer James,
> As this server is only the run this project, I can install another linux
> distribution.
> I'm able to install theses :
>
> *CentOS 6 minimal system (64 bits)*
> Système de base openSUSE 13.1 (64 bits)
> Système de base Debian 7 Wheezy (64 bits)
> CentOS 6 avec Parallels Plesk Panel 12 (64 bits)
> openSUSE 13.1 avec Parallels Plesk Panel 12 (64 bits)
> Système de base ubuntu 14.04 (64 bits)
>
> Do you think it's better to install one or another ?
>
> Actually, I already tried on Debian 7 and I followed some tutorial but I
> wasn't able to run the server neither. So if you know a great tutorial
> which shows how to install&run a django project on one of theses
> distributions, it would be perfect! :)
>
> Thanks again !
>
> Robin.

CentOS 6 is fine, as you saw your developer server already worked.

Looking at your project, I can not find a file
pizzaclub.settings,
but pizza_club.settings

(see the '_' ?)

Matthias

Timothy W. Cook

unread,
Nov 10, 2015, 9:53:28 AM11/10/15
to django...@googlegroups.com
If you have the option use a different Linux distribution.  If you must use CentOS this may help with getting Apache and Python (newer than 2.6) working.   http://stackoverflow.com/questions/21158918/django-mod-wsgi-psycopg2-improperlyconfigured-error-loading-psycopg2-module  

I see that since I had the original problem others have posted that there are fixes for Python 3 and mod_wsgi.  It may work for you to use Python 3.x ???


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



--

============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Robin Fourcade

unread,
Nov 10, 2015, 2:15:54 PM11/10/15
to Django users
Thanks Matthias,

I set os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pizza_club.settings") in my wsgi.py
Now I have ImportError: Could not import settings 'pizza_club.settings' (Is it on sys.path?): No module named pizza_club.settings, referer: http://www.pizzaclub.fr/

Is that what you meant ? Because the problem is still there. :/


--------------------------------------------------

Thanks Timothy,
I'll check the link you gave me. :)

Thanks again,

Robin

James Schneider

unread,
Nov 10, 2015, 3:40:06 PM11/10/15
to django...@googlegroups.com

I would strongly suggest abandoning trying to fix the import problem until you either a) verify that you have recompiled mod_wsgi with the correct Python version or b) switch to a distribution that uses a supported version of Python by default.

At this point, you are wasting time and you may not even be able to fix it without a supported version of Python being used by Apache/mod_wsgi. It's like trying to fix a flat tire on a car and expecting it to be able to drive when you know the engine is missing.

Also, if you have a virtualenv that has the correct Python version on that system, you'll need to verify that mod_wsgi is using that Python interpreter, but that won't work with your current version of mod_wsgi.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Robin Fourcade

unread,
Nov 10, 2015, 5:46:36 PM11/10/15
to Django users
Thanks James,
I looked at many tutorials like:


Neither of these are for python 3.7 or higher. :/
i would gladly use higher version of python but I can't find any tutorial about it. :/

James Schneider

unread,
Nov 11, 2015, 9:04:44 AM11/11/15
to django...@googlegroups.com

Python 3.7 would be quite a feat considering it hasn't been invented yet. ;-P

Take a look at these and focus on the parts pertaining to Apache/httpd and mod_wsgi.

https://github.com/crits/crits/wiki/RHEL-Supplemental-Install-Guide

https://www.webhostpython.com/billing/knowledgebase.php?action=displayarticle&id=33

https://www.google.com/search?q=centos+6+python+2.7&oq=centos+6+python+&aqs=chrome.1.69i57j0l3.8479j1j4&client=ms-android-hms-tmobile-us&sourceid=chrome-mobile&ie=UTF-8#q=centos+6+python+2.7+mod_wsgi

If you aren't comfortable compiling your own stuff, you should consider switching to a distribution that supports 2.7 by default. RHEL/CentOS is pretty much the last notable holdout due to their extended release schedule.

-James

Robin Fourcade

unread,
Nov 11, 2015, 7:01:04 PM11/11/15
to Django users
As I'm not comfortable at all with this, I tried with ubuntu, wich has python 2.7 by default.


Everything was working well, except at the end, I've 403 error.

[Wed Nov 11 12:56:37.525607 2015] [mpm_event:notice] [pid 28089:tid 140367682340736] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 12:56:37.635193 2015] [mpm_event:notice] [pid 28192:tid 140578408851328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Wed Nov 11 12:56:37.635323 2015] [core:notice] [pid 28192:tid 140578408851328] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 12:56:39.823415 2015] [core:error] [pid 28196:tid 140578239018752] (13)Permission denied: [client 109.10.154.52:50531] AH00035: access to / denied (filesystem path '/root/pizzaclub') because search permissions are missing on a component of the path
[Wed Nov 11 12:56:40.046750 2015] [core:error] [pid 28196:tid 140578228528896] (13)Permission denied: [client 109.10.154.52:50531] AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') because search permissions are missing on a component of the path, referer: http://s18710917.domainepardefaut.fr/
[Wed Nov 11 12:56:41.625131 2015] [core:error] [pid 28196:tid 140578218039040] (13)Permission denied: [client 109.10.154.52:50531] AH00035: access to / denied (filesystem path '/root/pizzaclub') because search permissions are missing on a component of the path
[Wed Nov 11 12:56:41.871027 2015] [core:error] [pid 28196:tid 140578207549184] (13)Permission denied: [client 109.10.154.52:50531] AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') because search permissions are missing on a component of the path, referer: http://s18710917.domainepardefaut.fr/

I tried this: 

chmod g+x ./*
or 
chmod +x /root/pizzaclub

But it didn't solve anything. I followed the tutorial line after line, just to test (no even with my own project).

Thanks again,
Robin.

Luis Zárate

unread,
Nov 11, 2015, 7:24:45 PM11/11/15
to django...@googlegroups.com
Are you install your app as root user? (/root/pizzaclub)

The permission denied it's because apache run as www-data or http user not as root, so if you install your app as root you probably have read/write permission problems and a big security issue.




2015-11-11 13:01 GMT-06:00 Robin Fourcade <fourca...@gmail.com>:
/root/pizzaclub




--
"La utopía sirve para caminar" Fernando Birri


Robin Fourcade

unread,
Nov 11, 2015, 7:50:04 PM11/11/15
to Django users
Hi, 
thanks for your answer.

That's what I did. So if it's a big issue, I'll create a new user on my server and I'll redo the installation through this user !

Thanks,
Robin.

Robin Fourcade

unread,
Nov 11, 2015, 9:09:40 PM11/11/15
to Django users
Hi,

So I made another install with a new user (pizzaclub).

I wrote this in the default.conf:

<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

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

Alias /static /home/pizzaclub/pizzaclub/static
    <Directory /home/pizzaclub/pizzaclub/static>
        Require all granted
    </Directory>

    <Directory /home/pizzaclub/pizzaclub/static>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess pizzaclub python-path=/home/pizzaclub:/home/pizzaclub/pizzaclubenv/lib/python2.7/site-packages
    WSGIProcessGroup pizzaclub
    WSGIScriptAlias / /home/pizzaclub/pizzaclub/wsgi.py

</VirtualHost>

And I still have the same issue which is the 403 error:

[Wed Nov 11 15:07:26.244727 2015] [mpm_event:notice] [pid 27193:tid 140432722884480] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 15:07:26.354982 2015] [mpm_event:notice] [pid 27289:tid 140603486005120] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Wed Nov 11 15:07:26.355107 2015] [core:notice] [pid 27289:tid 140603486005120] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 15:07:28.461063 2015] [authz_core:error] [pid 27293:tid 140603387373312] [client 109.10.154.52:51815] AH01630: client denied by server configuration: /home/pizzaclub/pizzaclub/wsgi.py
[Wed Nov 11 15:07:30.563364 2015] [authz_core:error] [pid 27293:tid 140603376875264] [client 109.10.154.52:51815] AH01630: client denied by server configuration: /home/pizzaclub/pizzaclub/wsgi.py


Thanks again,

Robin.

Robin Fourcade

unread,
Nov 11, 2015, 10:15:41 PM11/11/15
to Django users
Riiigghh,
After many many many tries, it finally worked !

Thanks again, thank you, everybody!

Robin.

-- SOLVED.
Reply all
Reply to author
Forward
0 new messages