How to host flask project on Vesta CP ?

Here are the steps to host a Flask project on Vesta CP:

  1. First, make sure you have installed Flask and have a working Flask application. You can follow Flask’s official documentation to create a simple Flask app.
  2. Next, log in to your Vesta CP control panel.
  3. Click on the “Web” tab and then click “Add Web Domain”.
  4. Enter your domain name, select your web template, and click “Add”.
  5. Now, go to your server’s terminal and navigate to the “public_html” folder of your domain. For example: cd /home/<user>/web/<your-domain>/public_html
  6. Create a new virtual environment for your Flask app using the following command:
   virtualenv venv
   source venv/bin/activate
  1. Install Flask and other required packages in the virtual environment:
   pip install flask
   pip install gunicorn
  1. Create a new file named “wsgi.py” in your domain’s public_html folder and paste the following code:
   import sys
   sys.path.insert(0, '/home/<user>/web/<your-domain>/public_html')

   from app import app as application

Replace <user> and <your-domain> with your actual Vesta CP username and domain name.

  1. Create a new file named “app.py” in your domain’s public_html folder and paste your Flask app code in it.
  2. Test your Flask app by running it using Gunicorn: gunicorn wsgi:application This should start your Flask app on port 8000.
  3. To access your Flask app from the internet, you need to configure your domain’s DNS settings to point to your server’s IP address. Once the DNS settings are propagated, you should be able to access your Flask app by visiting your domain in a web browser.

That’s it! You have successfully hosted your Flask app on Vesta CP.

Leave a Comment

Your email address will not be published. Required fields are marked *