336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
sudo adduser user
sudo adduser user sudo
su user
sudo echo "localhost" > /etc/hostname
sudo hostname localhostsudo apt-get update
sudo apt-get upgrade
sudo apt-get install python
sudo apt-get install python-virtualenv
sudo apt-get install python2.7-dev
sudo apt-get install nginx
sudo service nginx start
sudo apt-get install uwsgi
sudo mkdir /var/www
sudo mkdir /var/www/example.com
cd /var/www/example.com
sudo mkdir venv conf src logs
sudo virtualenv /var/www/example.com/venv
source /var/www/example.com/venv/bin/activate (해제는 deactivate)
(venv)$ sudo pip install django
cd /var/www/example.com/src
(venv)$ django-admin.py startproject example
sudo vim /var/www/example.com/conf/uwsgi.ini (신규생성)
[uwsgi]
# variables
projectname = example_project
projectdomain = example.com
base = /var/www/example.com
# config
plugins = python
master = true
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=%(projectname).settings
pythonpath = %(base)/src/%(projectname)
module = %(projectname).wsgi
socket = 127.0.0.1:8889
logto = %(base)/logs/uwsgi.log
#below line runs it as a daemon in background
daemonize = /var/log/uwsgi/example_project.log
sudo vim /var/www/example.com/conf/nginx.conf (신규생성)
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/src/example_project;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
location /static/ { # STATIC_URL
alias /var/www/example.com/src/static/; # STATIC_ROOT
expires 30d;
}
location /media/ { # MEDIA_URL
alias /var/www/example.com/src/media/; # MEDIA_ROOT
expires 30d;
}
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8889;
}
}
sudo vim /etc/nginx/nginx.conf (기존파일 수정)
user www-data;
# ...
http {
# ...
include /var/www/*/conf/nginx.conf;
# ...
}
sudo service nginx restart
# mysql 사용시
# sudo apt-get install mysql-server
# sudo mysql_secure_installation
# sudo apt-get install python-mysqldb
sudo apt-get install uwsgi-plugin-python
sudo pip install south (optional)
sudo uwsgi --ini /var/www/example.com/conf/uwsgi.ini
sudo vim settings.py (기존파일 수정)
DEBUG = False
ALLOWED_HOSTS = '*'
sudo vim /etc/init/uwsgi.conf (신규생성)
# Emperor uWSGI script
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
exec uwsgi --master --die-on-term --emperor /var/www/example.com/conf/uwsgi.ini
sudo reboot
# 참고 사이트
# http://tutorial.djangogirls.org/ko/django_urls/index.html
# http://blog.richard.do/index.php/2013/04/setting-up-nginx-django-uwsgi-a-tutorial-that-actually-works/
# http://blog.collabspot.com/2012/08/14/setting-up-nginx-uwsgi-python-ubuntu-12-04/
# http://abipictures.tistory.com/918