You are currently viewing Fix ModuleNotFoundError Wsgi + Apache
Nevuer Cybersecurity & Hacking

Fix ModuleNotFoundError Wsgi + Apache

Hi, in this post I want to write about a problem that I have encountered when I configured apache with the wsgi mod to run python/wsgi scripts from apache.

The specific error is as follow:

Shell

We can think that it is a problem of the code, but executing the script manually, this error is not generated. This gives us a clue that the problem is in apache and not in the script.

The project is organized as follows:

Stylus

The python wsgi script is:

Python
pythonproyect.wsgi

The first step to fix the error is to correctly configure the apache virtual host file to correctly find our project when we make the request to the server.

The web.com.conf file in the sites-available folder must contain the following configuration:

Stylus
web.com.conf

IMPORTANT

create as many aliases as there are folders in your project, Apache needs to know every path used in your code.

The second and final step is to add the following lines to the wsgi script:

Python

The script will look like this:

Python

Remember, restart the apache server and check that the problem is solved.

References:

Leave a Reply