In the process of getting my Django app running in production, I became aware that apt-get mod_wsgi didn't install the correct version of mod_wsgi. And the advice was to pip install mod_wsgi in my virtual environment.
I'm running an AWS Small Ubuntu 16.04.4 LTS server and Python 3.5.
My virtual environment is /usr/local/pulseenv and contains mod-wsgi 4.6.4.
My vhost file (/etc/apache2/sites-available/000-default.conf) has:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
DocumentRoot /var/www/pulsemanager/pulsemanager
Alias /static /var/www/pulsemanager/pulsemanager/static
<Directory /var/www/pulsemanager/pulsemanager/static>
Require all granted
</Directory>
<Directory /var/www/pulsemanager/config>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /var/www/pulsemanager/config/wsgi.py
#WSGIDaemonProcess pulsemanager
WSGIPythonHome /usr/local/pulseenv
WSGIPythonPath /var/www/pulsemanager
#WSGIProcessGroup pulsemanager
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
But when I try to start apache, I get this error:
ubuntu@ip-172-31-84-213:~$ systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Fri 2018-05-04 01:35:16 UTC; 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 6697 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: * The apache2 configtest failed.
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Output of config test was:
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: AH00526: Syntax error on line 42 of /etc/apache2/sites-enabled/000-default.conf:
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Action 'configtest' failed.
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: The Apache error log may have more information.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Control process exited, code=exited status=1
May 04 01:35:16 ip-172-31-84-213 systemd[1]: Failed to start LSB: Apache2 web server.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Unit entered failed state.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Failed with result 'exit-code'.
lines 1-18/18 (END)
So it seems like mod_wsgi must not be found by Apache. (Is that where the WSGI* commands are?) So how do I configure Apache using pip install mod_wsgi?
mod_wsgi-express module-config
and add the result into your Apache configuration? Details in section 'Connecting into Apache installation' of pypi.org/project/mod_wsgi – Graham Dumpleton