お名前.comのVPS01でDjango
yumのインストール
$ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/m2crypto-0.16-6.el5.6.x86_64.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/python-elementtree-1.2.6-5.x86_64.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/python-sqlite-1.1.7-1.2.1.x86_64.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm $ wget http://ftp.iij.ad.jp/pub/linux/centos/5/os/x86_64/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm $ wget http://ftp.iij.ad.jp/pub/linux/ceentos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm # rpm -ivh m2crypto-0.16-6.el5.6.x86_64.rpm # rpm -ivh python-elementtree-1.2.6-5.x86_64.rpm # rpm -ivh yum-metadata-parser-1.1.2-3.el5. centos.x86_64.rpm # rpm -ivh python-urlgrabber-3.1.0-5.el5.noarch.rpm # rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm # rpm -ivh python-sqlite-1.1.7-1.2.1.x86_64.rpm # rpm --import http://mirror.centos.org/centos-5/5.3/o s/i386/RPM-GPG-KEY-CentOS-5 # rpm -ivh yum-3.2.22-26.el5.centos.noarch.rpm yum-fasttestmirror-1.1.16-14.el5.centos.noarch.rpm
Python2.5とDjangoのインストール
wget http://python.org/ftp/python/2.5.2/Python-2.5.2 .tgz tar xvfz Python-2.5.2.tgz cd Python-2.5.2 ./configure --prefix=/opt/python2.5 --with-threa ds --enable-shared vi ./Modules/Setup make make install vi opt-python2.5.conf /sbin/ldconfig ln -s /opt/python2.5/bin/python /usr/bin/python2.5 wget http://pypi.python.org/packages/2.5/s/setuptool s/setuptools-0.6c9-py2.5.egg sh setuptools-0.6c11-py2.5.egg --prefix=/opt/python2 .5 curl -O http://peak.telecommunity.com/dist/ez_se tup.py easy_install Django
パス周り
$ vi .bash_profile --- PATH=$PATH:$HOME/bin +++ PATH=$PATH:$HOME/bin:/opt/python2.5/bin/ $ vi .bashrc +++ alias python='python2.5' $ source ~/.bash_profile $ source ~/.bashrc
Djangoのバージョン確認
django-admin.py --version 1.2.1
デプロイ
# httpd -v Server version: Apache/2.2.3 Server built: Oct 14 2009 20:27:59 cd etc $ find . -name httpd.conf -print ./httpd/conf/httpd.conf //mod_pythonのインストール # yum -y install httpd-devel # cd DOWNLOAD_DIR # wget http://ftp.kddilabs.jp/infosystems/apache/httpd/modpython/mod_python-3.3.1.tgz # tar xfz mod_python-3.3.1.tgz # cd mod_python-3.3.1 # ./configure --with-python=/opt/python2.5/bin/python2.5 --with-apxs=/usr/sbin/apxs # make # make install //Django+mod_python # chown stamp109.com /var/www/vhosts/stamp109.com/httpdocs $ cd /var/www/vhosts/stamp109.com/httpdocs $ django-admin.py startapp polls #Djangoチュートリアルアプリ作成 # vi /etc/httpd/conf.d/python.conf LoadModule python_module modules/mod_python.so <Location "/stamprally/"> SetHandler python-program PythonPath "['/var/www/vhosts/mydomain/httpdocs']+sys.path" PythonHandler django.core.handlers.modpython SetEnv PYTHON_EGG_CACHE /var/www/vhosts/mydomain/httpdocs/stamprally/.python-eggs SetEnv DJANGO_SETTINGS_MODULE stamprally.settings PythonDebug On </Location> # vi /etc/httpd/conf/httpd.conf <Location "/stamprally/"> SetHandler python-program PythonPath "['/var/www/html/']+sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE stamprally.settings PythonOption django.root /stamprally PythonDebug On PythonPath "['/var/www/vhosts/mydomain/httpdocs'] + sys.path" </Location> # /sbin/service httpd configtest # /sbin/service httpd restart
画像ライブラリPILのインストール
# wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz # tar zxvf Imaging-1.1.7.tar.gz # cd Imaging-1.1.7 # /opt/python2.5/bin/python setup.py build # /opt/python2.5/bin/python setup.py install //必要なライブラリの追加 # yum install libjpeg # yum install libjpeg-devel # yum install zlib # yum install zlib-devel
デプロイの続き
ここでブラウザからアクセスするとmod_pythonのエラー ImportError: No module named django.core.handlers.modpython シンボリックリンクを作成してみる # ln -s django /opt/python2.5/lib/python2.5/site-packages エラーが変わった SystemError: NULL result without error in PyObject_Call # chmod a+x /var/www/vhosts/mydomain/httpdocs/
pysqliteのインストール
//pysqliteのインストール # /opt/python2.5/bin/easy_install pysqlite エラー発生:command 'gcc' failed with exit status //gccのインストール # yum install gcc //再度pysqliteのインストール # /opt/python2.5/bin/easy_install pysqlite エラー発生:/usr/bin/ld: cannot find -lpython2.5 //ソースからpysqliteをインストール # wget http://pysqlite.googlecode.com/files/pysqlite-2.6.0.tar.gz # tar xvzf pysqlite-2.6.0.tar.gz # cd pysqlite-2.6.0 # vi setup.cfg 以下の様に修正 include_dirs=/opt/python2.5 librarly_dirs=/opt/python2.5/lib # /opt/python2.5/bin/python setup.py build # /opt/python2.5/bin/python setup.py install --prefix=/opt/python2.5 //インストール完了の確認 # /opt/python2.5/bin/python >>> import sys >>> sys.path.append('/opt/python2.5/lib/python2.5/site-packages/') >>> import pysqlite2
Apacheを再起動してブラウザからアクセスするとエラーが変わった DatabaseError: unable to open database file データベースファイルの親ディレクトリのパーミッションを変更すると、画面にアクセスできました☆ http://www.mail-archive.com/django-users@googlegroups.com/msg16740.html
References
- お名前.comのVPSサーバを使うまで
- お名前.com の VPS の CentOS5.3 に、Python 2.6.4 と Django 1.1.1 と、mod_wsgi を設定した覚え書き
- yumを間違って削除しちゃった場合の手順
- CentOS5.3にPython2.6でDjango1.1の開発環境を作成する
- パス(PATH)の確認と設定方法は?
- Apache と mod_python で Django を動かす
- mod_python のインストール
- CentOS5にpython2.6+Django+mod_python+色々の環境を整える
- PIL(Python Image Library)の導入
- CentOS に Django をデプロイ - with python2.6, mod_python
- はまったところ/pysqliteのインストール