This project serves as a biolerplate using django framework and nginx as the web server, with uwsgi to communicate. It's mainly for Mac OS X users, and not tested on Linux system. If you want it works on Linux system, you need to change some paths for the configuration files.
- python 2.7 & pip:
brew install python - nginx:
brew install nginx - virtualenv:
pip install virtualenv
- create a virtual environment:
virtualenv venv - activate the virtaul environment:
source venv/bin/activate - install all the dependent packages:
pip install -r requirements.txt
cd into the mysite folder where holds the manage.py, run ./deploy.sh. It will first create the nginx and uwsgi configuration files, then make a soft link in /usr/local/etc/nginx/servers to the configuration file.
Run ./start.sh. It will start nginx and uwsgi. Visit http://localhost:8888/ to see the welcome page. All the uwsgi logs are in uwsgi.log.
Run ./stop.sh. It will stop uwsgi and nginx.
- mysite server uses 8888 port, you can change it in
deploy.sh. - uwsgi communicates with nginx through unix file
/tmp/mysite.sockto achieve better efficiency. - The uwsgi pid is logged at
/tmp/mysite.pid, and if something goes wrong, you can easily kill the uwsgi process with it. - The static file folders are
static1andstatic2, as configurated inmysite/settings.py. You can change the configuration and add more static files. Make sure runpython manage.py collectstaticafter that, django will collect all the static files instaticfolder and nginx will find static files in it. - The uploaded files are located at
mediafolder, and nginx will find files in it. - Make sure that nginx has the right permission to visit the
mediaandstaticfolder, modify/usr/local/etc/nginx/nginx.confand change theuseroption properly, e.guser sean staff.