> On 3 Dec 2021, at 1:42 pm, matkatmusic <[email protected]> wrote:
>
> Here is the part that gets included automatically from the VirtualHost
> directive for my site http://flask.chordieapp.com
> Cpanel is automatically creating the VirtualHost directive, and the
> instructions say to create a file in /etc/apache2/conf.d/userdata/ and then
> either /std/ or /ssl/ for the site that was added.
> This is the http file:
> /etc/apache2/conf.d/userdata/std/2_4/bfxqsxmy/flask.chordieapp.com/flask.chordieapp.com.conf
>
> <IfModule alias_module>
There shouldn't be an IfModule section for alias_module because that is nothing
to do with mod_wsgi. You only want what was inside that section.
> WSGIDaemonProcess flaskapp
> python-home=/home/bfxqsxmy/public_html/flask/venv/
> WSGIProcessGroup flaskapp
> WSGIScriptAlias /app /home/bfxqsxmy/public_html/flask/application.wsgi
Better to also change this to:
WSGIDaemonProcess flaskapp
python-home=/home/bfxqsxmy/public_html/flask/venv/
WSGIScriptAlias /app /home/bfxqsxmy/public_html/flask/application.wsgi
process-group=flaskapp application-group=%{GLOBAL}
You are also not telling mod_wsgi where you application code is. You probably
mean:
WSGIDaemonProcess flaskapp
python-home=/home/bfxqsxmy/public_html/flask/venv/
python-path=/home/bfxqsxmy/public_html/flask
WSGIScriptAlias /app /home/bfxqsxmy/public_html/flask/application.wsgi
process-group=flaskapp application-group=%{GLOBAL}
> </IfModule>
>
> <Directory "/home/bfxqsxmy/public_html/flask/">
> Options FollowSymLinks
> AllowOverride None
> Require all granted
> </Directory>
>
> # ErrorLog ${APACHE_LOG_DIR}/error.log
> LogLevel warn
> # CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> Here is the https conf:
> <IfModule alias_module>
> # this daemon process was declared in the /std/ copy of this file (handler
> for http, not https)
> # WSGIDaemonProcess flaskapp
> python-home=/home/bfxqsxmy/public_html/flask/venv/
> WSGIProcessGroup flaskapp
> WSGIScriptAlias /app /home/bfxqsxmy/public_html/flask/application.wsgi
> </IfModule>
>
> <Directory "/home/bfxqsxmy/public_html/flask/">
> Options FollowSymLinks
> AllowOverride None
> Require all granted
> </Directory>
>
> # ErrorLog ${APACHE_LOG_DIR}/error.log
> LogLevel warn
> # CustomLog ${APACHE_LOG_DIR}/access.log combined
Only need for mod_wsgi.
WSGIScriptAlias /app /home/bfxqsxmy/public_html/flask/application.wsgi
process-group=flaskapp application-group=%{GLOBAL}
No WSGIDaemonProcess directive.
You still need the Directory stuff in both.
> Here is the folder hierarchy over /public_html/flask
> <Screen Shot 2021-12-02 at 6.36.04 PM.png>
> Here is the folder hierarchy of /public_html/flask/pfm/
> <Screen Shot 2021-12-02 at 6.33.44 PM.png>
>
> Here is what is written in `application.wsgi`:
> 1 python_home = '/home/bfxqsxmy/public_html/flask/venv'
> 2 import sys
> 3 import site
> 4
> 5 # Calculate path to site-packages directory.
> 6
> 7 python_version = '.'.join(map(str, sys.version_info[:2]))
> 8 site_packages = python_home + '/lib/python%s/site-packages' % python_version
> 9
> 10 # Add the site-packages directory.
> 11
> 12 site.addsitedir(site_packages)
> 13 from pfm import test1 as test1
> 14 from test1 import app as application
This should all be replaced with just:
from pfm import test1 as test1
from test1 import app as application
The directory that "pfm" package is in should be what you add to python-path
above.
>
> Here's the error message:
> _wsgi (pid=13119, process='flaskapp',
> application='flask.chordieapp.com|/app'): Loading Python script file
> '/home/bfxqsxmy/public_html/flask/application.wsgi'.
> [Thu Dec 02 19:37:30.512141 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349] mod_wsgi (pid=13119): Failed to exec Python
> script file '/home/bfxqsxmy/public_html/flask/application.wsgi'.
> [Thu Dec 02 19:37:30.512220 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349] mod_wsgi (pid=13119): Exception occurred
> processing WSGI script '/home/bfxqsxmy/public_html/flask/application.wsgi'.
> [Thu Dec 02 19:37:30.512623 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349] Traceback (most recent call last):
> [Thu Dec 02 19:37:30.512660 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349]File
> "/home/bfxqsxmy/public_html/flask/application.wsgi", line 13, in <module>
> [Thu Dec 02 19:37:30.512664 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349] from pfm import test1 as test1
> [Thu Dec 02 19:37:30.512690 2021] [wsgi:error] [pid 13119:tid 47096016185088]
> [remote 73.221.155.223:57349] ModuleNotFoundError: No module named 'pfm'
>
>
> When I comment everything out in application.wsgi and use your 'hello world'
> script instead, I see 'hello world' when I visit the URL to the app:
> def application(environ, start_response):
> status = '200 OK'
> output = b'Hello World!'
>
> response_headers = [('Content-type', 'text/plain'),
> ('Content-Length', str(len(output)))]
> start_response(status, response_headers)
>
> return [output]
>
> <Screen Shot 2021-12-02 at 6.22.48 PM.png>
>
> As I said earlier, it's a python error related to the folder hierarchy and
> not being able to find the files.
> Any ideas?
>
> On Thursday, December 2, 2021 at 6:23:41 PM UTC-8 Graham Dumpleton wrote:
> You would need to post the error messages and the mod_wsgi configuration if
> you want help resolving it. Too hard to guess otherwise.
>
>
>> On 3 Dec 2021, at 1:21 pm, matkatmusic <[email protected]
>> <applewebdata://3B0C0173-900B-4A9B-B2D1-DD8BC3720630>> wrote:
>>
>
>> I'm not using it.
>> I followed your guide and what it says about python3.
>>
>> On Thursday, December 2, 2021 at 6:20:35 PM UTC-8 Graham Dumpleton wrote:
>> You should not use activate_this.py for virtual environment activation
>> unless you have no other choice. Use WSGIPythonHome or preferably use
>> WSGIDaemonProcess and python-home as explain in that doc.
>>
>>
>>> On 3 Dec 2021, at 1:18 pm, matkatmusic <[email protected] <>> wrote:
>>>
>>
>>> Success!!!
>>>
>>> [wsgi:info] [pid 19919:tid 47035722368064] mod_wsgi (pid=19919):
>>> Initializing Python.
>>> [Thu Dec 02 15:38:08.576095 2021] [wsgi:info] [pid 19916:tid
>>> 47035722368064] mod_wsgi (pid=19916): Attach interpreter ''.
>>> [Thu Dec 02 15:38:08.586154 2021] [wsgi:info] [pid 19913:tid
>>> 47035722368064] mod_wsgi (pid=19913): Attach interpreter ''.
>>> [Thu Dec 02 15:38:08.591026 2021] [wsgi:info] [pid 19914:tid
>>> 47035722368064] mod_wsgi (pid=19914): Attach interpreter ''.
>>> [Thu Dec 02 15:38:08.594354 2021] [wsgi:info] [pid 19915:tid
>>> 47035722368064] mod_wsgi (pid=19915): Attach interpreter ''.
>>> [Thu Dec 02 15:38:08.598385 2021] [wsgi:info] [pid 19919:tid
>>> 47035722368064] mod_wsgi (pid=19919): Attach interpreter ''.
>>> [ N 2021-12-02 15:38:08.9955 19868/T1 age/Cor/TelemetryCollector.h:531 ]:
>>> Message from Phusion: End time can not be before or equal to begin time
>>> [ N 2021-12-02 15:38:09.0274 19868/T1 age/Cor/CoreMain.cpp:1325 ]:
>>> Passenger core shutdown finished
>>>
>>> Now I am getting python-specific errors when I try to load up my site.
>>> These errors are related to the virtual environment and the missing
>>> `activate_this.py` file.
>>>
>>> After reading:
>>> https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
>>>
>>> <https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html>
>>>
>>> It seems like mod_wsgi is meant for, or designed around python v2.x, not
>>> v3.x
>>>
>>> I was able to get the hello, world snippet you shared here up and running
>>> and printing out.
>>> https://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html#apache-error-log-files
>>>
>>> <https://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html#apache-error-log-files>
>>>
>>> Now I just need to solve these import errors, which seem to be related to
>>> my folder hierarchy and file structure.
>>>
>>>
>>>
>>> On Thursday, December 2, 2021 at 1:47:38 PM UTC-8 Graham Dumpleton wrote:
>>> A few quick comments as got other things need to do before read through
>>> this properly.
>>>
>>> 1. Compiling your own Python can be tricky. Read:
>>>
>>> *
>>> http://blog.dscpl.com.au/2015/06/installing-custom-python-version-into.html
>>> <http://blog.dscpl.com.au/2015/06/installing-custom-python-version-into.html>
>>>
>>> Ignore that it talks about docker as still relevant.
>>>
>>> 2. If you are using Python from a non standard location, if using CMMI
>>> install method you have to embed in mod_wsgi knowledge of where it is.
>>> That is, set LD_RUN_PATH when compiling/installing module. Read:
>>>
>>> *
>>> https://modwsgi.readthedocs.io/en/master/user-guides/installation-issues.html#unable-to-find-python-shared-library
>>>
>>> <https://modwsgi.readthedocs.io/en/master/user-guides/installation-issues.html#unable-to-find-python-shared-library>
>>>
>>> 3. Instead of using CMMI install method, it can be better to use pip
>>> install method. Read:
>>>
>>> * https://pypi.org/project/mod-wsgi/ <https://pypi.org/project/mod-wsgi/>
>>>
>>> Graham
>>>
>>>
>>>> On 3 Dec 2021, at 8:39 am, matkatmusic <[email protected] <>> wrote:
>>>>
>>>
>>>> I am getting the following error when I try to use mod_wsgi with Apache2.4:
>>>>
>>>> The “/usr/sbin/httpd -DSSL -t -f
>>>> /etc/apache2/conf.d/includes/pre_main_global.conf.tmp.cfgcheck -C Include
>>>> "/etc/apache2/conf.modules.d/*.conf"” command (process 10241) reported
>>>> error number 1 when it ended. httpd: Syntax error on line 2 of
>>>> /etc/apache2/conf.d/includes/pre_main_global.conf.tmp.cfgcheck: Cannot
>>>> load modules/mod_wsgi.so into server: libpython3.9.so.1.0: cannot open
>>>> shared object file: No such file or directory
>>>>
>>>> I have installed python3.9.9 from source code as the Cpanel user into:
>>>> $HOME/python/Python-3.9.9/
>>>> the configuration was:
>>>> --enable-shared --prefix=$HOME/python
>>>> This install location is taken from this tutorial from my host:
>>>> https://www.bluehost.com/help/article/python-installation
>>>> <https://www.bluehost.com/help/article/python-installation>
>>>>
>>>> mkdir ~/python
>>>> cd ~/python
>>>> wget http://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
>>>> <http://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz>
>>>> tar zxfv Python-3.9.9.tgz
>>>> find ~/python -type d | xargs chmod 0755
>>>> cd Python-3.9.9
>>>> ./configure --enable-shared --prefix=$HOME/python
>>>> make
>>>> make install
>>>>
>>>> I have modified the CPanel user's .bashrc file to point to this location
>>>> so that calling $ python -V will execute the python installed from source.
>>>>
>>>> This command failed (cannot find libpython3.9.so.1.0), so I followed the
>>>> instructions here to add LD_LIBRARY_PATH to the .bashrc:
>>>> https://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s
>>>>
>>>> <https://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s>
>>>>
>>>> export PATH=/home/bfxqsxmy/python/Python-3.9.9/:$PATH
>>>> export PATH=/home/bfxqsxmy/python/bin/:$PATH
>>>> export LD_LIBRARY_PATH=/home/bfxqsxmy/python/Python-3.9.9/:$LD_LIBRARY_PATH
>>>>
>>>> Now running 'python -V' from the CPanel User's shell prints out
>>>> 'python3.9.9'
>>>>
>>>> I then installed mod_wsgi from source as the Cpanel user.
>>>> the configuration used was:
>>>> ./configure --with-apxs=/bin/apxs
>>>> --with-python=/home/bfxqsxmy/python/Python-3.9.9/python
>>>>
>>>> 'make' succeeded without issue.
>>>> running 'make install' failed because I was the Cpanel user, and it was
>>>> trying to write to /etc/apache2/modules/
>>>>
>>>> running 'sudo make install' succeeded.
>>>> /etc/apache2/modules/mod_wsgi.so now exists.
>>>>
>>>> Next: I try to edit the Apache Pre-main include file via WHM and add the
>>>> following line:
>>>> LoadModule wsgi_module modules/mod_wsgi.so
>>>>
>>>> Updating the pre-main include file causes this error to appear:
>>>> Error:
>>>> The “/usr/sbin/httpd -DSSL -t -f
>>>> /etc/apache2/conf.d/includes/pre_main_global.conf.tmp.cfgcheck -C Include
>>>> "/etc/apache2/conf.modules.d/*.conf"” command (process 10241) reported
>>>> error number 1 when it ended. httpd: Syntax error on line 2 of
>>>> /etc/apache2/conf.d/includes/pre_main_global.conf.tmp.cfgcheck: Cannot
>>>> load modules/mod_wsgi.so into server: libpython3.9.so.1.0: cannot open
>>>> shared object file: No such file or directory
>>>>
>>>> Apache is running as the following users:
>>>> root (1 instance of /usr/sbin/httpd -k start)
>>>> nobody (6 instances of /usr/sbin/httpd -k start)
>>>>
>>>> Any idea what the problem is?
>>>>
>>>> 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 view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/modwsgi/a8bf68cd-491a-4ae4-be45-16f013eb6aa1n%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/modwsgi/a8bf68cd-491a-4ae4-be45-16f013eb6aa1n%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/350a3ab2-ef75-4a4e-9c2a-74f158ad0f3an%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/modwsgi/350a3ab2-ef75-4a4e-9c2a-74f158ad0f3an%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]
>> <applewebdata://3B0C0173-900B-4A9B-B2D1-DD8BC3720630>.
>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/modwsgi/fad705f6-8c26-48ad-89a4-b39967897a35n%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/modwsgi/fad705f6-8c26-48ad-89a4-b39967897a35n%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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/dc970e73-cada-423e-97c3-1f463120c12fn%40googlegroups.com
>
> <https://groups.google.com/d/msgid/modwsgi/dc970e73-cada-423e-97c3-1f463120c12fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
> <Screen Shot 2021-12-02 at 6.22.48 PM.png><Screen Shot 2021-12-02 at 6.33.44
> PM.png><Screen Shot 2021-12-02 at 6.36.04 PM.png>
--
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/E7554E50-5CD3-4A87-B061-DD03A9B089AA%40gmail.com.