LoginSignup
8
7

More than 5 years have passed since last update.

CentOS6+Python3+Django

Last updated at Posted at 2016-11-07

バージョン

$ cat /etc/redhat-release 
CentOS release 6.8 (Final)

準備

$ yum update
$ # Pythonのmakeに必要
$ yum install wget
$ yum install gcc*
$ yum install openssl-devel
$ # pipのインストールに必要
$ yum install git
$ # Djangoの利用に必要
$ yum install sqlite-devel

Python

参考:https://www.python.org/downloads/

$ cd /usr/local/src
$ wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
$ tar xzvf Python-3.5.2.tgz
$ cd Python-3.5.2
$ ./configure
$ make
$ make install
$ python3 --version
Python 3.5.2

pip

$ cd /usr/local/src
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3 get-pip.py
$ pip3 --version
pip 9.0.0 from /usr/local/lib/python3.5/site-packages (python 3.5)

Django

参考:https://www.djangoproject.com/download/

$ pip3 install Django==1.10.3

開始と確認

$ cd /usr/local/src
$ python3 /usr/local/bin/django-admin.py startproject test_project
$ cd test_project
$ vi test_project/settings.py

#ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']

$ python3 manage.py migrate
$ python3 manage.py runserver 0.0.0.0:8000

アクセス:http://127.0.0.1:8000/

※ALLOWED_HOSTSの設定と、
 runserverの「0.0.0.0:8000」はセキュリティに関わる部分なので、適切な値を設定することが望ましい

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7