I appreciate your prompt replies. I do have 3 different virtual hosts. Two 
on port 80 (running without issues. They are just simple html pages for 
testing; not flask apps) and one on port 443 (for the flask app). The .conf 
for each virtualhost are in /etc/httpd/sites-available/, so, the 
virtualhost configuration I showed above is not part of 
/etc/httpd/conf/httpd.conf. Instead, it is a standalone file.  I was sure 
that I had several wrong settings; yet, I did not know which. I now have 
all your information and will work on this again. Once I make progress I 
will reply back. 

Again, thank you for your help with this. Documentation did not make much 
sense to me because I am very new to programming and I am still a bit 'all 
over the place. I work in networking and ventured to build a small web app 
that will make a couple of different XML API calls. I will update this post 
as soon as I make progress using all your input.

On Wednesday, July 11, 2018 at 6:16:50 PM UTC-7, Graham Dumpleton wrote:
>
> You should have:
>
> WSGIDaemonProcess flask processes=2 threads=12 \
>   python-home=/var/www/mywebsite <http://mywebsite.com/flask/bin/>. 
> <http://mywebsite.com/flask/bin/>com <http://mywebsite.com/flask/bin/>
> /flask <http://mywebsite.com/flask/bin/> \
>   python-path=/var/www/mywebsite.com/flask
>
> WSGIProcessGroup flask
>
>
> The path for python-home is wrong. As I already mentioned and docs 
> explain, it needs to be what sys.prefix is for the virtual environment.
>
> You are missing the WSGIProcessGroup directive as well, which says to run 
> your WSGI application in that daemon process group.
>
> I would check python-path value. It should be the directory you need to be 
> in to import your application code.
>
> It is a bit strange that you have your application code inside of the 
> virtual environment. That is generally regarded as bad practice as it makes 
> it harder to delete the virtual environment and start over with a fresh 
> one, as you need to be able to separate out which is your application code.
>
> BTW, LoadModule isn't supposed to be inside of VirtualHost. I would have 
> thought Apache would fail to start up if have it there. It is supposed to 
> be outside of all VirtualHost definitions at top level scope.
>
> Finally, do you only have a VirtualHost for port 443? What about port 80? 
> If you have both, you need to be careful how you set up daemon process 
> groups to ensure you share one across port 80 and 443.
>
> Graham
>
> On 12 Jul 2018, at 10:50 am, jerry100 <[email protected] <javascript:>> 
> wrote:
>
> Sorry, I meant to do that. Here it is:
>
> <VirtualHost *:443>
>
>     ServerName mywebsite.com
>     LoadModule wsgi_module /var/www/mywebsite 
> <http://mywebsite.com/flask/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so>
> . 
> <http://mywebsite.com/flask/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so>
> com 
> <http://mywebsite.com/flask/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so>
> /flask/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
>  
> <http://mywebsite.com/flask/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so>
>     WSGIDaemonProcess flask processes=2 threads=12 python-home=/var/www/
> mywebsite <http://mywebsite.com/flask/bin/>. 
> <http://mywebsite.com/flask/bin/>com <http://mywebsite.com/flask/bin/>
> /flask/bin/ <http://mywebsite.com/flask/bin/> python-path=/var/www/
> mywebsite <http://mywebsite.com/flask/bin/>. 
> <http://mywebsite.com/flask/bin/>com <http://mywebsite.com/flask/bin/>
> /flask/bin/ <http://mywebsite.com/flask/bin/>
>     WSGIScriptAlias / /var/www/mywebsite 
> <http://mywebsite.com/flask/flask.wsgi>. 
> <http://mywebsite.com/flask/flask.wsgi>com 
> <http://mywebsite.com/flask/flask.wsgi>/flask/flask.wsgi 
> <http://mywebsite.com/flask/flask.wsgi>
>     <Directory /var/www/mywebsite <http://mywebsite.com/flask>. 
> <http://mywebsite.com/flask>com <http://mywebsite.com/flask>/ 
> <http://mywebsite.com/flask>flask <http://mywebsite.com/flask>>
>     Order allow,deny
>     Allow from all
>     </Directory>
>
>     ErrorLog /var/www/mywebsite 
> <http://mywebsite.com/public_html/error.log>. 
> <http://mywebsite.com/public_html/error.log>com 
> <http://mywebsite.com/public_html/error.log>/public_html/error.log 
> <http://mywebsite.com/public_html/error.log>
>     CustomLog /var/www/mywebsite 
> <http://mywebsite.com/public_html/requests.log>. 
> <http://mywebsite.com/public_html/requests.log>com 
> <http://mywebsite.com/public_html/requests.log>/public_html/requests.log 
> <http://mywebsite.com/public_html/requests.log> combined
>     sslengine on
>     sslcertificatefile /etc/ssl/certs/STAR.mywebsite.com.crt
>     sslcertificatekeyfile /etc/ssl/certs/mywebsite.com.key
> </VirtualHost>
>
>
>
> On Wednesday, July 11, 2018 at 5:26:24 PM UTC-7, Graham Dumpleton wrote:
>>
>> You haven't shown your Apache configuration for mod_wsgi.
>>
>> You need to tell mod_wsgi/Python that your virtual environment is at:
>>
>>     /var/www/mywebsite.com/flask
>>
>> Adding that directory to sys.path is not enough.
>>
>> Read:
>>
>>     
>> http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
>>
>> as it explains what you need to do.
>>
>> I can't be more specific since you didn't include the Apache 
>> configuration for mod_wsgi.
>>
>> Graham
>>
>> On 12 Jul 2018, at 9:45 am, jerry100 <[email protected]> wrote:
>>
>> Hello all! The requests module was installed in the site-packages folder 
>> in the virtual environment as I expected. I ran "pip install requests". 
>> Since I run the flask app on apache and the virtual environment is 
>> inactive, by design, as we are using mod_wsgi, the requests module is not 
>> being imported by Apache.
>>
>> /var/www/mywebsite.com/flask/lib/python3.6/site-packages/requests
>>
>> This is how I am trying to import the module:
>>
>> from flask import Flask, render_template, request
>> import requests
>>
>>
>> Here's my flask.wsgi file. Are we supposed to import modules in this file 
>> instead of init.py file?
>>
>> import sys
>>
>> sys.path.insert(0, "/var/www/mywebsite.com/flask/")
>>
>> from init import app as application
>>
>>
>> This is the error I get. What am I doing wrong?
>>
>> [Wed Jul 11 16:16:18.941771 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794] Traceback (most recent call last):
>> [Wed Jul 11 16:16:18.941850 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794]   File "/var/www/mywebsite.com/flask/flask.wsgi", line 5, in 
>> <module>
>> [Wed Jul 11 16:16:18.941864 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794]     from init import app as application
>> [Wed Jul 11 16:16:18.941876 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794]   File "/var/www/mywebsite.com/flask/init.py", line 2, in 
>> <module>
>> [Wed Jul 11 16:16:18.941881 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794]     import requests
>> [Wed Jul 11 16:16:18.941909 2018] [wsgi:error] [pid 7244] [client 192.168
>> .1.2:64794] ModuleNotFoundError: No module named 'requests'
>>
>> -- 
>> 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