!!!Django インストール1.5.1 [CentOS][Python][MySQL][Django][Django インストール] {{amazon 4048672096}} http://docs.djangoproject.com/en/dev/intro/install/ !!!Pythonのインストール *CentOS6にPython2.7をインストール !!!MySQLのインストール *MySQL !!!Djangoのインストール *https://www.djangoproject.com/ !!ダウンロードと解凍 # 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 *http://docs.nullpobug.com/django-doc-ja/trunk/howto/deployment/modwsgi.html *Apache と mod_wsgi の組み合わせは、推奨の Django の実運用環境です。 !!modwsgi のインストール *http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide *http://d.hatena.ne.jp/addition/20130330/1364620476 !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 *http://code.google.com/p/modwsgi/downloads/list ::ダウンロードと解凍 # 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の編集 *http://docs.nullpobug.com/django-doc-ja/trunk/howto/deployment/modwsgi.html !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 !静的ファイルの扱い *http://docs.djangoproject.jp/ja/latest/howto/static-files.html ::settings.py 例 STATIC_URL = '/static/' STATIC_ROOT = '/home/myname/static/' ::テンプレート中の記述 ::配置 ./manage.py collectstatic ::wsgi.conf に Aliasを追記 Alias /static/ "/home/myname/static/"