Enabling mod_wsgi in Apache for a Django app on Gentoo

Posted by hobbes3 on Server Fault See other posts from Server Fault or by hobbes3
Published on 2012-03-07T21:21:09Z Indexed on 2013/10/25 21:58 UTC
Read the original article Hit count: 308

Filed under:
|
|
|

I installed Apache, Django, and mod_wsgi on Gentoo using emerge (on Amazon EC2).

I know that the mod_wsgi is configured in /etc/apache2/modules.d/70_mod_wsgi.conf:

<IfDefine WSGI>
LoadModule wsgi_module modules/mod_wsgi.so
</IfDefine>

# vim: ts=4 filetype=apache

So in my /etc/conf.d/apache I added the WSGI module:

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D WSGI"

But when I try to list the loaded module, mod_wsgi isn't listed.

root ~ # apache2 -M | grep wsgi
Syntax OK

I also know that mod_wsgi isn't loading properly because the Apache configuration file doesn't recognize WSGIScriptAlias.

By the way for Django to work I need to include a custom Apache configuration file. Where should I insert the line below?

Include "/var/www/localhost/htdocs/mysite/apache/apache_django_wsgi.conf"

I currently have that in the httpd.conf file but I feel like that file will get reseted whenever I upgrade Gentoo or related package.

EDIT: it seems the mod_wsgi file is located in /usr/lib64/apache2/modules/mod_wsgi.so.

Here is my detailed Apache settings:

root@ip-99-99-99-99 /usr/portage/eclass # apache2 -V
Server version: Apache/2.2.21 (Unix)
Server built:   Mar  7 2012 06:52:30
Server's Module Magic Number: 20051115:30
Server loaded:  APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"

© Server Fault or respective owner

Related posts about apache2

Related posts about django