aliyun的网络访问有时会有问题,pip有问题的时候使用豆瓣源

pip install $apptoinstall$ -i http://pypi.douban.com/simple

------------------------------------------------------------------------------------

Step1.Perpare the basic packages

1.instal pip and fabric

sudo easy_install pip # no pip in ubuntu < 10, make sure
sudo pip install --upgrade virtualenv virtualenvwrapper
sudo pip install --upgrade 'fabric>=1.0'

2.install compiler

sudo apt-get --yes install build-essential python-setuptools python-dev \
python-software-properties

3.install C lib for PIL

这个是为mezzanine准备的,Pillow自动安装的时候不会自动装,mezzanine的上传功能不能使用。

sudo apt-get install --yes libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev \
liblcms1-dev libwebp-dev python-dev

----------------------------------------------------------------------------

Step 2.Setup Mezzinine in VirtualEnv

0.perpare folds

mkdir -p /srv/www/open-ivi.org/public_html/static
mkdir /srv/www/open-ivi.org/application
mkdir /srv/www/open-ivi.org/logs

1. create virtualenv


export WORKON_HOME=/srv/www/open-ivi.org/
mkdir $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh

cd $WORKON_HOME

mkvirtualenv open-ivi.org

#rmvirtualenv open-ivi.org # use this command to remove the env if you are in trouble

######################################################################

# How to enter this virtual env again

cd /srv/www/open-ivi.org/

source /srv/www/open-ivi.org/open-ivi.org/bin/activate

######################################################################

2.install packages

pip install pillow
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- LIBTIFF support available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
--- WEBP support available
*** WEBPMUX support not available
--------------------------------------------------------------------
pip install mezzanine south django-compressor

3. try to work with sqlite3

mezzanine-project siteroot
chmod 777 -R *.py #make it as exe
cd siteroot
./manage.py createdb --noinput # usrname:admin pwd:default
./manage.py runserver 0.0.0.0:9999 #then check it with your browser

So great! It works.Then let's create the server stack .

------------------------------------------------------------------------------------

Step3.Make Gunicorn works

0.Make Sure django works with the deploy env

#go there to find a key :http://www.miniwebtool.com/django-secret-key-generator/
#edit siteroot/deploy/live_setting.py
SECRET_KEY =

1.install gunicorn

gunicorn18.0 droped gunicorn_django so let's use old version.

pip install gunicorn==17.5
#make www-data own the folder
chown -R www-data:www-data /srv/www

2.test gunicorn

gunicorn siteroot.wsgi:application --bind 0.0.0.0:80

3.add gunicorn conf to project root

#we use the code from deploy/gunicorn.conf.py
from __future__ import unicode_literals
import os
import multiprocessing bind = "127.0.0.1:8023"
workers = multiprocessing.cpu_count() * + 1
#old method have problem with the system use multiprocessing class for replacement
#workers = (os.sysconf("SC_NPROCESSORS_ONLN") * ) +
loglevel = "error"
proc_name = "openivi"

4. install supervisor

apt-get install supervisor ngnix

5.make gunicorn run while reboot

vi /etc/supervisor/conf.d/openivi.conf
#add codes below

[group:openivi]
programs=gunicorn_openivi


[program:gunicorn_openivi]
command=/datadsk/siteroot/bin/gunicorn_django -c gunicorn.conf.py -p gunicorn.pid
directory=/datadsk/siteroot/openivi
user=root
autostart=true
autorestart=true
redirect_stderr=true
environment=PATH="/datadsk/siteroot/bin"

 

6.try it!

 supervisorctl reload

CSS won't be found when we use gunicorn, let nginx do with the statics.

Step4.Work with Nginx

we already installed ngnix in step3

1.config it! Add file to /ete/nginx/sites-enabled/openivi.conf as below.

upstream openivi {
server 127.0.0.1:8023;
} server {
listen 80;
# listen 443 ssl;
server_name localhost;
client_max_body_size 10M;
keepalive_timeout 15; # ssl_certificate conf/%(proj_name)s.crt;
# ssl_certificate_key conf/%(proj_name)s.key;
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 10m;
# ssl_ciphers RC4:HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_pass http://openivi;
} location /static/ {
root /datadsk/siteroot/openivi;
access_log off;
log_not_found off;
} location /robots.txt {
root /datadsk/siteroot/openivi/static;
access_log off;
log_not_found off;
} location /favicon.ico {
root /datadsk/siteroot/openivi/static/img;
access_log off;
log_not_found off;
} }

@we used nginx for static pass-though, don't forget to collect all static file to the root folder. manage.py have this feature which provided by django framework.

 Test it ,Shoud be works.

建站随手记:installation python virtualenv mezzanine -1的更多相关文章

  1. 建站随手记:about server stack

    建站需要,随手记: Server Stack: ----------- 标准的mezzanine的Stack设置 前端:Nginx wsgi:gunicorn cms tool: mezzanine ...

  2. Drupal 7 建站学习手记(四):怎样改动Nivo Slider模块的宽高

    背景 Nivo Slider模块默认大小是用的height: 100%, width 100%, 但IE7及下面的浏览器是不支持百分比宽高的, 而我的项目目标用户基本都是使用XP系统,项目需求是必须兼 ...

  3. Drupal 7 建站学习手记(五):QuickTabs模块内的元素无法溢出的问题

    背景 项目要求站点首页放Views生成的区块,而且要求有很多其它链接. Views生成的区块默认的很多其它链接仅仅能选在列表上方和下方 下图是默认在上方的样式图: 为了美观.我将很多其它链接上移了若干 ...

  4. Python快速建站系列-Part.One-组装开发环境

    |版权声明:本文为博主原创文章,未经博主允许不得转载. 源代码都在github上:SmallStudyStation 现在是个demo,但回来会租个服务器,等功能完善了放到服务器上挂着,域名jusot ...

  5. 【从0開始Tornado建站】0.9版本号python站点代码开源--持续更新中

            从5月份開始[从0開始Tornado建站]这个专栏,開始一点一点把这个分类兴趣站点弄起来,从无到有的过程也是令人兴奋的:-) 国庆的时候等待备案然后上线,如今站点域名为ustchack ...

  6. Python+Flask+MysqL的web技术建站过程

    1.个人学期总结 时间过得飞快,转眼间2017年就要过去.这一年,我学习JSP和Python,哪一门都像一样新的东西,之前从来没有学习过. 这里我就用我学习过的Python和大家分享一下,我是怎么从一 ...

  7. Python快速建站系列-Part.Three-注册和登录

    |版权声明:本文为博主原创文章,未经博主允许不得转载. 上一个Part已经给TSSS编好了一个简单的Web服务,网页的基础模版也写好了,那从这个Part开始就慢慢增加编写功能. 先写基础功能:注册和登 ...

  8. (转) Web 建站技术中,HTML、HTML5、XHTML、CSS、SQL、JavaScript、PHP、ASP.NET、Web Services 是什么?

    Web 建站技术中,HTML.HTML5.XHTML.CSS.SQL.JavaScript.PHP.ASP.NET.Web Services 是什么? 建站有很多技术,如 HTML.HTML5.XHT ...

  9. Web 建站技术中,HTML、HTML5、XHTML、CSS、SQL、JavaScript、PHP、ASP.NET、Web Services 是什么(转)

    Web 建站技术中,HTML.HTML5.XHTML.CSS.SQL.JavaScript.PHP.ASP.NET.Web Services 是什么?修改 建站有很多技术,如 HTML.HTML5.X ...

随机推荐

  1. (Interface)接口特点

    接口是一种规范.只要一个类继承了一个接口,这个类就必须实现这个接口中所有的成员 为了多态. 接口不能被实例化.也就是说,接口不能new(不能创建对象) 接口中的成员不能加"访问修饰符&quo ...

  2. python 编辑文件时路径问题解决方法:文件或者目录不存在、文件编辑后无法保存等(以编辑xml文件为例)

    1.获取工程所在根路径:根路径=os.path.dirname(os.path.abspath('__file__')) 2.将获取的根路径和相对路径组合:组合路径=os.path.join(根路径, ...

  3. mysql优化一 之 优化内容概述及开启慢查日志的相关配置

    1-1数据库优化的目的 首先是为了避免出现页面访问错误(基本有三种) (1)由于数据库连接timeout产生的页面5XX错误 (2)由于慢查询造成页面无法加载 (3)由于阻塞造成的数据无法提交 其次: ...

  4. apache代理服务器为nodejs服务设置域名

    本机以apache为主,其中 在httpd.conf中先设置 <VirtualHost *:80> ServerName nodejs.cc ServerAlias www.nodejs. ...

  5. Json解析实例

    using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Win ...

  6. python 最大公约数

    求解两个整数(不能是负数)的最大公约数(要求两数不能同时为0)当两数都是0时,最大公约数为0方式一:穷举法 def GCU(m, n): if not m: return n elif not n: ...

  7. 什么是js和js的基本语法

    时间:2016年12月15日 先讲讲基础语法: 大部分是来操作表单: js动态效果和数据交互(ajax?) js也有自己的API js大部分的DOM操作都是针对input的. 案例学习,对注册页面的简 ...

  8. 16-腾讯-intership-面试

    问题 问:说一下在浏览器那里输入一个网址,会发生什么?答:DNS服务器解析,TCP三次握手,建立连接,然后bilibala............... 问:你对http相关协议熟悉吗?答:我问是ge ...

  9. Codeforces Round #388 (Div. 2) A,B,C,D

    A. Bachgold Problem time limit per test 1 second memory limit per test 256 megabytes input standard ...

  10. 回调函数及数组中sort()方法实现排序的原理

    1.回调函数:把一个方法A当一个参数值传递到另外一个函数B中,在B执行的过程当中我们随时根据需求让A方法执行:   什么是回调 :它是异步编程基本的方法,需要异步处理的时候一般采用后续传递的方式,将后 ...