Total Pageviews

Sunday, 24 November 2013

在linux vps上编译python3.3.3环境,然后搭建基于python3.3.3的静态博客程序-letterpress

需先编译python3.3.3环境:


wget http://python.org/ftp/python/3.3.3/Python-3.3.3.tar.bz2
tar jxvf Python-3.3.3.tar.bz2  
cd Python-3.3.3
./configure --prefix=/usr/local/python-3.3.3
make            
make install 
ln -s /usr/local/python-3.3.3/bin/python3.3 /usr/local/bin/python3.3
ln -s  /usr/local/python-3.3.3/bin/easy_install-3.3 /usr/local/bin/easy_install-3.3
ln -s  /usr/local/python-3.3.3/bin/pip-3.3 /usr/local/bin/pip-3.3 
(至此python3.3就搭建好了) 

或编译python3.5.2环境:
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar zxvf Python-3.5.2.tgz
cd Python-3.5.2
./configure --prefix=/usr/local/python-3.5.2
make 
make install
ln -s /usr/local/python-3.5.2/bin/python3.5 /usr/bin/python3.5
ln -s /usr/local/python-3.5.2/bin/easy_install-3.5 /usr/bin/easy_install-3.5
ln -s /usr/local/python-3.5.2/bin/pip3.5 /usr/bin/pip3.5
(至此python3.5就搭建好了)
 
或更简单的办法:apt-get install -y python3 python3-pip python3-setuptools
即可。 

git clone https://github.com/an0/Letterpress.git letterpress
cd letterpress
cp code/letterpress.py /usr/local/python-3.3.3/lib/python3.3/
wget https://raw.github.com/an0/python-markdown2/master/lib/markdown2.py
mv markdown2.py /usr/local/python-3.3.3/lib/python3.3/
mkdir press_folder
cp press/* press_folder
nano ~/letterpress/press_folder/letterpress.config
(把base_url的值改为你的域名地址,我的是http://lp.brite.biz,
把site_dir的值改为你指定的letterpress的静态网站的根目录,我的为/root/letterpress-root-dir)

然后安装pyinotify,
git clone https://github.com/seb-m/pyinotify.git
cd pyinotify
python3.3 setup.py install (thus i can install pyinotify to python3.3 environment successfully)
或者这样装:
wget http://python-distribute.org/distribute_setup.py
python3.3 distribute_setup.py
it will show:
 ...
Installing easy_install script to /usr/local/python-3.3.3/bin
Installing easy_install-3.3 script to /usr/local/python-3.3.3/bin
...
/usr/local/python-3.3.3/bin/easy_install-3.3 pyinotify (thus i can install pyinotify to python3.3 environment successfully)

cd /usr/local/python-3.3.3/lib/python3.3
python3.3 letterpress.py ~/letterpress/press_folder & (这个就是生成/更新静态网站的命令)
cd /root/letterpress-root-dir
as3:~/letterpress-root-dir# ls
2013  404.html  archive  css  favicon.png  img  index.html  tags
as3:~/letterpress-root-dir#
(可见~/letterpress-root-dir/果然是静态网站的根目录。)
as3:~/letterpress-root-dir# Rwebserver 45360 &
(立马就可查看网站效果:http://as3.brite.biz:45360)

发贴方法:
as3:~/letterpress-root-dir# cd ~/letterpress/press_folder
 as3:~/letterpress/press_folder# ls
404.html  favicon.png  letterpress.config  sample_post.md
css       img          letterpress.log     templates
按照sample_post.md的格式,新建帖子test1.md,格式如下:
title: test1
date: 11/23/2013
excerpt: read more...
tags: misc

这是测试1.


然后:
 as3:~/letterpress/press_folder# cd ..
 as3:~/letterpress# python3.3 code/letterpress.py ~/letterpress/press_folder &
(这个就是生成/更新静态网站的命令)

演示站点:http://lp.brite.biz/
项目地址:https://github.com/an0/Letterpress
--------------------------
编译python3.2.2环境:


wget https://www.python.org/ftp/python/3.2.2/Python-3.2.2.tar.bz2
tar jxvf Python-3.2.2.tar.bz2  
cd Python-3.2.2
./configure --prefix=/usr/local/python-3.2.2
make            
make install 
ln -s /usr/local/python-3.2.2/bin/python3.2 /usr/local/bin/python3.2
wget https://bootstrap.pypa.io/ez_setup.py
python3.2 ez_setup.py
会显示:
...
Adding setuptools 1.4 to easy-install.pth file
Installing easy_install script to /usr/local/python-3.2.2/bin
Installing easy_install-3.2 script to /usr/local/python-3.2.2/bin
Installed /usr/local/python-3.2.2/lib/python3.2/site-packages/setuptools-1.4-py3.2.egg
Processing dependencies for setuptools==1.4
Finished processing dependencies for setuptools==1.4 
 
ln -s  /usr/local/python-3.2.2/bin/easy_install-3.2  /usr/local/bin/easy_install-3.2
这样以后就可用easy_install-3.2命令来安装python3.2版的各个python modules了。

或者这样做,更好:
# wget https://bootstrap.pypa.io/get-pip.py
# python3.2  get-pip.py
显示: 
Downloading/unpacking pip
  Downloading pip-1.5.4-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Successfully installed pip
Cleaning up...
as3:~# ls /usr/local/python-3.2.2/bin/
2to3              idle3    pip3.2    python3.2          python3-config
2to3-3.2          idle3.2  pydoc3    python3.2-config
easy_install      pip      pydoc3.2  python3.2m
easy_install-3.2  pip3     python3   python3.2m-config
as3:~# ln -s /usr/local/python-3.2.2/bin/pip3.2  /usr/local/bin/pip3.2
这样以后就可用pip3.2命令来安装python3.2版的各个python modules了。

(参考:
https://pypi.python.org/pypi/ez_setup

https://pypi.python.org/pypi/setuptools)