MacにApacheとmod_pythonを入れてDjangoを動かす

4 / 15 / 2010

結構はまった部分があるのでメモメモ。

$ sudo port install apache2

$ sudo port install mod_python

To fully complete your installation and make python 2.4 the default, please run

$ sudo port install python_select
$ sudo python_select python25

$ django-admin.py
Type ‘django-admin.py help’ for usage.

お次はhttpd.confを

$ sudo vim /opt/local/apache2/conf/httpd.conf

#LoadModule ssl_module modules/mod_ssl.so

<Location “/”>
SetHandler python-program
PythonPath “['/Users/hoge/Sites/']+sys.path”
PythonHandler django.core.handlers.modpython
SetEnv PYTHON_EGG_CACHE /Users/hoge/Sites/contrust.python-eggs
SetEnv DJANGO_SETTINGS_MODULE hoge.settings
PythonDebug On
</Location>

<Location “/media”>
SetHandler None
</Location>

<LocationMatch “\.(jpg|gif|png)$”>
SetHandler None
</LocationMatch>

お次はhttpd-vhosts.confを。

dummy-host.example.comみたいなやつはコメントアウトしておきましょう。

<VirtualHost *:80>
DocumentRoot “/Users/hoge/Sites/contrust”
ServerName localhost
ServerAlias localhost
</VirtualHost>

$ sudo /opt/local/apache2/bin/apachectl start

http://localhost/にアクセスしたら404。ここから試行錯誤を二時間。結局httd.confの

<Directory “/Users/hoge/Sites”>

ってのを忘れてた。

Tags: , , ,

コメントする

About this entry

MacにApacheとmod_pythonを入れてDjangoを動かす

Posted in 4 / 15 / 2010

Tags: , , ,

Share

Bookmark