django-mysql-apache 설치 (작성일 : 2012.12.21, 작성자 : 김영광) 1. python 2.7.3 설치 다운로드 : http://www.python.org/getit/ 설치 파일 : python-2.7.3.msi python27폴더를 속성(내컴퓨터) -> 고급, 환경변수 -> path에 추가 2. DB 설치 mySQL 설치 다운로드 : http://www.mysql.com/downloads/installer/ 설치 파일 : mysql-installer-community-5.5.28.3.msi root 패스워드 설정 및 유저 추가 - root (PW: root) - k09wang (PW: 1231242) Workbench 설치 MySQLdb(MySQL for Python) 설치 다운로드 : http://sourceforge.net/projects/mysql-python/ 설치 파일 : MySQL-python-1.2.4b4.win32-py2.7.exe database 생성 MySQL Command Line Client에서 다음과 같이 입력하여 database를 생성 CREATE DATABASE CHARACTER SET utf8; 3. django 1.4.3 설치 다운로드 : https://www.djangoproject.com/download/ command line에서 django 압축해제한 디렉토리로 이동 c:\>cd C:\Django-1.4.3 c:\Django-1.4.3>python setup.py install Django-1.4.3\django\bin 디렉토리에 있는 django-admin.py를 c:\windows나 파이썬이 설치된 디렉토리 같은 시스템 경로로 복사 새 프로젝트를 생성하려면 command line에서 프로젝트 생성 (원하는 디렉토리 이동 후 아래 명령어 입력. 하위에 mysite폴더가 생성됨.) django-admin.py startproject mysite mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py 위와같은 경로로 생성되는데 manage.py는 settings.py와 같은 폴더에 있어야함. mysite/ __init__.py settings.py urls.py wsgi.py manage.py 위와 같이 구성하도록 함. manage.py, settings.py, wsgi.py 에 'mysite.~' 와 같이 되어 있는 부분들에서 'mysite.'을 삭제. 예) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") -> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") 4. DB 세팅 settings.py 에서 DATABASES 부분을 다음과 같이 설정. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': , # Or path to database file if using sqlite3. 'USER': , # Not used with sqlite3. 'PASSWORD': , # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } command line에서 mysite 디렉토리로 이동 후 python manage.py syncdb 입력하면 DB table들이 생성됨. 그리고 아래와 같은 질문을 받게 되는데, 'yes'를 입력하면 관리자 아이디를 생성할 수 있음. You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): 5. south 설치 다운로드 : http://www.aeracode.org/releases/south/ 압축 파일 : south-0.7.6.tar.gz 압축풀고 cmd에서 설치경로로 이동 후 python setup.py install 실행. settings.py의 INSTALLED_APPS에 'south' 추가. 6. apache 설치 다운로드 : http://www.apache.org/dist/httpd/binaries/win32/ 설치 파일 : httpd-2.2.22-win32-x86-no_ssl.msi 설치 후 방화벽 예외에 포트 추가 (TCP 80) 7. apache 세팅 mod_wsgi 설치 (apache2-python module) 다운로드 : http://code.google.com/p/modwsgi/downloads/list 설치 파일 : mod_wsgi-win32-ap22py27-3.3.so mod_wsgi-win32-ap22py27-3.3.so 파일을 \Apache2.2\modules 폴더 안에 mod_wsgi.so로 이름 변경하여 넣음. 아래의 두 파일을 다음과 같이 수정. httpd.conf (~/Apache2.2/conf/httpd.conf) LoadModule wsgi_module modules/mod_wsgi.so 추가 WSGIPythonPath "c:/var/www/mysite" 추가 Options Indexes FollowSymLinks 에서 Indexes 삭제 #Include conf/extra/httpd-vhosts.conf 에서 #(주석) 삭제 httpd-vhosts.conf (~/Apache2.2/conf/extra/httpd-vhosts.conf) 첫번째 ~ 부분을 다음과 같이 변경 DocumentRoot "C:/var/www/mysite" ServerName 09wang.stylefor.us:80 WSGIScriptAlias / "c:/var/www/mysite/wsgi.py" Order deny,allow Allow from all 참고 : https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/ 8. 이후 django project 진행 참고 : https://docs.djangoproject.com/en/dev/intro/tutorial01/