CentOS5でPython2.5が標準パッケージのサーバでインストールを確認しました。
# yum install -y httpd-devel # 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=/usr/local/bin/python2.5 # make # make install
LoadModule python_module modules/mod_python.so
※<Location>~</Location>を使ってhttpd.confに書くことも可能。
<VirtualHost *:80>
ServerName mysite.com
DocumentRoot /var/www/html/mysite
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonPath "['/var/www/html'] + sys.path"
PythonDebug On #for debug mode
SetEnv PYTHON_EGG_CACHE /tmp/mysite
</VirtualHost>設定項目についてはmod_python上のでDjangoで「ImportError: Could not import settings : No module named settings」と出るときの解決方法?などを参照
# mkdir /tmp/mysite # chown apache:apache /tmp/mysite
# service httpd restart
It worked! Congratulations on your first Django-powered page. Of course, you haven't actually done any work yet. Here's what to do next: If you plan to use a database, edit the DATABASE_* settings in test_project/settings.py. Start your first app by running python test_project/manage.py startapp [appname]. You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!
タグ : apache django mod_python インストール CentOS yum Python virtualhost PythonHandler

