Here are the steps to host a Flask project on Vesta CP:
- 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.
- Next, log in to your Vesta CP control panel.
- Click on the “Web” tab and then click “Add Web Domain”.
- Enter your domain name, select your web template, and click “Add”.
- Now, go to your server’s terminal and navigate to the “public_html” folder of your domain. For example:
- Create a new virtual environment for your Flask app using the following command:
virtualenv venv source venv/bin/activate
- Install Flask and other required packages in the virtual environment:
pip install flask pip install gunicorn
- 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
<your-domain> with your actual Vesta CP username and domain name.
- Create a new file named “app.py” in your domain’s public_html folder and paste your Flask app code in it.
- Test your Flask app by running it using Gunicorn:
gunicorn wsgi:applicationThis should start your Flask app on port 8000.
- 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.