Hello, my name is John from Liquid Web and today, I am going to show you how to install Python WSGI Applications on cPanel
First, let's begin by installing the packages and dependencies for python3
(for a full list of commands, see the comments in the description below)
Now let's install the packages and dependencies for Passenger
Please note that installing the ea-ruby24-mod_passenger package will disable the mod_userdir module for Apache
Now we are going to change directories to the home directory for the cPanel account that we are going to put the application
And we are going to use a virtual environment to house this example application that we are going to make.
Now let's change directories into that virtual environment we just made.
And let's go ahead and activate the virtual environment
And the first thing I am going to do is install the
Python dependencies I am going to need for this example
Python Flask web application I am going to make
Now I am going to go ahead and deactivate the virtual environment
And let's go ahead and make the Flask file first
And Let's go ahead and save this file
And let's go ahead and create the Passenger WSGI file
And since this is a virtual environment we are going to add a few lines at the top to activate the virtual environment
And what this is, this is going to tell Passenger where to find the Python interpreter because with virtual environments
you can activate the virtual environment by using the python interpreter found in the bin directory of the virtual environment.
so the path that I put for the interpreter is the path to the Python interpreter that is in the virtual environment that I created.
And this last line here is importing from python_test which is the python_test.py file that I created and it's going to import the app as application
and since I created all of this as the root user I am going to go ahead and chown
and change owner of all of these files over to the cPanel user name for this
So now all files are owner by the cPanel user.
And the last step is going to be to register this as an application in cPanel.So I am going to go ahead
And we are going to come down here to the application manager.
This is going to be in the software section.
From here we want to register an application. This is for the Phusion Passenger.
Which is whats handling WSGI for this.
And for the name I am going to give it Python Test which is the name of the actual web application.
And for domain I am going to put this under the main domain for this account, but of course, you could put this un a subdirectory or any kind of subdomain or add on domains that are on the cPanel account
And for the path, it starts at home and we are just going to put the path to the folder that contains the virtual environment.
for this, this is just python_test
And for now, I am just going to leave this set to development since this is just a test one. And we are going to deploy that.
And now we should be able to go to it. And it loads the Python application
And thanks again for watching this video. And for more helpful articles and videos be sure to check out liquidweb.com/kb