dev-lang

Apache + mod_wsgi + Flask

검은바람 2013. 7. 18. 17:07
반응형

아파치는 설치되어 있다 가정하고...

1. Flask app editing

2. mod_wsgi install

3. httpd.conf editing

4. Apache restart


1. Flask app editing

$ cd /[app path]

$ vim [app name].wsgi

# 아래 추가.

import sys

sys.path.insert(0, "/[app path]")

from [app name] import app as application


2. mod_wsgi install

$ cd /usr/local/src

$ sudo weget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz

$ sudo tar zxvf mod_wsgi-3.4.tar.gz

$ cd mod_wsgi-3.4

sudo ./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/bin/python (경로는 알아서...)

$ sudo make

$ sudo make install


3. httpd.conf editing

$ cd /usr/local/apache/conf

$ sudo vim httpd.conf

# 아래 추가.

LoadModule wsgi_module modules/mod_wsgi.so

AddHandler wsgi-script .wsgi

$ sudo vim extra/httpd-vhosts.conf

# 아래 추가.

<VirtualHost *:80>

       ServerName [도메인]

       ServerAdmin [관리자이메일]

       WSGIDaemonProcess [app name] user=nobody group=nobody threads=5

       WSGIScriptAlias / /[app path]/[app name].wsgi

       #WSGIRestrictStdout Off

       <Directory /[app path] >

               WSGIProcessGroup [app name]

               WSGIApplicationGroup %{GLOBAL}

               WSGIScriptReloading On

               #Options Includes ExecCGI

               #AllowOverride None

               Order allow,deny

               Allow from all

       </Directory>

</VirtualHost>


4. Apache restart

반응형