HOWTO: run Django on Apache and mod_wsgi
sean Thank you very much Sean.
Apache server is running, but we checked and we obtained a 500 error.
When we checked logs we saw this:
[Tue Dec 15 23:05:13.939600 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] from zinnia.models.entry import Entry
[Tue Dec 15 23:05:13.939604 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] File "/home/{OpalUser}/apps/{myapp}/lib/python2.7/django_blog_zinnia-0.12.3-py2.7.egg/zinnia/models/entry.py", line 24, in <module>
[Tue Dec 15 23:05:13.939612 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] from zinnia.models.category import Category
[Tue Dec 15 23:05:13.939616 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] File "/home/{OpalUser}/apps/{myapp}/lib/python2.7/django_blog_zinnia-0.12.3-py2.7.egg/zinnia/models/category.py", line 5, in <module>
[Tue Dec 15 23:05:13.939624 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] from mptt.models import MPTTModel
[Tue Dec 15 23:05:13.939635 2020] [wsgi:error] [pid 129026:tid 140655410722560] [remote ::1:40646] ImportError: No module named mptt.models
When we checked the dependances at
/home/{OpalUser}/apps/{myapp}/lib/python2.7
we saw that we have that dependances:
django_blog_zinnia-0.12.3-py2.7.egg
django_mptt-0.5.4-py2.7.egg-info
PD: Sorry for my explanation I don't use to write in english, my mother tongue is spanish.
joshuccr WebFaction did a lot of weird non-standard stuff with Python search paths so your default library setup isn't going to work here.
The first two steps in the procedure are intended to cover that:
- Make a Python 2.7 environment for your Python dependencies: Python Virtual Environments | Opalstack Support Center
- Install your Python dependencies into the new environment.
You'll need to install any packages that were in your appname/lib/python2.7
and in your ~/lib/python2.7
directory at WF.
sean Thanks a lot. It is very hard for us to migrate all django projects, because have the same Webfaction Structure in all of them.
Sean, we have already created python 2.7 virtual environment.
Is it possible to move with filezilla all dependances that we have in appname/lib/python2.7 and ~/lib/python2.7, directly in env/lib/python2.7/site-packages?
The projects don't have a requirements.txt file for use pip.
sean Thanks
Well we created a virtual env and install all dependances of both projects and we obtained this error when we run Apache2 (we changed in httpd.conf this:
/home/{OpalUser}/apps/{myapp}/lib/python2.7 -> /home/{OpalUser}/apps/{myapp}/env)
[Wed Dec 16 01:01:53.723176 2020] [wsgi:error] [pid 240845:tid 140655410722560] [remote ::1:41240] from django.core.wsgi import get_wsgi_application
[Wed Dec 16 01:01:53.723196 2020] [wsgi:error] [pid 240845:tid 140655410722560] [remote ::1:41240] ImportError: No module named django.core.wsgi
[Wed Dec 16 01:01:53.816825 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] mod_wsgi (pid=240845): Target WSGI script '/home/ccr/apps/django_ccr_apache/ccr-web/wsgi.py' cannot be loaded as Python module.
[Wed Dec 16 01:01:53.816866 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] mod_wsgi (pid=240845): Exception occurred processing WSGI script '/home/{OpalUser}/apps/{myapp}/{myproject}/wsgi.py'.
[Wed Dec 16 01:01:53.816915 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] Traceback (most recent call last):
[Wed Dec 16 01:01:53.816964 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] File "/home/ccr/apps/django_ccr_apache/ccr-web/wsgi.py", line 23, in <module>
[Wed Dec 16 01:01:53.817029 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] from django.core.wsgi import get_wsgi_application
[Wed Dec 16 01:01:53.817071 2020] [wsgi:error] [pid 240845:tid 140655263209216] [remote 127.0.0.1:49356] ImportError: No module named django.core.wsgi
We didn't install this dependance in our requiriment file.