I believe I understand what you mean for the package vs. module structure.

I get:

$ ls -las /var/www/FLASKAPPS
total 6
1 drwxr-xr-x  2 root  wheel    3 Oct 23 17:39 .
1 drwxr-xr-x  4 root  wheel    4 Oct 23 18:10 ..
5 -rw-r--r--  1 wes   wes    148 Oct 23 17:33 mywebtool.py


When I do the ls -las 

On Monday, October 29, 2018 at 5:20:21 PM UTC-7, Graham Dumpleton wrote:
>
>
>
> On 30 Oct 2018, at 11:16 am, wc <[email protected] <javascript:>> wrote:
>
> Yes, my "mywebtool" is under 
>
> /var/www/FLASKAPPS
>
>
> I'm assuming that Apache is running as user www, though I should check 
> that and check the permissions on the file. As I recall, I uploaded the 
> files as root because I was unable to modify the directory /var/www as 
> myself from my ftp prog.
>
>
> Keep in mind it isn't just the files that need to be readable, the 
> directories down to where the files are also need to be accessible.
>
> So what do you get for:
>
>     ls -las /var/www/FLASKAPPS
>
> I installed mod_wsgi with pip2.7 ... 
>
> No... I don't have an __init__.py file, and I'm just seeing now in the 
> tutorial that the file I am calling "mywebtool.py" they are referring to as 
> __init__.py
>
>
> If you have mywebtool.py that is fine as just means you are packaging your 
> application as a module rather than a package. Later on when need to split 
> code across multiple files, better to use a package format. Because using 
> Python 2.7, must have the __init__.py in that package where as in Python 3 
> you don't need it.
>
> Graham
>
>  
>
> On Monday, October 29, 2018 at 5:08:44 PM UTC-7, Graham Dumpleton wrote:
>>
>> 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 <[email protected]> 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/) 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
>> ):
>>
>>
>>  
>>
>> $ 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 <[email protected]> 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)
>>>>  
>>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/modwsgi.
>>> For more options, visit 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/modwsgi.
>> For more options, visit 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> Visit this group at https://groups.google.com/group/modwsgi.
> For more options, visit 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to