39

I am using Django 1.8 on CentOS 6.7 with Apache Server version: Apache/2.2.15 (Unix).

I have followed the steps in How To Serve Django Applications with Apache and mod_wsgi on CentOS 7. But at last step when I start the Apache server with command : service httpd start instead of systemctl start httpd beacuse I have Centos 6.7 not CentOS 7 according to tutorial.

It is giving the following error:

Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/django.conf:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module ot included in the server configuration

you can check the django.conf here:

Alias /static /home/ftpispy/ispy/static
<Directory /home/ftpispy/ispy/static>
    Require all granted
</Directory>
<Directory /home/ftpispy/ispy/ispy>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>
WSGIDaemonProcess ispy python-path=/home/ftpispy/ispy:/home/ftpispy/ispy/venv/lib/python2.7/site-packages
WSGIProcessGroup ispy
WSGIScriptAlias / /home/ftpispy/ispy/ispy/wsgi.py

Thanks in advance.Please suggest any other option to deploy on CentOS 6.7 with djnago 1.8.

Himanshu dua
  • 2,496
  • 1
  • 20
  • 27

6 Answers6

53

make sure you have wsgi package installed, by running

sudo a2enmod wsgi

if its not installed, execute below commands to install

for python2

sudo apt-get install python-pip apache2 libapache2-mod-wsgi

for python3

sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3
sha12
  • 1,497
  • 1
  • 17
  • 14
  • 15
    How does this have 8 upvotes? original question was about CentOS, this answer suggests using apt-get?! – deweydb Dec 13 '18 at 01:53
  • 5
    I searched for the same issue for Ubuntu and I landed on this page. I found the solution later, I added it here if in case someone else lands on the same page like me. – sha12 Dec 13 '18 at 10:36
  • Hi, I'm getting "No package libapache2-mod-wsgi-py3 available", Help me out to fix this. – kathir raja Dec 27 '19 at 11:24
  • what is the full command you are using to install libapache2-mod-wsgi-py3 ?? try updating your apt-get, "sudo apt-get update" and then try installing. – sha12 Jan 07 '20 at 11:02
  • 3
    The question was for CentOS not for ubuntu, so the apt commands wont work.. – dev.ink Feb 21 '20 at 10:01
  • how does this work for aws ec2. mod-wsgi- they provide is not for python3? i used pip3 to install mod_wsgi. now i cannot start apache – shorif2000 Jul 20 '20 at 14:19
15

Right way to install mod_wsgi today in 2020 (source: https://github.com/GrahamDumpleton/mod_wsgi/issues/233)

I. Uninstall libapache2-mod-wsgi

sudo apt-get remove libapache2-mod-wsgi

sudo apt-get remove libapache2-mod-wsgi-py3

II. Use pip to install mod_wsgi

pip install mod_wsgi

If it is already installed, update it:

pip uninstall mod_wsgi
pip install mod_wsgi

III. After that, mod_wsgi-express command must be available. Use it with

mod_wsgi-express module-config

IV. Grab its output, this is what you need to tell Apache where to find your new mod_wsgi version.
V. Update wsgi.load file

sudo nano /etc/apache2/mods-available/wsgi.load

remove any lines of wsgi.load And past the output from IV

VI. Ensure mod_wsgi is enabled:

sudo a2enmod wsgi

VII. Restart your apache service

systemctl reload apache2
snoob dogg
  • 2,491
  • 3
  • 31
  • 54
6

The mod_wsgi module should be enabled for Apache. Make sure you have symlinks setup in /etc/apache2/mods-enabled/ pointing to wsgi.conf and wsgi.load in /etc/apache2/mods-available/.

On a side note, check out the latest generation of mod_wsgi, it provides a convenient way to launch wsgi applications using a simple tool mod_wsgi-express (without the hassle of setting up an httpd configuration).

sirfz
  • 4,097
  • 23
  • 37
2

I had the same Problem. Actually I did not load the mod_wsgi module in httpd.conf file. After spending many hours I solved by adding

LoadModule wsgi_module modules/mod_wsgi.so

in to the httpd.conf file. Then there is no more error.

Anu Alex
  • 230
  • 2
  • 5
  • 19
0

I had a similar error

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

Because forgot to write "/" before path

WSGIScriptAlias / /var/www...

devugur
  • 1,339
  • 1
  • 19
  • 25
0

Ensure that the correct version of mod_wsgi is installed in CentOS. The mod_wsgi that comes with the yum repo is compiled based on (iirc) python 2.6. You need mod_wsgi compiled using python 2.7.

I think [1] might help you with it, though it mentions CentOS 5/6 using python 2.4 (CentOS 6.7 uses python 2.6 as the basis).

[1] - https://blog.webhostpython.com/2015/01/12/how-to-install-python-2-7-with-mod_wsgi-on-a-centos-6-vps-or-server-with-cpanel/

ewokx
  • 2,204
  • 3
  • 14
  • 27