How to Host a Python app on Cloudways (Step-By-Step Guide)

Table Of Content
- Log in on Cloudways
- Provision an Application (using PHP boilerplate)
- Deploying the Application via Git
- Set Up Your Python Application
- Access the Server via SSH
- Installing Dependencies
- Testing the Application Before PM2 Setup
- Configuring the Web Server
- Installing and Configuring PM2 for Process Management
- Overview of the server folder structure
- Automating Deployment (Optional)
- Conclusion
How to Host a Python app on Cloudways (Step-By-Step Guide)
In this article, we will guide you through the process of how to host a Python app on Cloudways (Step-By-Step Guide). Cloudways is a managed hosting platform that simplifies the deployment and management of web applications, including Python apps.
Last updated: May 29, 2025
Log in on Cloudways
The first and foremost step is to sign in with your credentials on the Cloudways Platform. If you’re not a Cloudways user, sign up to get your 3-day FREE trial, without even entering your credit card details.
Provision an Application (using PHP boilerplate)

- To set up your Python application, start by installing a PHP Application on the Cloudways Platform with a single -click setup.
- Add your application’s name and other details and then click Launch Now.
- Once the application is installed, you can access it using SSH/SFTP to upload your application data. Access the Python environment via the SSH terminal provided on the Cloudways platform. For SFTP, you can use any SFTP client, such as FileZilla, PuTTY, etc. You can also use Git to manage your Python application. This method lets you pull changes directly from your GitHub repository, simplifying the process. The steps of deploying via GitHub and server setup will be discussed next.
Deploying the Application via Git
Cloudways offers a built-in Git deployment feature, eliminating the need for manual cloning via SSH.

Follow these steps to deploy your Python application:
- Log in to your Cloudways account.
- Navigate to Applications > Deployment via Git.
- Generate an SSH Key and add it to your Git repository (e.g., GitHub, GitLab).
- Enter your repository SSH URL and authenticate.
- Choose the deployment branch and start the deployment process.
Set Up Your Python Application
Navigate to the appropriate directory to set up your application:
- Application Directory:
Applications are typically located at /applications/your_app_name/public_html/
.
Your application code is typically located at public_html
. You can access it if the code is already on the server, uploaded via GitHub, or you can upload it to the server via git clone
.
Access the Server via SSH
Once your server is up, access it using SSH:
-
Obtain SSH Credentials: Find these in the Cloudways platform under Server Management > Master Credentials.
-
Connect via Terminal:
ssh master_username@server_ip_address
Check if Python is Installed
python3 --version
If Python is not installed, you will need to install it manually.
Since the Cloudways master user does not have sudo
privileges, you need to manually set up Python and a virtual environment. Follow these steps:
Create a Python Directory and Install Python 3.9.8:
cd ~ && mkdir python
cd python && wget https://www.python.org/ftp/python/3.9.8/Python-3.9.8.tgz
tar xzf Python-3.9.8.tgz && cd Python-3.9.8/
./configure --with-zlib --enable-optimizations && make
Create a Virtual Environment and Activate It
pip install virtualenv
.local/bin/virtualenv --python=python/Python-3.9.8/python venv
. venv/bin/activate

Installing Dependencies
Once the virtual environment is activated, install the necessary dependencies from your requirements.txt
file:
pip install -r requirements.txt
- Request Assistance: If you lack
sudo
privileges, contact Cloudways support to install system-wide packages.
Testing the Application Before PM2 Setup
Before setting up PM2, test if your Python application is running correctly:
For FastAPI (Uvicorn)
. venv/bin/activate
uvicorn main:app --host 0.0.0.0 --port 8000
💡 If your main FastAPI file is named app.py, use:
uvicorn app:app --host 0.0.0.0 --port 8000
For Flask
. venv/bin/activate
python main.py
💡 If your main Flask file is named app.py, use:
python app.py
Accessing the Application
Visit http://your-server-ip:8000
(for FastAPI) or http://your-server-ip:5000
(for Flask) to check if it's running correctly.

Configuring the Web Server
To route requests correctly, modify the .htaccess
file inside the public_html
folder:
If .htaccess
doesn’t exist:
-
Linux/macOS/WSL:
touch .htaccess vim .htaccess
-
Windows (Git Bash/PowerShell):
Use:
notepad .htaccess
or if using VS Code:
code .htaccess
Paste the following rewrite rules:
DirectoryIndex disabled
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://0.0.0.0:8000/$1 [P,L]
Save and close the file.

Installing and Configuring PM2 for Process Management
PM2 is useful for keeping your Python application running in the background. However, since the master user does not have sudo
privileges, installing PM2 might require assistance from the Cloudways support team. If you face issues installing PM2, contact Cloudways support and ask them to install it for you.
If You Can Install PM2 Manually
npm install pm2@latest -g
Running a Python Application with PM2
Once installed, start your Python app with PM2:
For FastAPI:
pm2 start "uvicorn main:app --host 0.0.0.0 --port 8000" --name my-python-app
For Flask:
pm2 start "python main.py" --name my-python-app
💡 If your main file is named app.py instead of main.py, replace main with app in the PM2 command
Ensure PM2 Runs After Reboot
pm2 save
pm2 startup

Check Running Processes and Logs
pm2 list
pm2 logs my-python-app

Make sure your application status is online.
🎉 Congratulations! You have successfully hosted your Python application on Cloudways using Git deployment, virtual environments, and PM2 for process management.
Overview of the server folder structure

Automating Deployment (Optional)
For smoother deployments, consider setting up Git webhooks or using tools like DeployBot to trigger automatic updates.
Conclusion
By following these steps, you can successfully host a Python application on Cloudways with Git deployment, virtual environments, and PM2 process management. If you encounter issues installing PM2 due to permission restrictions, Cloudways support can assist in the installation. Cloudways' managed hosting makes it easier to deploy and scale your applications without dealing with server configurations. Happy coding!