Ok thanks.

I did chmod 755 on the mywebtool.py file (plus starting and stopping Apache 
with each iteration) and I still get a 404 Not Found error in the browser, 
but I'm not getting any errors in the Apache error log any longer:

[Mon Oct 29 17:30:29.609529 2018] [mpm_prefork:notice] [pid 20949] AH00163: 
Apache/2.4.35 (FreeBSD) mod_wsgi/4.6.4 Python/2.7 configured -- resuming 
normal operations
[Mon Oct 29 17:30:29.609818 2018] [core:notice] [pid 20949] AH00094: 
Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'



On Monday, October 29, 2018 at 5:39:46 PM UTC-7, Graham Dumpleton wrote:
>
> Nothing should be cached from old version of file, but to be safe I would 
> suggest stopping and starting Apache, trying again and seeing what error 
> you get.
>
> Also see comments below.
>
> On 30 Oct 2018, at 11:36 am, wc <wcol...@ucdavis.edu <javascript:>> wrote:
>
> mywebtool.wsgi is indeed in the location you noted
>
> my virtual host section (showing the WSGIScriptAlias) is:
>
> <VirtualHost *:80>
>
>     ServerName my.server.edu
>
>     DocumentRoot /var/www/FLASKAPPS
>
>
> You should not set DocumentRoot to be where your application code is. If 
> you remove the WSGIScriptAlias, people can download your source code. Leave 
> DocumentRoot as global default, or point it at an empty directory.
>
>
>     <Directory /var/www/FLASKAPPS>
>         Require all granted
>     </Directory>
>
>
> You don't need this above.
>
>
>     WSGIScriptAlias / /var/www/wsgi-scripts/mywebtool.wsgi
>
>     <Directory /var/www/wsgi-scripts>
>         Require all granted
>     </Directory>
>     
> </VirtualHost>
>
> On Monday, October 29, 2018 at 5:30:05 PM UTC-7, Graham Dumpleton wrote:
>>
>> Where is 'mywebtool.wsgi'.
>>
>> The error suggests:
>>
>>     /var/www/wsgi-scripts/mywebtool.wsgi
>>
>> yet, the error also says:
>>
>> [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
>>
>> so is talking about the import being on line 1, so it doesn't match what 
>> you said was in that, which you said was:
>>
>> import sys
>>
>> sys.path.insert(0, '/var/www/FLASKAPPS')
>>
>> from mywebtool import app as application
>>
>>
>> The import error should have said line 5, not line 1.
>>
>> So check path for WSGIScriptAlias and that the code file does update 
>> sys.path.
>>
>> Graham
>>
>>
>> On 30 Oct 2018, at 11:24 am, wc <wcol...@ucdavis.edu> wrote:
>>
>> 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 <wcol...@ucdavis.edu> 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 <wcol...@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/) 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 <pete...@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)
>>>>>>  
>>>>>> 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.
>>>>> To post to this group, send email to mod...@googlegroups.com.
>>>>> 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 modwsgi+u...@googlegroups.com.
>>>> To post to this group, send email to mod...@googlegroups.com.
>>>> 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 modwsgi+u...@googlegroups.com.
>>> To post to this group, send email to mod...@googlegroups.com.
>>> 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 modwsgi+u...@googlegroups.com.
>> To post to this group, send email to mod...@googlegroups.com.
>> 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 modwsgi+u...@googlegroups.com <javascript:>.
> To post to this group, send email to mod...@googlegroups.com <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 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