-
通过git的方式
-
通过Blog_mini项目主页下载
-
首先确保你的系统已经安装了git版本控制系统:
1
2
|
[root@leaf ~]
# git --version
git version 1.7.1
|
-
如果还没有安装,请通过yum方式安装:
1
|
[root@leaf ~]
# yum install git
|
-
安装完成后,在用户目录中创建一个project的目录:
1
2
3
|
[root@leaf ~]
# mkdir project
[root@leaf ~]
# cd project
[root@leaf project]
#
|
-
从Blog_mini项目地址中克隆源代码:
1
|
[root@leaf project]
# git clone https://github.com/xpleaf/Blog_mini
|
-
查看Blog_mini的源代码目录结构:
1
2
3
4
5
|
[root@leaf project]
# cd Blog_mini/
[root@leaf Blog_mini]
# ls
app LICENSE migrations requirements
config.py manage.py Procfile requirements.txt
config.pyc manage.pyc README.md
|
-
进入项目主页:
-
点击Download ZIP按钮
-
下载后的文件名应该是:Blog_mini-master.zip
-
执行下面的命令安装即可:
1
|
[root@leaf Blog_mini]
# easy_install -i http://pypi.douban.com/simple virtualenv
|
-
在Blog_mini目录下执行下面的命令:
1
2
3
|
[root@leaf Blog_mini]
# virtualenv venv
New python executable
in
/root/project/Blog_mini/venv/bin/python
Installing setuptools, pip, wheel...
done
.
|
-
可以在Blog_mini下看到生成了一个venv目录:
1
2
3
4
|
[root@leaf Blog_mini]
# ls
app LICENSE migrations requirements
config.py manage.py Procfile requirements.txt
config.pyc manage.pyc README.md venv
|
-
执行如下命令:
1
|
[root@leaf Blog_mini]
# easy_install -i http://pypi.douban.com/simple pip
|
-
在Blog_mini目录下:
1
2
|
[root@leaf Blog_mini]
# source venv/bin/activate
(venv) [root@leaf Blog_mini]
#
|
-
执行如下命令:
1
|
(venv) [root@leaf Blog_mini]
# pip install -r requirements/common.txt
|
-
使用sqlite作为默认数据库来运行Blog_mini
-
使用MySQL作为默认数据库来运行Blog_mini
-
生成Blog_mini所需要的系统默认数据,请在Blog_mini目录下执行下面的命令:
1
2
3
4
|
(venv) [root@leaf Blog_mini]
# python manage.py deploy product
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 051691f120e6, fit to MySQL
|
-
查看生成的sqlite数据库:
1
2
3
4
|
(venv) [root@leaf Blog_mini]
# ls
app data.sqlite manage.pyc README.md venv
config.py LICENSE migrations requirements
config.pyc manage.py Procfile requirements.txt
|
-
运行Blog_mini:
1
2
3
4
5
|
(venv) [root@leaf Blog_mini]
# gunicorn manage:app
[2016-03-07 01:57:32 +0000] [7273] [INFO] Starting gunicorn 19.4.5
[2016-03-07 01:57:32 +0000] [7273] [INFO] Listening at: http:
//127
.0.0.1:8000 (7273)
[2016-03-07 01:57:32 +0000] [7273] [INFO] Using worker:
sync
[2016-03-07 01:57:32 +0000] [7278] [INFO] Booting worker with pid: 7278
|
-
以80端口运行Blog_mini:
1
2
3
4
5
|
(venv) [root@leaf Blog_mini]
# gunicorn -b 0.0.0.0:80 manage:app
[2016-03-07 02:01:46 +0000] [7317] [INFO] Starting gunicorn 19.4.5
[2016-03-07 02:01:46 +0000] [7317] [INFO] Listening at: http:
//0
.0.0.0:80 (7317)
[2016-03-07 02:01:46 +0000] [7317] [INFO] Using worker:
sync
[2016-03-07 02:01:46 +0000] [7322] [INFO] Booting worker with pid: 7322
|
-
如果你是在有公网IP地址的服务器部署Blog_mini的,只需要在互联网上任何一台主机的浏览器上输入你的公网IP地址,就可以访问Blog_mini了。
-
如果你只是在局域网上部署Blog_mini的,那么在局域网上的任何一台主机的浏览器上输入你这台主机的IP地址也是可以访问的了。
1
2
3
4
|
(venv) [root@leaf Blog_mini]
# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
|
-
账号:blog_mini@163.com
-
密码:blog_mini
1
|
(venv) [root@leaf Blog_mini]
# python manage.py deploy test_data
|
-
通过yum方式安装MySQL
-
通过源码的方式安装MySQL
-
安装MySQL-python依赖函数库:
1
|
(venv) [root@leaf Blog_mini]
# yum install python-devel mysql-devel zlib-devel openssl-devel
|
-
安装MySQL-python:
1
2
3
4
5
|
(venv) [root@leaf Blog_mini]
# pip install MySQL-python
……
Successfully built MySQL-python
Installing collected packages: MySQL-python
Successfully installed MySQL-python-1.2.5
|
-
退出虚拟环境,回到用户主目录中:
1
2
3
|
(venv) [root@leaf Blog_mini]
# deactivate
[root@leaf Blog_mini]
# cd
[root@leaf ~]
#
|
-
登陆到MySQL数据库中(请先确保MySQL服务已经开启):
1
2
3
4
|
[root@leaf ~]
# mysql -u root -p
Enter password:
mysql>
|
-
为Blog_mini创建数据库:
1
2
3
4
5
6
7
8
9
10
11
12
|
mysql> create database blog_mini default character
set
utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blog_mini |
| mysql |
+--------------------+
3 rows
in
set
(0.00 sec)
|
-
设定系统环境变量:
1
|
[root@leaf ~]
# export DATABASE_URL=mysql://root:123456@127.0.0.1/blog_mini
|
-
验证系统环境变量:
1
2
|
[root@leaf ~]
# echo $DATABASE_URL
mysql:
//root
:123456@127.0.0.1
/blog_mini
|
-
进入project/Blog_mini目录,初始化虚拟环境:
1
2
3
|
[root@leaf ~]
# cd project/Blog_mini/
[root@leaf Blog_mini]
# source venv/bin/activate
(venv) [root@leaf Blog_mini]
#
|
-
初始化Blog_mini系统默认数据:
1
2
3
4
|
(venv) [root@leaf Blog_mini]
# python manage.py deploy product
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 051691f120e6, fit to MySQL
|
-
运行Blog_mini:
1
2
3
4
5
|
(venv) [root@leaf Blog_mini]
# gunicorn manage:app
[2016-03-07 01:57:32 +0000] [7273] [INFO] Starting gunicorn 19.4.5
[2016-03-07 01:57:32 +0000] [7273] [INFO] Listening at: http:
//127
.0.0.1:8000 (7273)
[2016-03-07 01:57:32 +0000] [7273] [INFO] Using worker:
sync
[2016-03-07 01:57:32 +0000] [7278] [INFO] Booting worker with pid: 7278
|
-
以80端口运行Blog_mini:
1
2
3
4
5
|
(venv) [root@leaf Blog_mini]
# gunicorn -b 0.0.0.0:80 manage:app
[2016-03-07 02:01:46 +0000] [7317] [INFO] Starting gunicorn 19.4.5
[2016-03-07 02:01:46 +0000] [7317] [INFO] Listening at: http:
//0
.0.0.0:80 (7317)
[2016-03-07 02:01:46 +0000] [7317] [INFO] Using worker:
sync
[2016-03-07 02:01:46 +0000] [7322] [INFO] Booting worker with pid: 7322
|
-
如果你是在有公网IP地址的服务器部署Blog_mini的,只需要在互联网上任何一台主机的浏览器上输入你的公网IP地址,就可以访问Blog_mini了。
-
如果你只是在局域网上部署Blog_mini的,那么在局域网上的任何一台主机的浏览器上输入你这台主机的IP地址也是可以访问的了。
1
2
3
4
|
(venv) [root@leaf Blog_mini]
# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
|
-
账号:blog_mini@163.com
-
密码:blog_mini
1
|
(venv) [root@leaf Blog_mini]
# python manage.py deploy test_data
|