23

I want to deploy my Django project to EC2 server. I installed mod_wsgi.

And made configuration like in the tutorial of django.

I am getting the following:

Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration

What is the reason? mod_wsgi is not installed correctly?

LoadModule wsgi_module     libexec/httpd/mod_wsgi.so
LoadModule alias_module    libexec/httpd/mod_alias.so


WSGIScriptAlias / /usr/local/apache2/htdocs/mysite/mysite/wsgi.py
WSGIPythonPath /usr/local/apache2/htdocs/mysite/mysite


<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Burak
  • 5,586
  • 19
  • 67
  • 109

4 Answers4

50

The problem is that mod_wsgi is not installed properly.

Solution (using Apache 2):

  1. install Apache:

    $ sudo apt-get install apache2
    
  2. install libapache2-mod-wsgi:

    $ sudo apt-get install libapache2-mod-wsgi
    

And this should work fine.

palacsint
  • 27,430
  • 10
  • 76
  • 108
om choudhary
  • 501
  • 1
  • 4
  • 2
19

The error specifically indicates that mod_wsgi is not being loaded into Apache.

In what file is:

LoadModule wsgi_module     libexec/httpd/mod_wsgi.so

Did you enable the mod_wsgi module with appropriate Linux distro management command so that it will be loaded if you used distro binary packages for mod_wsgi?

Graham Dumpleton
  • 56,277
  • 6
  • 111
  • 129
  • 2
    For me it worked by issuing the following command: sudo a2enmod wsgi (http://stackoverflow.com/a/20627328/811335) – A. K. Jun 06 '14 at 04:36
1

just to add, How I solved my problem if you don't know the location of the modules just search for them

 locate mod_alias.so

then you may get output like

/usr/lib/apache2/modules/mod_alias.so

then you can add that location in your config file

LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
madhu131313
  • 6,371
  • 7
  • 37
  • 52
1

I just encountered the very same issue on openSUSE 12.2, with apache 2.2.

Even if wsgi is installed, it is a good idea to check if it has been activated. What I mean is this:

#outputs a list of registered modules
/usr/sbin/httpd2 -M

If wsgi_module (shared) does not appear, add wsgi to the variable APACHE_MODULES, inside the file /etc/sysconfig/apache2

This way I could avoid altogether the line LoadModule from httpd.conf.

pbarill
  • 608
  • 6
  • 16