LoginSignup
4
4

More than 5 years have passed since last update.

ApacheでPython3+Django ~Mac~

Last updated at Posted at 2015-12-22

意外とこのあたりがまとまってるものがなかったのでメモ。
Macにはデフォルトで
Python 2.7.9
がインストールされている。

pyenvの準備

pyenvはPython環境を管理するもの。
バージョン違いのPythonを切り替えて管理することが可能。

pyenvのインストール

Macの場合は、brewでインストールする。

$ brew install pyenv-virtualenv

Pythonのインストール

3.4.3をインストール。

$ pyenv install 3.4.3

3.4.3をグローバルに設定する。

$ pyenv global 3.4.3

グローバルに設定されたか確認する

$ python -V

mod_wsgi

mod_wsgiとは、Apache上でPythonを動かすためのモジュール。

インストール

$ brew install mod_wsgi

Apacheの設定

httpd.confに以下を追加。

LoadModule wsgi_module [module to path]

virtualhostに設定する場合は以下を参照。
http://django-project-skeleton.readthedocs.org/en/latest/apache2_vhost.html

Daemon Mode

wsgi_modはデフォルトで「Embedded Mode」になっている。
「Embedded Mode」はApacheを再起動しないとpythonファイルが更新されない。
pythonの修正を即時に反映させるためには、「Daemon Mode」に設定する。
「WSGIDaemonProcess」に「processes=2 threads=15 display-name=%{GROUP}」を入れる。

WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP}

[参考]
https://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process

4
4
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
4
4