Custom HTTPD template for mod_wsgi (mod_wsgi in daemon mode & Django)

vverloop

Verified User
Joined
Mar 30, 2010
Messages
35
I have installed mod_wsgi global by installing mod_wsgi from source.
See the following link:
https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html

After that open the following line:
Code:
nano /etc/httpd/conf/extra/httpd-phpmodules.conf

And added the following line:
Code:
LoadModule wsgi_module /usr/lib/apache/mod_wsgi.so

Save and Exit the file, if you restart the httpd instances within DirectAdmin, they will all have access to mod_wsgi features.


I want to add the following code to httpd template, so i can run Django in Production Mode (mod_wsgi in daemon mode):

Code:
WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIDaemonProcess ProcessUser threads=25
WSGIProcessGroup ProcessGroup

See the following link for more information:
https://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html


I want to run Django at a subdomain. (Django is already working)
But when i add the right code to the custom HTTPD template in Directadmin Admin level, i get the following error:
Code:
AH00526: Syntax error on line 42 of /usr/local/directadmin/data/users/xxxxxxx/httpd.conf:
Name duplicates previous WSGI daemon definition.

The code is inserted in all other subdomains.

I'm searching for the right tutorial, how i get mod_wsgi inserted in custom httpd templates.
I hope somebody can help me with this, get it working at a subdomain.
 
Last edited:
Get it to work, but not via Admin Level > Custom HTTPD

When i put the following code the the top of , by SSH it is working:
Code:
/usr/local/directadmin/data/users/xxxxxxx/httpd.conf

Code:
WSGIScriptAlias / /home/xxxxxx/domains/domain.com/public_html/django/myproject/wsgi.py
WSGIDaemonProcess ProcessUser python-path=/home/xxxxxxx/domains/domain.com/public_html/django/:/home/xxxxxxx/.virtualenvs/myproject/lib/python2.7/site-packages
WSGIProcessGroup ProcessGroup
 
Last edited:
You shoudln't use this file: /usr/local/directadmin/data/users/xxxxxxx/httpd.conf
It get overwritten by DA.

You should use custom httpd config in admin level, which custom part you need to add this mostly depend on where in the httpd.conf this need to appear.

To have a better idea check the file: /usr/local/directadmin/data/templates/virtual_host2.conf
and see the |CUSTOM part where they are, find the one more appropriate than add the code in your Custom HTTPD Configuration in DA on the relative section.

Best regards
 
Apache and Django don't work good together, with every change in your website you have to restart Apache.
With Nginx it not needed to restart Nginx.

Django sucks in this way.

Better support for Django should be apprenticed.
 
Can you use the Passenger module? (from the Phusion guys).

I've used it in the past with Ruby applications, along with the Custom HTTPD mentioned above, with something similar to this as my custom httpd config:

Code:
|?DOCROOT=/home/your-user/path-to-django-app/public
 
Back
Top