블로그 이전하였습니다.

티스토리로 블로그를 이전하였습니다.

http://gauryan.tistory.com/ --> 이쪽으로 와주세요. *^^*

by 가우리언 | 2009/06/19 14:45 | 트랙백 | 덧글(0)
Debian Squeeze 에서 Apache + Django 연동 설치하기
Django 공식사이트나 Django Book 사이트에도 잘 정리되어 있지만,
다시한번 처음부터 설치/설정 하는 법을 정리해보았다.

1. Django 설치
# apt-get install python-django

2. Apache + mod_python 설치
# apt-get install libapache2-mod-python

3. 프로젝트 생성
$ mkdir -p /opt/project/web
$ cd /opt/project/web
$ django-admin startproject 프로젝트이름

4. 템플릿 디렉토리 설정
$ cd 프로젝트이름
$ mkdir templates

settings.py :
TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)

5. 어플리케이션 생성
$ cd /opt/project/web/프로젝트이름
$ python manage.py startapp 어플리케이션이름

6. URL 설정 (urls.py)
from 프로젝트이름.어플리케이션이름.views import *
urlpatterns = patterns('',
    (r'^$', index),
)

7. View 작성
$ cd /opt/project/web/프로젝트이름/어플리케이션이름
$ vi views.py
from django.shortcuts import render_to_response
from django.template import RequestContext

def index(request):
    return render_to_response(
        'index.html',
    )

8. 템플릿 작성
$ cd /opt/project/web/프로젝트이름/templates
$ vi index.html
<html>
<head><title>The First Page</title></head>
<body><h1>The First Page : Success ^^</h1></body>
</html>

9. Apache 설정
# cd /etc/apache2/sites-available
# vi 프로젝트이름
NameVirtualHost 아이피:80

<Virtualhost 아이피:80>
    ServerName 도메인주소
    DocumentRoot /opt/project/web

    <Location>
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE 프로젝트이름.settings
        PythonDebug On
        PythonPath "['/opt/project/web'] + sys.path"
    </Location>

    <Location "/css">
        SetHandler None
    </Location>
</Virtualhost>

# a2ensite 프로젝트이름

10. 이제, 아파치를 재시작하고 웹브라우즈에서 http://도메인이름 을 입력해보자.
by 가우리언 | 2009/05/20 14:36 | ⊙ IT | 트랙백 | 덧글(0)
Ubunu 8.04 LTS에 python 2.6 을 설치하자
나중에 python 2.x 에서 python 3.x 로 변경하기 위해서는 2.6 버전을 이용하는 것이 좋다고 합니다. 3.x 로 가기 위한 중간 버전인것이죠. 그런데, Ubunbu 8.04 에서는 python 2.5.2 가 설치되어 있어서, 별도로 설치해주어야 합니다. 여기에서는 python 2.6.2 final 버전을 설치하겠습니다.

현재 파이썬 버전을 확인 합니다.
$ python -V
Python 2.5.2

우선 빌드를 위한 기본 패키지를 설치합니다.
$ sudo -i
# apt-get install build-essential

파이썬 소스를 다운로드 받습니다.
# cd /usr/local/src
# wget http://python.org/ftp/python/2.6.2/Python-2.6.2.tgz

파이썬 소스를 풀고, 빌드/설치합니다.
# tar xvfz Python-2.6.2.tgz
# cd Python-2.6.2
# ./configure
# make; make install

/usr/local/bin 에 가서 확인해보면 python 2.6 이 설치된 것을 볼 수 있습니다.
마지막으로 다시 현재 파이썬 버전을 확인해봅니다.
# python -V
Python 2.6.2

어때요, 쉽지요?
그리 어려운 작업은 아니었습니다. *^^*

by 가우리언 | 2009/04/18 12:27 | ⊙ IT | 트랙백 | 덧글(0)


< 이전페이지 다음페이지 >