Open tony-bony opened 4 years ago
The solution for me was to add passenger_python /home/linuxbrew/.linuxbrew/bin/python3;
to the demoapp.conf. So it should look like:
server {
listen 80;
server_name hXXXXXXX.stratoserver.net;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/demoapp/code/public;
passenger_python /home/linuxbrew/.linuxbrew/bin/python3;
# Turn on Passenger
passenger_enabled on;
passenger_user demoapp;
}
This way Passenger is using Python3 and this is where I installed Flask. Maybe you could adit your tutorial to include this information?
Also the Passenger installation for Nginx should not include Apache support.
You should use a python virtual environment and, as you note, the path tug o the python executable can be supplied. However, your comment confuses the issue somewhat. Flask is not a production level tool and you need Passenger and the wsgi application server to replace flask.
Yes, using the virtual environment was the next step but online tutorial does not specify it is required for the Flask demo app as far as I recall. I know Flask is an application framework and I am running a Flask app on Nginx/Phusion Passenger server.
Issue report
Question 1: What is the problem?: I want to install
Nginx
andPassenger
on Ubuntu 16.04 to run python apps e.g. usingFlask
and I run into issues. When I visit my server http://hXXXXXXX.stratoserver.net/ in the browser I am getting:Question 2: Passenger version and integration mode: Passenger open source 6.0.4 + Nginx
Question 3: OS or Linux distro, platform (including version): Ubuntu 16.04 LTS
Question 4: Passenger installation method: Nginx + Phusion APT repo
Question 5: Your app's programming language (including any version managers) and framework (including versions): Python 3.7.6 + Flask 1.1.1
Question 6: Are you using a PaaS and/or containerization? If so which one? NA
Question 7: Anything else about your setup that we should know? I have a VPS at strato.nl with Ubuntu 16.04 installed, and the host address is: http://hXXXXXXX.stratoserver.net/ and I was following "Deploying a Python app with Passenger to production" tutorial with the following infrastructure:
So the demo Flask app was cloned like this:
git clone https://github.com/phusion/passenger-python-flask-demo.git
Running
passenger-memory-stats
gives:When I run the app locally on the server everything works as expected:
Then in another terminal:
So it looks like locally all works fine. However when I visit http://hXXXXXXX.stratoserver.net/ in the browser I got an error page like described above.
The nginx error /var/log/nginx/error.log:
It seems the server uses Python2 by default. I need it to use Python3 where I installed Flask. How can I setup the Python version and Python libraries in Nginx/Passenger?
My demoapp.conf is:
What are the passenger / Nginx settings that I need to set to successfully run a Flask application? How can I set Passenger/Nginx to use Python3 and Python3 libraries?