virtualenv the5fire
cd the5fire
source bin/activate
git clone https://github.com/the5fire/django_selfblog.git
cd django_selfblog
(the5fire)as3:~/the5fire# cd django_selfblog
(the5fire)as3:~/the5fire/django_selfblog# ls
conf fabfile readme.rst requirements.txt selfblog
(the5fire)as3:~/the5fire/django_selfblog# pip install -r requirements.txt
(the5fire)as3:~/the5fire/django_selfblog# ls
conf fabfile readme.rst requirements.txt selfblog
(the5fire)as3:~/the5fire/django_selfblog# cd selfblog
(the5fire)as3:~/the5fire/django_selfblog/selfblog# ls
blog feeds.pyc manage.py sitemap.py static
feeds.py __init__.py selfblog sitemap.pyc utils
(the5fire)as3:~/the5fire/django_selfblog/selfblog# cd selfblog
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# ls
__init__.py settings.py urls.py wsgi.py
__init__.pyc settings.pyc urls.pyc wsgi.pyc
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# nano settings.py
(编辑DATABASES = 部分如下:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'yourdbname', # Or path to database file if using sqlite3.
'USER': 'yourusername', # Not used with sqlite3.
'PASSWORD': 'yourpassword', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
注意:NAME,USER,PASSWORD的值都要加上单引号。
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# cd ..
(the5fire)as3:~/the5fire/django_selfblog/selfblog# ls
blog feeds.pyc manage.py sitemap.py static
feeds.py __init__.py selfblog sitemap.pyc utils
(the5fire)as3:~/the5fire/django_selfblog/selfblog# python manage.py syncdb (此命令是创建数据库表)
(the5fire)as3:~/the5fire/django_selfblog/selfblog# nohup python manage.py runserver 0.0.0.0:56375 > /dev/null &
访问http://as3.brite.biz:56375/,即可看到网站效果。
登录后台后,发现它的编辑器是基于rst格式的,所以如果你想插入html code,请参见
http://briteming.blogspot.co.uk/2013/11/linux-vpspythonhandcrank.html
另外,需修改settings.py中的if DEBUG那行下面的DOMAIN = 的值,由http://localhost改为http://as3.brite.biz:56375,否则网站里的文章链接是这样的:http://localhost/wether-sunshine-or-rain.html而非http://as3.brite.biz:56375/wether-sunshine-or-rain.html
演示站点:
http://as3.brite.biz:56375/ (这个使用的数据库是sqlite3)
http://as3.brite.biz:56376/ (这个使用的数据库是mysql)
项目地址:https://github.com/the5fire/django_selfblog
我发现 virtualenv真是好东西。之前没有装virtualenv,而直接装此django_selfblog程序失败,估计是由于跟我系统里的相关程序的版本有冲突的缘故。
虚拟环境里让Gunicorn跑Django project
pip install gunicorn
(the5fire)as3:~/the5fire/django_selfblog/selfblog# nohup ~/the5fire/bin/gunicorn_django --workers=2 -b 127.0.0.1:36483 > /dev/null &
(注意:必须先进入django项目文件夹,即含有manage.py文件的那个文件夹里,然后启动gunicorn.开启2个进程跑Django项目,使用nohup守护进程。)
让Nginx代理Gunicorn服务:
server {
listen 81;
server_name t5f.brite.biz;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:36483;
}
}
重启Nginx即可。演示站点:http://t5f.brite.biz:81/,原地址为http://as3.brite.biz:56375/ (这个56375是django工程的development server的端口号。(nohup python manage.py runserver 0.0.0.0:56375 > /dev/null &)
另外,需修改django项目的settings.py中的if DEBUG那行下面的DOMAIN = 的值,由
http://as3.brite.biz:56375改为http://t5f.brite.biz:81,然后重启django,使修改生效:
netstat -anp|grep :36483
(找到占用36483端口的进程号,杀死该进程)
nohup ~/the5fire/bin/gunicorn_django --workers=2 -b 127.0.0.1:36483 > /dev/null &
再以youflog为例。在虚拟环境里让Gunicorn跑Django project
cd ~/youflog-0.3/
as3:~/youflog-0.3# source bin/activate
(youflog-0.3)as3:~/youflog-0.3# ls
bin include lib youflog youflog-0.3.tar.gz
(youflog-0.3)as3:~/youflog-0.3# pip install gunicorn
(youflog-0.3)as3:~/youflog-0.3# cd youflog
(youflog-0.3)as3:~/youflog-0.3/youflog# nohup ~/youflog-0.3/bin/gunicorn_django --workers=2 -b 127.0.0.1:36484 > /dev/null &
(注意:必须先进入django项目文件夹,即含有manage.py文件的那个文件夹里,然后启动gunicorn.开启2个进程跑Django项目,使用nohup守护进程。)
让Nginx代理Gunicorn服务:
server {
listen 81;
server_name yl-cname.brite.biz;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:36484;
}
}
重启Nginx即可。演示站点:http://yl-cname.brite.biz:81/
此地址http://yl-cname.brite.biz:81/比http://yl.brite.biz:81/打开速度快多了。
cd the5fire
source bin/activate
git clone https://github.com/the5fire/django_selfblog.git
cd django_selfblog
(the5fire)as3:~/the5fire# cd django_selfblog
(the5fire)as3:~/the5fire/django_selfblog# ls
conf fabfile readme.rst requirements.txt selfblog
(the5fire)as3:~/the5fire/django_selfblog# pip install -r requirements.txt
(the5fire)as3:~/the5fire/django_selfblog# ls
conf fabfile readme.rst requirements.txt selfblog
(the5fire)as3:~/the5fire/django_selfblog# cd selfblog
(the5fire)as3:~/the5fire/django_selfblog/selfblog# ls
blog feeds.pyc manage.py sitemap.py static
feeds.py __init__.py selfblog sitemap.pyc utils
(the5fire)as3:~/the5fire/django_selfblog/selfblog# cd selfblog
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# ls
__init__.py settings.py urls.py wsgi.py
__init__.pyc settings.pyc urls.pyc wsgi.pyc
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# nano settings.py
(编辑DATABASES = 部分如下:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'yourdbname', # Or path to database file if using sqlite3.
'USER': 'yourusername', # Not used with sqlite3.
'PASSWORD': 'yourpassword', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
注意:NAME,USER,PASSWORD的值都要加上单引号。
(the5fire)as3:~/the5fire/django_selfblog/selfblog/selfblog# cd ..
(the5fire)as3:~/the5fire/django_selfblog/selfblog# ls
blog feeds.pyc manage.py sitemap.py static
feeds.py __init__.py selfblog sitemap.pyc utils
(the5fire)as3:~/the5fire/django_selfblog/selfblog# python manage.py syncdb (此命令是创建数据库表)
(the5fire)as3:~/the5fire/django_selfblog/selfblog# nohup python manage.py runserver 0.0.0.0:56375 > /dev/null &
访问http://as3.brite.biz:56375/,即可看到网站效果。
登录后台后,发现它的编辑器是基于rst格式的,所以如果你想插入html code,请参见
http://briteming.blogspot.co.uk/2013/11/linux-vpspythonhandcrank.html
另外,需修改settings.py中的if DEBUG那行下面的DOMAIN = 的值,由http://localhost改为http://as3.brite.biz:56375,否则网站里的文章链接是这样的:http://localhost/wether-sunshine-or-rain.html而非http://as3.brite.biz:56375/wether-sunshine-or-rain.html
演示站点:
http://as3.brite.biz:56375/ (这个使用的数据库是sqlite3)
http://as3.brite.biz:56376/ (这个使用的数据库是mysql)
项目地址:https://github.com/the5fire/django_selfblog
我发现 virtualenv真是好东西。之前没有装virtualenv,而直接装此django_selfblog程序失败,估计是由于跟我系统里的相关程序的版本有冲突的缘故。
虚拟环境里让Gunicorn跑Django project
pip install gunicorn
(the5fire)as3:~/the5fire/django_selfblog/selfblog# nohup ~/the5fire/bin/gunicorn_django --workers=2 -b 127.0.0.1:36483 > /dev/null &
(注意:必须先进入django项目文件夹,即含有manage.py文件的那个文件夹里,然后启动gunicorn.开启2个进程跑Django项目,使用nohup守护进程。)
让Nginx代理Gunicorn服务:
server {
listen 81;
server_name t5f.brite.biz;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:36483;
}
}
重启Nginx即可。演示站点:http://t5f.brite.biz:81/,原地址为http://as3.brite.biz:56375/ (这个56375是django工程的development server的端口号。(nohup python manage.py runserver 0.0.0.0:56375 > /dev/null &)
另外,需修改django项目的settings.py中的if DEBUG那行下面的DOMAIN = 的值,由
http://as3.brite.biz:56375改为http://t5f.brite.biz:81,然后重启django,使修改生效:
netstat -anp|grep :36483
(找到占用36483端口的进程号,杀死该进程)
nohup ~/the5fire/bin/gunicorn_django --workers=2 -b 127.0.0.1:36483 > /dev/null &
再以youflog为例。在虚拟环境里让Gunicorn跑Django project
cd ~/youflog-0.3/
as3:~/youflog-0.3# source bin/activate
(youflog-0.3)as3:~/youflog-0.3# ls
bin include lib youflog youflog-0.3.tar.gz
(youflog-0.3)as3:~/youflog-0.3# pip install gunicorn
(youflog-0.3)as3:~/youflog-0.3# cd youflog
(youflog-0.3)as3:~/youflog-0.3/youflog# nohup ~/youflog-0.3/bin/gunicorn_django --workers=2 -b 127.0.0.1:36484 > /dev/null &
(注意:必须先进入django项目文件夹,即含有manage.py文件的那个文件夹里,然后启动gunicorn.开启2个进程跑Django项目,使用nohup守护进程。)
让Nginx代理Gunicorn服务:
server {
listen 81;
server_name yl-cname.brite.biz;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:36484;
}
}
重启Nginx即可。演示站点:http://yl-cname.brite.biz:81/
此地址http://yl-cname.brite.biz:81/比http://yl.brite.biz:81/打开速度快多了。