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

ApacheUbuntuMod WsgiWsgiCkan

Apache Problem Overview


I got the below error while I was configuring CKAN DataPusher.

> Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a > module not included in the server configurationAction 'configtest' > failed.

How can I fix this?

Apache Solutions


Solution 1 - Apache

Try to enable wsgi mod in Apache

sudo a2enmod wsgi

If you come across below error

> ERROR: Module mod-wsgi does not exist!

You will have to install mod wsgi as below. What you have to do is run the following commands,

sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
sudo service apache2 restart

Solution 2 - Apache

To enable wsgi_mod in httpd, install the module

sudo yum install mod_wsgi

and make sure to load the module in the httpd config file

sudo nano /etc/httpd/conf/httpd.conf

then add the following line in the config file, to the list of other loaded module:

LoadModule wsgi_module modules/mod_wsgi.so

Solution 3 - Apache

I faced this problem because

  1. I installed mod_wsgi which was compatible with python3.5, but my project's virtual environment was using python3.7. So, mod_wsgi for 3.7 was required. I installed that as well (python3.7 -m pip install mod_wsgi). But a configuration was missing from apache2 which resulted in this issue.

  2. run : mod_wsgi-express module-config
    add the output in /etc/apache2/apache.conf ( LoadModule wsgi_module "/home/user/.local/lib/python3.7/site-packages/mod_wsgi/server/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so" WSGIPythonHome "/usr" )

    then restart - sudo service apache2 restart

This solved the problem.

Solution 4 - Apache

I had this error after messing up my Apache installation and restarting the setup after an apt purge apache2. This also seems to have removed the wsgi mod but Ubuntu 20 LTS kept thinking it's still around.

So I had to to purge and reinstall the wsgi mod from scratch:

apt purge -y libapache2-mod-wsgi-py3
apt install -y libapache2-mod-wsgi-py3
a2enmod wsgi

After that, Apache was able to find it again.

Solution 5 - Apache

I think you might need to add this line in your apache2.conf

LoadModule wsgi_module "/usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"

Below command will give you the above output

mod_wsgi-express module-config

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTechieView Question on Stackoverflow
Solution 1 - ApacheTechieView Answer on Stackoverflow
Solution 2 - ApacheSamerView Answer on Stackoverflow
Solution 3 - ApacheChandrika MukherjeeView Answer on Stackoverflow
Solution 4 - ApacheroskakoriView Answer on Stackoverflow
Solution 5 - ApacheRajeshView Answer on Stackoverflow