Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active November 18, 2022 15:30
Show Gist options
  • Save peteristhegreat/1191833d40185cd6652eae89d669b54d to your computer and use it in GitHub Desktop.
Save peteristhegreat/1191833d40185cd6652eae89d669b54d to your computer and use it in GitHub Desktop.
Bluehost, cPanel, CentOS 7, python3 mod_wsgi, WHM, Application Manager

After a lot of trial and error I have found the way to get cpanel to let me run my python flask project:

First of all get a VPS or Dedicated server in your hosting environment, and log in with ssh and enable a root user.

Now install all the good things:

sudo yum install python3 python3-devel 
sudo yum -y install gcc gcc-c++
sudo yum -y install zlib zlib-devel
yum install libffi-devel

sudo yum install ea-ruby24-mod_passenger ea-apache24-mod_env
sudo yum install ea-apache24-devel

yum install ea4-experimental
yum --disablerepo="*" --enablerepo="EA4-experimental" install ea-apache24-mod_wsgi.x86_64
python -m venv ./venv
source venv/bin/activate
pip install -r requirements.txt

https://documentation.cpanel.net/display/EA4/The+Experimental+Repository

https://willhaley.com/blog/flask-on-bluehost/

https://documentation.cpanel.net/display/CKB/How+to+Install+a+Python+WSGI+Application

@peteristhegreat
Copy link
Author

@allychau My end environment I used was without apache (aka httpd) and without passenger.

I installed nginx, I turned off apache. I had nginx point to gunicorn running my production flask application and got that going. It was quite a pain to get it working. And getting SSL working, I went with Let's Encrypt, but I didn't get it automatically refreshing everything, so once every 2 or 3 months, I had to log in and reboot everything after running certbot.

I'll keep an eye on this thread more today. If you want to chat thru another platform, let me know.

I'll see if I can throw together another gist that is more accurate of what I ended up having in the end...

Sooner or later I want to make

flask + guncorn (or some other wsgi) + lets encrypt certbot + nginx + cron + docker

much simpler so I don't have to re-learn it each time I am publishing a finished product.

GCE and Heroku are supposed to be easier, but I haven't dumped the time into learning their setups perfectly.

The Flask Mega Tutorial is a gold mine of information.

Bluehost and most legacy hosting platforms are geared for Apache + MySQL + Php. Anything else is a huge exception and they don't really help you get it going. And a lot of automatic certificate issuing from these hosting providers relies on Apache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment