CentOS django 설치

Jmnote (토론 | 기여)님의 2014년 6월 20일 (금) 10:41 판
리눅스 django 설치

1 사전확인

[root@localhost ~]# rpm -qa | grep ^python
python-libs-2.6.6-36.el6.x86_64
python-iniparse-0.3.1-2.1.el6.noarch
python-pycurl-7.19.0-8.el6.x86_64
python-2.6.6-36.el6.x86_64
python-urlgrabber-3.9.1-8.el6.noarch
[root@localhost ~]# python -V
Python 2.6.6

2 EPEL 저장소 추가

3 python-pip 설치

[root@localhost ~]# yum install python-pip
... (생략)
======================================================================================================
 Package                        Arch                Version                   Repository         Size
======================================================================================================
Installing:
 python-pip                     noarch              1.3.1-4.el6               epel              330 k
Installing for dependencies:
 python-setuptools              noarch              0.6.10-3.el6              base              336 k

Transaction Summary
======================================================================================================
Install       2 Package(s)

Total download size: 666 k
Installed size: 2.5 M
Is this ok [y/N]: y
... (생략)
Installed:
  python-pip.noarch 0:1.3.1-4.el6                                                                     

Dependency Installed:
  python-setuptools.noarch 0:0.6.10-3.el6                                                             

Complete!

4 django 설치

[root@localhost ~]# pip install django
Downloading/unpacking django
  Downloading Django-1.6.5.tar.gz (6.6MB): 6.6MB downloaded
  Running setup.py egg_info for package django
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: django
  Running setup.py install for django
    changing mode of build/scripts-2.6/django-admin.py from 644 to 755
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
    changing mode of /usr/bin/django-admin.py to 755
Successfully installed django
Cleaning up...

5 webapp 폴더 초기화

[root@localhost ~]# mkdir /opt/webapp
[root@localhost ~]# cd /opt/webapp
[root@localhost webapp]# django-admin.py startproject testapp
[root@localhost webapp]# find . -type f
./testapp/manage.py
./testapp/testapp/wsgi.py
./testapp/testapp/urls.py
./testapp/testapp/settings.py
./testapp/testapp/__init__.py

6 서버 실행

[root@localhost webapp]# cd testapp/
[root@localhost testapp]# python manage.py runserver &
[1] 19503
... (생략)
0 errors found
June 19, 2014 - 09:04:07
Django version 1.6.5, using settings 'testapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^M
[root@localhost testapp]# ps -ef | grep python | grep -v grep
root     19503 19471  5 18:04 pts/1    00:00:00 python manage.py runserver
root     19504 19503 10 18:04 pts/1    00:00:00 /usr/bin/python manage.py runserver
[root@localhost testapp]# netstat -anp | grep python
tcp        0      0 127.0.0.1:8000              0.0.0.0:*                   LISTEN      19504/python
[root@jmnote testapp]# curl "localhost:8000" 2>&1 | grep worked
[19/Jun/2014 10:29:49] "GET / HTTP/1.1" 200 1757
  <h1>It worked!</h1>

7 서버 중지

[root@localhost testapp]# kill 19503 19504
[1]+  Terminated              python manage.py runserver
[root@localhost testapp]# ps -ef | grep python | grep -v grep

8 같이 보기

9 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}