Is your mywebtool module/package under:

    /var/www/FLASKAPPS

or:

    /var/www/wsgi-scripts

Are the directories/files readable to the user that Apache runs as?

Is mod_wsgi compiled for Python 2.7 or 3.X?

If mywebtool is a package, does it have an __init__.py file in it.

Graham

> On 30 Oct 2018, at 11:05 am, wc <wcoll...@ucdavis.edu> wrote:
> 
> Thank you both for your replies. I now have a better understanding of the 
> wsgi framework and I am using the error log to my advantage. I was able to 
> find an error in my httpd.conf - I was using Apache 2.2 syntax in my 
> directives, now I've updated it with the "Require all granted" and I am 
> getting the server to respond with the wsgi script, which I have named 
> mywebtool.wsgi - the code for which I grabbed from a stack overflow post:
> 
> def application(environ, start_response):
>     status = '200 OK'
>     output = b'Hello World!\n'
>     response_headers = [('Content-type', 'text/plain'),
>                 ('Content-Length', str(len(output)))]
>     start_response(status, response_headers)
>     return [output]
> 
> I decided to do this to verify the first 2/3 of the stack were working 
> (Apache, mod_wsgi). 
> 
> My original wsgi script taken from the flask mod_wsgi docs 
> (http://flask.pocoo.org/docs/1.0/deploying/mod_wsgi/ 
> <http://flask.pocoo.org/docs/1.0/deploying/mod_wsgi/>) is simple:
> 
> import sys
> 
> sys.path.insert(0, '/var/www/FLASKAPPS')
> 
> from mywebtool import app as application
> 
> 
> 
> and points to the Hello World python app I was calling originally (again, got 
> this basic python script from a tutorial at 
> https://www.bogotobogo.com/python/Flask/Python_Flask_HelloWorld_App_with_Apache_WSGI_Ubuntu14.php
>  
> <https://www.bogotobogo.com/python/Flask/Python_Flask_HelloWorld_App_with_Apache_WSGI_Ubuntu14.php>):
> 
>  
> $ cat mywebtool.py
> from flask import Flask
>  
> app = Flask(__name__)
>  
> @app.route("/")
> def hello():
>     return "Hello world!"
>  
> if __name__ == "__main__":
>     app.run()
> 
> But, this is failing. When I tailed the Apache error log, I saw:
> 
> [Mon Oct 29 15:53:08.108746 2018] [wsgi:error] [pid 20474] [client 
> 185.26.34.125:53717] ImportError: No module named mywebtool
> [Mon Oct 29 15:55:30.445940 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359] mod_wsgi (pid=20476): Failed to exec Python script file 
> '/var/www/wsgi-scripts/mywebtool.wsgi'.
> [Mon Oct 29 15:55:30.446038 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359] mod_wsgi (pid=20476): Exception occurred processing WSGI 
> script '/var/www/wsgi-scripts/mywebtool.wsgi'.
> [Mon Oct 29 15:55:30.446059 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359] Traceback (most recent call last):
> [Mon Oct 29 15:55:30.446084 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359]   File "/var/www/wsgi-scripts/mywebtool.wsgi", line 1, 
> in <module>
> [Mon Oct 29 15:55:30.446150 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359]     from mywebtool import app as application
> [Mon Oct 29 15:55:30.446173 2018] [wsgi:error] [pid 20476] [client 
> 60.248.94.241:50359] ImportError: No module named mywebtool
> 
> Obviously, I named my python file "mywebtool.py" as I say in the wsgi script, 
> which leads me to two potential conclusions - 1. I'm not properly referring 
> to the .py in the wsgi script, or 2. my python script is not executing due to 
> a problem with python, or  with the python code itself.
> 
> I'm optimistic I'm getting closer here...
>  
>  
> 
> On Monday, October 29, 2018 at 4:00:21 PM UTC-7, Graham Dumpleton wrote:
> I'd agree on that except as noted.
> 
> If the error message from the Apache error log is shown, along with 
> configuration for your WSGI application in Apache config, as well as saying 
> where your Python application code is located, that would help to give better 
> idea of what is going on.
> 
>> On 30 Oct 2018, at 9:57 am, Peter Lai <pete...@ <>pw.utc.com 
>> <http://pw.utc.com/>> wrote:
>> 
>> 403 usually means that the directory to which you are hosting the .wsgi 
>> isn't configured with:
>> 
>> <Directory /path/to/your/app.wsgi>
> 
> Except that the argument is a directory path, not full path to WSGI script 
> file.
> 
>>     AllowOverride None
>>     Require all granted
>> </Directory>
>> 
>> This is required even though you have configured WSGIScriptAlias 
>> /web/path/to/app /path/to/your/app.wsgi
>> 
>> 
>> On Monday, October 29, 2018 at 6:52:29 PM UTC-4, wc wrote:
>> Hello,
>> 
>> My colleague would like to get a Python Flask app running on our new sever. 
>> I've been scratching my head for several days and doing lots of googling to 
>> help me get just a simple hello world wsgi app to run on my FreeBSD 11.2 
>> server. I've followed some online tutorials to make a .py file, a .wsgi file 
>> and modify the http.conf file to add a virtual host.
>> 
>> When I navigate to our site, I get a 403 forbidden error.
>> 
>> I'm getting lost... but I've gone back to this checklist I found 
>> (https://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html
>>  
>> <https://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html>)
>>  to see what I might be missing.
>> 
>> I see that in Apache (version 2.4) the wsgi_module is installed when I run 
>> httpd -M
>> 
>> but when I attempt ldd mod_wsgi.so I get the following:
>> 
>> ldd: mod_wsgi.so: No such file or directory
>> 
>> At this point, I think that Python and mod_wsgi are not linked, but I am 
>> unsure. I have two versions of Python installed, 2.7 and 3.6 and I installed 
>> and updated everything using pkg with the exception of the wsgi_module, 
>> which I installed using pip2.7.
>> 
>> I'm not sure what I'm missing and if I should go back and try to uninstall, 
>> then reinstall everything from scratch, or if there's something simple I'm 
>> missing. Anyone have a similar experience or any insight on this? Also, the 
>> various tutorials I've read on deploying Dash/Flask/mod_wsgi apps seem to 
>> vary in approach and can be somewhat vague on some of the steps. I'm not 
>> sure which is the best for me. One area that's not super clear to me is 
>> whether virtual host directives for Apache2.4 should be added directly to 
>> the httpd.conf virtual hosts section, or if it should be in a separate 
>> virtual hosts file.
>> 
>> Any help anyone could offer me would be greatly appreciated!!! Thanks!
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>.
>> To post to this group, send email to mod...@ <>googlegroups.com 
>> <http://googlegroups.com/>.
>> Visit this group at https://groups.google.com/group/modwsgi 
>> <https://groups.google.com/group/modwsgi>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to modwsgi+unsubscr...@googlegroups.com 
> <mailto:modwsgi+unsubscr...@googlegroups.com>.
> To post to this group, send email to modwsgi@googlegroups.com 
> <mailto:modwsgi@googlegroups.com>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to modwsgi+unsubscr...@googlegroups.com.
To post to this group, send email to modwsgi@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to