Ubuntu 10.04 환경에서 Django 설치 및 Apache 와의 연동을 방법Apache2, php, MySQL 환경이 구축되어있다고 가정한다.1. apache2 python module 설치
UserDir public_html
UserDir disabled root
<Directory /home/khtinsoft/public_html/>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE khtinsoft_jango.settings
PythonOption django.root /khtinsoft_jango
PythonPath "['/home/khtinsoft/public_html']+sys.path"
PythonDebug On
</Directory>
<Directory /home/-/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
</IfModule>
sudo apt-get install libapache2-mod-pythonsudo a2enmod pythonsudo /etc/init.d/apache2 restart2. Django 설치Djaggo 설치 소스를 다운받는다. https://www.djangoproject.com/download/
tar xvfz Django-1.3.1.tar.gzcd Django-1.3.1sudo python setup.py install3. Django Project 생성
cd /home/khtinsoft/public_htmldjango-admin startproject khtinsoft_jango그럼 /home/khtinsoft/public_html/khtinsoft_jango 가 생성된다4. Apache 와의 연동현재 apache2 의 userdir 모듈을 사용하고 있으므로, public_html 에 웹서버를 사용하고, http://ip_address/~khtinsoft 가 주소이다. 따라서 site 파일 말고 userdir.conf 파일을 수정한다.일반적인 아파치 환경의 경우 site 설정 파일을 수정한다.
cd /etc/apache2/mods-available/sudo vi ./userdir.conf<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/khtinsoft/public_html/>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE khtinsoft_jango.settings
PythonOption django.root /khtinsoft_jango
PythonPath "['/home/khtinsoft/public_html']+sys.path"
PythonDebug On
</Directory>
<Directory /home/-/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
</IfModule>
sudo /etc/init.d/apache2 restart이제 http://ip_address/~khtinsoft 로 접속하면 장고 화면을 볼 수 있다.



덧글