トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

Django インストール 1.5.1



目次



記事一覧

キーワード

Django インストール1.5.1

[CentOS][Python][MySQL][Django][Django インストール]


http://docs.djangoproject.com/en/dev/intro/install/

Pythonのインストール


MySQLのインストール


Djangoのインストール

 ダウンロードと解凍

# wget https://www.djangoproject.com/download/1.5.1/tarball/
# tar xvf Django-1.5.1.tar.gz 

 インストール

  • 上記でインストールしたPython2.7にインストール
# cd Django-1.5.1
# python2.7 setup.py install

 MySQL-pythonのインストール

# wget --no-check-certificate https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.4.zip#md5=ddf2386daf10a97af115ffad2ed4a9a0
# unzip MySQL-python-1.2.4.zip 
# cd MySQL-python-1.2.4
# python2.7 setup.py instal

modwsgi

 modwsgi のインストール

httpd-devel

# yum install httpd-devel

python-devel

# yum install python-devel

mod_ssl

# yum install mod_ssl

以下のようなエラーがでる
Cannot load /etc/httpd/modules/mod_wsgi.so into server:  
/etc/httpd/modules/mod_wsgi.so: undefined symbol: RAND_status

modwsgi

ダウンロードと解凍
# wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
# tar xvf mod_wsgi-3.4.tar.gz 
インストール
  • Pythonのパスに上記でインストールしたPython2.7を指定
# cd mod_wsgi-3.4
# ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/local/bin/python2.7
# make
# make install

 httpd.confの編集

wsgi.conf を作成

  • /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonPath /home/myname/mysite
WSGIScriptAlias / /home/myname/mysite/myapp/myapp.py

エラーが発生する場合、httpdログを確認

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
error_log
ImportError: Could not import settings 'mayapp.settings' (Is it on sys.path?): No module named mayapp.settings

静的ファイルの扱い

settings.py 例
STATIC_URL = '/static/'
STATIC_ROOT = '/home/myname/static/'
テンプレート中の記述
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/myapp.css">
配置
./manage.py collectstatic
wsgi.conf に Aliasを追記
Alias /static/ "/home/myname/static/"



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.