> On 21 Oct 2022, at 6:40 pm, Malcolm Cook <[email protected]> wrote:
> 
> Hello,
> 
> I have configured apache2 for running any .wsgi apps out of ~/public_html 
> 
> It works for a simple ~/public_html/hello_world.wsgi
> 
> Hooray!
> 
> However, I am having trouble when my app uses
> 
>     /usr/bin/python3 -m venv venv
> 
> with the simplest of dash apps.
> 
> I have so far learned to include in my app.wsgi the following:
> 
>     site.addsitedir('/home/mec/public_html/dash101/dash101.wsgi')

The site.addsitedir() function accepts a directory, not a file. For working 
with virtual environments ensure you read

    
https://modwsgi.readthedocs.io/en/master/user-guides/virtual-environments.html

> allowing the app to find the dash modules installed into its venv when run 
> under apache mod_wsgi.
> 
> The app now works from the command line; when run under apache mod_wsgi it 
> only successfully finds the modules in the venv but then fails with:
> 
> [root@hd1991356yb mec]# [Fri Oct 21 01:04:29.974555 2022] [wsgi:info] [pid 
> 69391] mod_wsgi (pid=69391): Create interpreter 
> 'hd1991356yb.sgc.loc|/~mec/dash101/app.wsgi'.
> [Fri Oct 21 01:04:29.989457 2022] [wsgi:info] [pid 69391] [client 
> 10.2.20.25:41124] mod_wsgi (pid=69391, process='', 
> application='hd1991356yb.sgc.loc|/~mec/dash101/app.wsgi'): Loading Python 
> script file '/home/mec/public_html/dash101/app.wsgi'., referer: 
> http://hd1991356yb/~mec/dash101/
> [Fri Oct 21 01:04:30.891229 2022] [wsgi:error] [pid 69391] 
> /home/mec/public_html/dash101/app.py:2: UserWarning:
> [Fri Oct 21 01:04:30.891279 2022] [wsgi:error] [pid 69391] The 
> dash_html_components package is deprecated. Please replace
> [Fri Oct 21 01:04:30.891289 2022] [wsgi:error] [pid 69391] `import 
> dash_html_components as html` with `from dash import html`
> [Fri Oct 21 01:04:30.891298 2022] [wsgi:error] [pid 69391]   import 
> dash_html_components as html
> [Fri Oct 21 01:04:33.661364 2022] [wsgi:error] [pid 69391] 
> /home/mec/public_html/dash101/app.py:4: UserWarning:
> [Fri Oct 21 01:04:33.661397 2022] [wsgi:error] [pid 69391]
> [Fri Oct 21 01:04:33.661403 2022] [wsgi:error] [pid 69391]
> [Fri Oct 21 01:04:33.661408 2022] [wsgi:error] [pid 69391] The 
> dash_core_components package is deprecated. Please replace
> [Fri Oct 21 01:04:33.661413 2022] [wsgi:error] [pid 69391] `import 
> dash_core_components as dcc` with `from dash import dcc`
> [Fri Oct 21 01:04:33.661417 2022] [wsgi:error] [pid 69391]
> [Fri Oct 21 01:04:34.825419 2022] [core:info] [pid 69391] [client 
> 10.2.20.25:41124] AH00128: File does not exist: 
> /var/www/html/_dash-component-suites/dash/deps/[email protected]_6_2m1666328797.12.1.min.js,
>  referer: http://hd1991356yb/~mec/dash101/app.wsgi/
> 
> I am for now ignoring the deprecation warnings.
> 
> I error comes from the app looking for dash's .js files within /var/www/html 
> (apache's root).  
> 
> How can my app.wsgi alter this path?
> 
> I tried adding this to my app.wsgi:
> 
>     os.environ["DASH_URL_BASE_PATHNAME"] = "/home/mec/public_html/dash101/"

That is a file system path you are giving it, not a URL path the web server 
understands.

> which does effect where the js files are sought, only not correctly, as the 
> error is now:
> 
> [Fri Oct 21 01:48:29.019458 2022] [core:info] [pid 8597] [client 
> 10.2.20.25:43445] AH00128: File does not exist: 
> /var/www/html/home/mec/public_html/dash101/_dash-component-suites/dash/deps/[email protected]_6_2m1666328797.12.1.min.js,
>  referer: http://hd1991356yb/~mec/dash101/app.wsgi

Where is the "_dash-component-suites" actually located on the file system. That 
directory should be copied into /var/www/html and DASH_URL_BASE_PATHNAME not 
set, or, you need to set up the Apache Alias directory to map some URL prefix 
to filesystem location where it is.

> So far, apache2 is configured with:
> 
> LoadModule wsgi_module 
> /usr/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
> 
> <IfModule mod_userdir.c>
>     UserDir public_html
> </IfModule>
> 
> <Directory "/home/*/public_html">
>     AllowOverride FileInfo AuthConfig Limit Indexes
>     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
>     Require method GET POST OPTIONS
>     AddHandler cgi-script .cgi
>     AddHandler wsgi-script .wsgi
> </Directory>
> 
> I am not issuing any other wSGI configuration directives in my apache2 
> configuration.
> 
> Perhaps I should not expect apache2+userdir+mod_wsgi to work at all...???

In general it is best to avoid using mod_userdir with mod_wsgi as it confuses 
typical WSGI application URL handling.

Why are you trying to use mod_userdir. Do you not control the whole Apache 
server?

> All advice as to how to proceed very welcome.
> 
> update:  I've now read 
> https://groups.google.com/g/modwsgi/c/Lnik3YHFujA/m/3QRuwEZXP6sJ and have 
> tried the approach mentioned there:
> 
> WSGIRestrictEmbedded On
> 
> WSGIDaemonProcess mec
> <Directory /home/mec/public_html>
> WSGIProcessGroup mec user=mec
> </Directory>
> 
> I modifed it remove the (now deprecated?) `user=mec` (which causes apache 
> restart to fail)
> 
> But it did not alter the error sequence I am getting.
> 
> That advice is from 2011.  Perhaps things have changed and there is now a 
> best approach to this (possibly including a "means for dynamic creation of 
> daemon
> process groups")...???

Daemon process groups still have to be defined up from.

> I also read https://groups.google.com/g/modwsgi/c/K9hBYI07EsM/m/A_Ao9g4vFgAJ 
> but could not determine if there was relevant advice there.
> 
> Thanks !
> 
> ~Malcolm COok
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/modwsgi/21316f05-cf35-427b-91e9-441200954ce5n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/modwsgi/21316f05-cf35-427b-91e9-441200954ce5n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/FD165E76-7860-4562-B1F8-BC6DCFCED8AB%40gmail.com.

Reply via email to