아미(아름다운미소)

[python] Flask WSGI 어플리케이션 본문

랭귀지/python

[python] Flask WSGI 어플리케이션

유키공 2017. 12. 29. 10:30

- flask소스를 올릴 폴더생성 및 권한부여

$sudo mkdir miniblog
$sudo chmod -R 775 /home/pi/WWW/miniblog
$sudo chown -R pi:www-data /home/pi/WWW/miniblog

- flask를 구동하기 위한 필수라이브러리 설치
$sudo apt-get update
$sudo apt-get upgrade
$sudo apt-get install apache2 libapache2-mod-wsgi python-setuptools python-flask
$sudo apt-get install libapache2-mod-wsgi

- 포트추가변경
$sudo nano /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 7777

        Listen 443



        Listen 443


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

- 홈디렉토리변경
$sudo nano /etc/apache2/apache2.conf

        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted


- wsgi파일 만들고(miniblog.wsgi)
import sys
sys.path.insert(0, '/home/pi/WWW/miniblog')
from miniblog import app as application
$sudo nano /etc/apache2/sites-available/miniblog.conf
- 아파치환경파일 수정
#Listen 7777
ServerName www.todaymart.com

        ServerAdmin ljj777@naver.com
        DocumentRoot /home/pi/WWW/miniblog
#       DirectoryIndex index.php index.html

#       WSGIDaemonProcess miniblog user=pi group=www-data threads=5
        WSGIDaemonProcess miniblog threads=5
#       WSGIProcessGroup miniblog
        WSGIScriptAlias / /home/pi/WWW/miniblog/miniblog.wsgi
#       WSGIScriptAlias /miniblog /home/pi/WWW/miniblog/miniblog.wsgi

        
                WSGIProcessGroup miniblog
                WSGIApplicationGroup %{GLOBAL}
              # WSGIScriptReloading On
                Order deny,allow
                Allow from all
              # Require all granted
        
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

-가상 호스트를 활성화 후 아파치 reload
$sudo a2ensite miniblog
$sudo /etc/init.d/apache2 reload



Comments