Instantly share code, notes, and snippets.

Embed
What would you like to do?
1. Creature new Sudo acc
-adduser ryan
-usermod -aG sudo ryan
-su - ryan
2.update repository
-sudo apt-get update
3. Install pip and nginx
-sudo apt-get install python-pip nginx
4. Configure Nginx
1. Start Nginx
-sudo apt-get install python-pip nginx
2.Remove existing default configuration
-sudo rm /etc/nginx/sites-enabled/default
3. Create new file in sites-available
-sudo touch /etc/nginx/sites-available/flask_settings
4. Create symbolic link between flask_settings, and equivalennt in sites-enabled
-sudo ln -s /etc/nginx/sites-available/flask_settings /etc/nginx/sites-enabled/flask_settings
` 5. Edit
-sudo nano /etc/nginx/sites-enabled/flask_settings
**
server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
**save and quit**
5. Restart nginx
-sudo /etc/init.d/nginx restart
6.Set up python
7. Install virtual env
-pip install virtualenv
8. Make flask app dir
-mkdir my_flask_app
-cd my_flask_app
9. Create virtual env in new dir my_flask_app
-virtualenv env
-source env/bin/activate
10. Install flask and gunicorn(and other dependencies for flaskapp)
-pip install flask gunicorn
11. Create flask app
-sudo nano hello.py
**
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'This is the homepage'
**save and exit**
12. Run server
-gunicorn hello:app.server -b localhost:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment