!!!Django インストール 1.2.3 [Django][Python][CentOS5.5][Django インストール] *CentOS5.5にインストール {{amazon 4048672096}} http://docs.djangoproject.com/en/dev/intro/install/ !!Python のインストール ::Django1.2.3 には *Python version 2.4 - 2.7 が必要 *version 3.0 は未対応 !ダウンロードと解凍 *http://www.python.org/download/releases/2.7/ *http://www.python.org/ftp/python/2.7/Python-2.7.tgz # wget http://www.python.org/ftp/python/2.7/Python-2.7.tgz # tar xzvf Python-2.7.tgz !インストール ::参考 *http://lowlife.jp/yasusii/wiki/InstallingAnotherVersionOfPython.html *http://surgo.jp/2009/11/centos-django-with-python26-modpython.html *http://labs.unoh.net/2007/04/python.html !システム標準のPythonを置き換えない方法を行う ::インストール # yum install zlib zlib-devel sqlite-devel # cd Python-2.7 # ./configure --prefix=/opt/python2.7 --with-threads --enable-shared # vi Modules/Setup : 以下の行のコメントを外す zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz : # make # make install ::共有ライブラリの設定 # vi /etc/ld.so.conf.d/opt-python2.7.conf : 以下の行を追加 /opt/python2.7/lib # /sbin/ldconfig # /sbin/ldconfig -p | grep "python" libpython2.7.so.1.0 (libc6) => /opt/python2.7/lib/libpython2.7.so.1.0 libpython2.7.so (libc6) => /opt/python2.7/lib/libpython2.7.so libpython2.4.so.1.0 (libc6) => /usr/lib/libpython2.4.so.1.0 libpython2.4.so (libc6) => /usr/lib/libpython2.4.so ::実行プログラムへのシンボリックリンク # ln -s /opt/python2.7/bin/python /usr/bin/python2.7 # ln -s /opt/python2.7/lib/python2.7 /usr/lib/python2.7 ::指定ユーザーに python で version 2.7 を起動させるように設定 # vi .bash_profile PATH=$PATH:$HOME/bin:/opt/python2.7/bin/ alias python='python2.7' # source .bash_profile # python Python 2.7 (r27:82500, Sep 13 2010, 23:26:14) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. ::今後作成するユーザーも python で version 2.7 を起動させるように、以下のファイルを編集 # vi /etc/skel/.bash_profile PATH=$PATH:$HOME/bin:/opt/python2.7/bin/ alias python='python2.7' ::setuptools のインストール # wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg # sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7 !!データベースのインストール *http://docs.djangoproject.com/en/1.2/topics/install/#database-installation !MySQLのインストール ::MySQLのインストール *CentOS 初期設定 を参照 # yum install mysql-devel ::MySQLdb のインストール # wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download # tar xzvf MySQL-python-1.2.3.tar.gz # cd MySQL-python-1.2.3 # python setup.py install *どうもPythonの[共有ライブラリの設定|Linux ライブラリ]がうまくいかない・・・ gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/opt/python2.7/include/python2.7 -c _mysql.c -o build/temp.linux-i686-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv gcc -pthread -shared build/temp.linux-i686-2.7/_mysql.o -L/usr/lib/mysql -L/usr/lib -L. -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -lpython2.7 -o build/lib.linux-i686-2.7/_mysql.so /usr/bin/ld: cannot find -lpython2.7 *回避 (/sbin/ldconfig -p では認識されているはずなのに・・・)する。 # sudo ln -s /opt/python2.7/lib/libpython2.7.so.1.0 /usr/lib/libpython2.7.so # python setup.py install !!Django のインストール(公式版) !ダウンロードと解凍 *http://www.djangoproject.com/download/ # wget http://www.djangoproject.com/download/1.2.3/tarball/ # tar xzvf Django-1.2.3.tar.gz # cd Django-1.2.3 # python setup.py install # mkdir django # chown apache:apache -R /var/www/django # cd /var/www/django # django-admin.py startproject mysite *ホストとポートを指定して起動 # cd mysite # python manage.py runserver 192.168.24.13:8080 Validating models... 0 errors found Django version 1.2.3, using settings 'mysite.settings' Development server is running at http://192.168.24.13:8080/ Quit the server with CONTROL-C. {{ref_image django_inst01.jpg}} !mod_python *http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ *要件 Apache 2.x および mod_python 3.x ::download # wget http://ftp.kddilabs.jp/infosystems/apache/httpd/modpython/mod_python-3.3.1.tgz ::install # yum install httpd-devel # tar xvzf mod_python-3.3.1.tgz # cd mod_python-3.3.1 # ./configure --with-python=/opt/python2.7/bin/python --with-apxs=/usr/sbin/apxs # make