mod_wsgi
mod_wsgi copied to clipboard
Target WSGI script not found or unable to stat
I'm trying to deploy a Django app on Amazon Linux-2. So, I downloaded the mod_wsgi from this Github repo built using python3.8 and then added Apache directives. And, then I got below error
[Thu May 12 08:44:23.969822 2022] [wsgi:error] [pid 10618] [client 10.0.1.152:50330] Target WSGI script not found or unable to stat: /home/ubuntu/deployment/config.wsgi
My Apache config looks like this
WSGIDaemonProcess myapp python-home=/home/ubuntu/deployment/.venv
WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /api "/home/ubuntu/deployment/prim.wsgi"
<Directory /home/ubuntu/deployment>
Require all granted
</Directory> ```
Below are the steps I followed
1. Downloadded the mod_wsgi tarball
2. built using make with python3.8
3. Added the path on built mod_wsgi.so file to LoadModule
Ensure you have reloaded Apache after changing configuration. The path you have in the Apache configuration file doesn't correspond with the error message, so you haven't reloaded Apache, or you have a conflicting configuration elsewhere in the Apache configuration. What is the path to the file you added the Apache configuration in?
Hi @GrahamDumpleton I have reloaded the Apache after changing the configuration. Also, I put this config directly within the main apache config for faster testing. I will add this to sites-available and create a symlink to the sites-enabled.
Hi @GrahamDumpleton The path of the file is sites-available/test_wsgi.conf
and I have added a symlink to the sites-enabled/test_wsgi.conf
Now, I'm getting this error
[Thu May 12 10:43:46.971113 2022] [authz_core:error] [pid 11817] [client 10.0.0.83:38742] AH01630: client denied by server configuration: /etc/httpd/htdocs
Also, If I visit the page then it toggles between 502 Bad gateway and 200 Success page(It's working on one refresh and is giving 502 Bad gateway on every second refresh). One thing I missed out on was we have ELB in front of our EC2 machines. Is it something ELB may have been causing?
@GrahamDumpleton If I could see a sample Apache config then I would be able to set my virtualenv which could resolve the issue of no module found and plus if I could see an example of permissions on the file then I could solve this.
Hi there
your initial issue is: [Thu May 12 08:44:23.969822 2022] [wsgi:error] [pid 10618] [client 10.0.1.152:50330] Target WSGI script not found or unable to stat: /home/ubuntu/deployment/config.wsgi
Than your next issue is: [Thu May 12 10:43:46.971113 2022] [authz_core:error] [pid 11817] [client 10.0.0.83:38742] AH01630: client denied by server configuration: /etc/httpd/htdocs
By the look, both are user errors. Nothing to do with Amazon, I think.