CentOS 5.7にDjango1.3.1をインストール

python環境を整えて触っていきたいなと思ったので、
perlbrewのpython版、pythonbrewを使ってpython-2.7.2にして
Django1.3.1をインストールしてみます。


[環境]
サーバ:さくらVSP
OS:CentOS 5.7 x86_64


1.pythonbrewをインストール

curl -kLO https://github.com/utahta/pythonbrew/raw/master/pythonbrew-install
chmod +x pythonbrew-install
./pythonbrew-install

2.PATH追加

vim .bash_profile
PATH=$PATH:$HOME:/usr/local/pythonbrew
source .bash_profile

3.python2.7.2インストール

pythonbrew install 2.7.2

4.時間がかかるのでログを見ながら
>|?|
tailf /usr/local/pythonbrew/log/build.log

エラー

2 tests failed:
    test_argparse test_httpservers
1 test altered the execution environment:
    test_distutils
41 tests skipped:
    test_aepack test_al test_applesingle test_bsddb185 test_bsddb3
    test_cd test_cl test_codecmaps_cn test_codecmaps_hk
    test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
    test_dl test_gdb test_gl test_imageop test_imgfile test_kqueue
    test_linuxaudiodev test_macos test_macostools test_msilib
    test_ossaudiodev test_pep277 test_scriptpackages test_smtpnet
    test_socketserver test_startfile test_sunaudiodev test_tcl
    test_timeout test_tk test_ttk_guionly test_ttk_textonly
    test_unicode_file test_urllib2net test_urllibnet test_winreg
    test_winsound test_zipfile64
5 skips unexpected on linux2:
    test_gdb test_tcl test_tk test_ttk_guionly test_ttk_textonly
make: *** [test] Error 1

5.足りないパッケージをインストール

yum install sqlite-devel
yum install readline-devel
yum install zlib-devel
yum install gdbm-devel
yum install openssl-devel
yum install bzip2-devel
yum install tk
yum install tkinter
yum install tk-devel
yum install db4-devel

6.再度インストールコマンドを実行

7.使うバージョンを指定

pythonbrew switch 2.7.2

8.バージョン確認

python -V

9.Django1.3.1インストール

wget http://www.djangoproject.com/download/1.3.1/tarball/
tar xvzf Django-1.3.1.tar.gz 
cd Django-1.3.1
python setup.py build
python setup.py install

10.とりあえずsampleとしてプロジェクトを作ってみる

 django/bin/django-admin.py startproject sample

11.DB設定を記載して作成コマンド実行

 cd sample
 vim settings.py
 python manage.py syncdb

エラー

Error loading MySQLdb module: No module named MySQLdb

MySQLのpyhotn用ライブラリーがないみたいなのでインストール

 easy_install MySQL-python

エラー

error: Setup script exited with error: command 'gcc' failed with exit status 1

Googleったらmysql-develがないのが原因のようなのでインストール

 yum --enablerepo=remi,eplp --disablerepo=base install mysql-devel

再度MySQL-pythonのインストールを試みる

 easy_install MySQL-python

再度DB作成コマンド実行

 python manage.py syncdb

サービスを立ち上げて動いているか確認

 python manage.py runserver delaemon.com:80