Flask                
            mod_wsgiを使ったApacheのFlask
        
        
            
    サーチ…
WSGIアプリケーションラッパー
多くのFlaskアプリケーションは、システム全体のPythonインストールとは別に各アプリケーションの依存関係を保持するためにvirtualenvで開発されています。 moden-wsgiがあなたのvirtualenvにインストールされていることを確認してください:
pip install mod-wsgi
次にFlaskアプリケーション用のwsgiラッパーを作成します。通常、アプリケーションのルートディレクトリに保存されます。
my-application.wsgi
activate_this = '/path/to/my-application/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/path/to/my-application')
from app import app as application
このラッパーは、Apacheから実行されたときに仮想環境とインストールされているすべてのモジュールと依存関係を有効にし、アプリケーションパスが検索パスの最初にあることを確認します。慣例により、WSGIアプリケーションオブジェクトはapplicationと呼ばれapplication 。 
WSGI用のApacheサイト対応構成
組み込みのwerkzeugサーバー上でApacheを使用する利点は、Apacheがマルチスレッド化されていることです。つまり、アプリケーションへの複数の接続を同時に行うことができます。これは、フロントエンドでXmlHttpRequest (AJAX)を使用するアプリケーションで特に役立ちます。
/etc/apache2/sites-available/050-my-application.conf (または共有Webサーバ上でホストされていない場合はデフォルトのApache設定)
<VirtualHost *:80>
        ServerName my-application.org
        ServerAdmin [email protected]
        # Must be set, but can be anything unless you want to serve static files
        DocumentRoot /var/www/html
        # Logs for your application will go to the directory as specified:
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # WSGI applications run as a daemon process, and need a specified user, group
        # and an allocated number of thread workers. This will determine the number
        # of simultaneous connections available.
        WSGIDaemonProcess my-application user=username group=username threads=12
        
        # The WSGIScriptAlias should redirect / to your application wrapper:
        WSGIScriptAlias / /path/to/my-application/my-application.wsgi
        # and set up Directory access permissions for the application:
        <Directory /path/to/my-application>
                WSGIProcessGroup my-application
                WSGIApplicationGroup %{GLOBAL}
                
                AllowOverride none
                Require all granted
        </Directory>
</VirtualHost>
Modified text is an extract of the original Stack Overflow Documentation
        ライセンスを受けた CC BY-SA 3.0
        所属していない Stack Overflow