-
Notifications
You must be signed in to change notification settings - Fork 82
Running PythonBuddy with Your Own Server
Based off of https://blog.marksteve.com/deploy-a-flask-application-inside-a-digitalocean-droplet/
-
Create DigitalOcean Droplet with the following features:
14.04 Ubuntu x64
any Size. Choose the closest region -
After Droplet is created, ssh into the droplet:
ssh root@<DROPLET_PUBLIC_IP_ADDRESS>
-
Add User called
deploy
:useradd -r -m -s /bin/bash deploy
-
Install
pip
andeasy_install
apt-get install python-setuptools
easy_install -U pip
-
Install
virtualenv
pip install virtualenv
-
Install
git
apt-get install git
-
Switch to the
deploy
usersu - deploy
-
Clone
PythonBuddy
repo and change to that repogit clone https://github.com/ethanchewy/OnlinePythonLinterSyntaxChecker cd OnlinePythonLinterSyntaxChecker
-
Make sure you are in the
OnlinePythonLinterSyntaxChecker
directory and install/activatevirualenv
virtualenv venv source venv/bin/activate
-
Install requirements and
gunicorn
pip install -r requirements.txt pip install gunicorn
-
Press
Ctrl-D
which will change you to root. Installnginx
apt-add-repository ppa:nginx/stable apt-get update apt-get install nginx
-
Configure
nginx
to point to gunicornnano /etc/nginx/conf.d/flask-app.conf
-
Add this to configuration file:
server { listen 80; server_name _; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_pass http://127.0.0.1:8000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
-
Disable default Nginx Welcome Page
nano /etc/nginx/nginx.conf
-
Comment out this line:
include /etc/nginx/sites-enabled/
; Reload Nginx:service nginx reload
-
Login back as deploy and load virtualenv
su - deploy cd OnlinePythonLinterSyntaxChecker source venv/bin/activate
-
Run as daemon by default:
gunicorn -D app:app
Now Everything Should be working! Just go to your ip address!