Created
August 23, 2012 21:23
-
-
Save 1mh0/3442006 to your computer and use it in GitHub Desktop.
flask - nginx+uwsgi setup with git repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt-get update | |
| apt-get install build-essential python-dev libxml2-dev | |
| apt-get install nginx | |
| /etc/init.d/nginx start | |
| SETUP GIT REPOSITORY | |
| ~~~~~~~~~~~~~~~~~~~~ | |
| adduser git | |
| nano /etc/passwd | |
| git:x:1000:1000::/home/git:/usr/bin/git-shell | |
| cat /tmp/id_rsa.name.pub >> /home/git/.ssh/authorized_keys | |
| apt-get install git-core | |
| mkdir /var/www/project.git | |
| cd /var/www/project.git | |
| git init --bare | |
| cd /var/www | |
| git clone project.git project | |
| cd /var/www/project | |
| # scp files into this directory | |
| nano .gitignore | |
| venv/* | |
| *.pyc | |
| git add . | |
| git commit -m "Initial commit" | |
| VIRTUALENV AND UWSGI | |
| ~~~~~~~~~~~~~~~~~~~~~ | |
| apt-get install python-pip | |
| pip install virtualenv | |
| cd /var/www/project | |
| chown -R www-data:www-data app | |
| virtualenv venv | |
| . venv/bin/activate | |
| pip install -r requirements.txt | |
| pip install uwsgi | |
| nano uwsgi.ini | |
| [uwsgi] | |
| uid = www-data | |
| socket = :3031 | |
| virtualenv = /var/www/project/venv | |
| chdir = /var/www/project | |
| file = /var/www/project/app/__init__.py | |
| callable = app | |
| processes = 4 | |
| master = true | |
| enable-threads = true | |
| threads = 20 | |
| harakiri = 30 | |
| harakiri-verbose = true | |
| daemonize = /var/log/uwsgi.log | |
| log-5xx = true | |
| /var/www/project/venv/bin/uwsgi --ini /var/www/project/uwsgi.ini | |
| nano /etc/nginx/nginx.conf | |
| http { | |
| server { | |
| listen 80; | |
| server_name project.com; | |
| location = /robots.txt { | |
| rewrite (.*) /static/robots.txt; | |
| } | |
| location = /favicon.ico { | |
| rewrite (.*) /static/favicon.ico; | |
| } | |
| location /static/ { | |
| root /var/www/project/app; | |
| } | |
| location / { | |
| include uwsgi_params; | |
| uwsgi_pass 127.0.0.1:3031; | |
| } | |
| } | |
| } | |
| /etc/init.d/nginx reload | |
| LOCAL DEVELOPER | |
| ~~~~~~~~~~~~~~~~ | |
| cd /home/username/sites | |
| git clone git@8.8.8.8:/var/www/project.git/ | |
| cd project | |
| virtualenv venv | |
| . venv/bin/activate | |
| pip install -r requirements.txt | |
| python run.py | |
| Load http://127.0.0.1:5000/ in browser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment