Create a shell user if you have not done so already. You can use an existing shell user if you wish.
Click on Applications in the control panel sidebar.
Click the button labeled "+ Add Application" in the upper-left corner of the content area.
Select Python/uWsgi as the application type.
Enter a name for your application in the Name field.
This name will be used to create a subdirectory in your shell user's
appsdirectory such as
Select the shell user that will host the application.
If you have multiple servers, be sure to select the shell user that is located on the server from which you intend to serve your site.
Click the "Add Application" button to save your new application.
A notification will appear in the control panel when the application is ready. This may take a minute or longer.
When the installation is complete, the following files and directories will be present in the application directory:
kill: scripts to control the operation of your application.
env: a directory containing the Python 3 environment used by your application.
tmp: a directory containing temporary files used by your application
myapp: a directory containing a simple "hello world" Python WSGI application.
uwsgi.ini: the configuration file for your Python/uWSGI application.
You can control the operation of your Python/uWSGI application using the scripts provided by the installer.
- To start the application:
- To stop the application:
- To kill the application if it has hung:
Your Python/uWSGI application includes a Python 3 environment located at
/home/app_user/apps/app_name/env into which you can install your project's Python dependencies. To do so:
Activate your application's Python environment:
Install your dependences with
pip. You can install single packages...
pip install packagename
...or if you have a requirements file for your project you can install all of the dependencies at once:
pip install -r requirements.txt
Your Python/uWSGI applications are initially configured to serve a simple "hello world" application. All of the configuration is done via the
uwsgi.ini configuration file in the application directory, so you can reconfigure the application to serve your own project by editing that configuration.
For example, if you have a Flask project that you'd like to serve via uWSGI:
Create a new Python/uWSGI application as described above.
Upload your Flask project directory to your application directory. For this example, the project directory is named
Edit your application's
uwsgi.iniconfiguration file (below the "adjust the following to point to your project" comment) to point it at your Flask app. For this example, we'll comment out the existing WSGI handler and use the uWSGI
# adjust the following to point to your project #wsgi-file = /home/username/apps/appname/myapp/wsgi.py #touch-reload = /home/username/apps/appname/myapp/wsgi.py module = flaskapp:app touch-reload = /home/username/apps/appname/flaskapp/__init__.py
Use the application's
startcommands to restart the application to pick up the new configuration:
At this point, the application is now serving the
If your Python/uWSGI application's performance is poor under heavy load, you may be able to improve it by increasing the values of
threads in your application's
uwsgi.ini configuration file. Increasing those values will increase the ability of the application to handle more traffic by adding more worker processes and by increasing the number of simultaneous requests that each worker can handle.
There is no magic formula for determining the number of workers and threads your application needs. You'll need to spend some time observing your application's performance while you are adjusting the configuration until you find the settings that work best for you.
You can use any uWSGI configuration you need by setting it in your application's
uwsgi.ini file. For more information please see: