How to Install a Python WSGI Application on Beta Host Server
Install the application
To install an application, perform the following steps:
-
Log in to the server via SSH as a cPanel user.
-
Create the application’s directory, relative to your home directory. To do this, run the following command, where
directoryname
represents the application’s directory:mkdir directoryname
-
Change to the application’s directory. To do this, run the following command, where
directoryname
represents the application’s directory:cd directoryname -
Copy the application to your server.
-
Create the
passenger_wsgi.py
file. In this example,pythonapp
represents your python application andMyApp
represents an application function:echo "from pythonapp import MyApp as application" > passenger_wsgi.py -
Install the application’s dependencies. To do this, run the following command:
pip install --user -r requirements.txtNote:You can also install any dependencies in the Ensure Dependencies section of cPanel’s Application Manager interface (cPanel >> Home >> Software >> Application Manager).
Test the application
After you install the application, we recommend that you confirm that it’s active.
-
Run the following command:
python pythonapp.py<!DOCTYPE html>
…
<section class="main">
<h1>Hello world!</h1>
Welcome to the example app.
</section>
</body>
</html> -
Open another terminal window and log in to the server via SSH as the same cPanel user.
-
Run the following command:
curl http://localhost:5000The output will resemble the following example:Hello, World!
Register the application
After you install the application, register it. To do this, use cPanel’s Application Manager interface (cPanel >> Home >> Software >> Application Manager).
You can then access the application in a web browser with the following url:
Restart the application
To restart your application after you edit it, create the restart.txt touch file. Create this file in the application’s /tmp
directory. This file directs Phusion Passenger® to restart the application after you modify it. This action applies your changes to the application.