apache-python3.conf 2.46 KB
# Apache virtual host conf file for Heliopropa web-app
#
# Will map a server name and an url to the wsgi script.
# 
# Allows to use a python virtualenvironment thanks to two WSGIDaemonProcess
# attributes:
#     python-home
#     python-path


# Edit Configuration
#
Define flaskapp_path  /home/richard/00DEV/SPACEWEATHERONLINE
Define flaskapp_wsgiscript  heliopropa.wsgi
Define flaskapp_server_name heliopropa
Define flaskapp_server_addr 127.0.0.1
Define flaskapp_subdir /
Define flaskapp_user www-data
Define flaskapp_group www-data

# Warning:
# --------
#
# Stdout/Stderr wont be logged in per virtualhost log files.
#
# 1- Unsuccessfull tries to fix it:
# 
# WSGIRestrictEmbedded On
# WSGIRestrictStdout Off
#
# 2- what works is to comment out ErrorLog, TransferLog and CustomLog
#    and let apache log everything in global log files
#
# 3- However you should prefer to manage your own log system from inside web-app
#
#
<VirtualHost ${flaskapp_server_addr}:443>
     # Add machine's IP address (use ifconfig command)
     ServerName ${flaskapp_server_name}
     # https stuf
     #SSLEngine on
     #SSLProtocol all -SSLv2
     #SSLCertificateFile /etc/pki/tls/certs/localhost.crt
     #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
     # Give an alias to to start your website url with
     DocumentRoot ${flaskapp_path}
     LogLevel warn
     LogFormat "%a %l %u %t \"%r\" %>s %b"
     #
     # Virtualhost log config doesnt show stdout/err see before
     # ErrorLog  ${flaskapp_path}/flaskapp-error.log
     # TransferLog ${flaskapp_path}/flaskapp-access.log
     # CustomLog  ${flaskapp_path}/flaskapp-custom.log combined

     # python-home is the virtual env path
     # python-path sets the PYTHON_PATH for modules import
     WSGIDaemonProcess ${flaskapp_server_name} \
                        user=${flaskapp_user} group=${flaskapp_user} \
                        processes=2 threads=5 \
                        python-home=${flaskapp_path}/venv \
                        python-path=${flaskapp_path} \
                        display-name=%{GROUP}
     WSGIScriptAlias /${flaskapp_subdir} ${flaskapp_path}/${flaskapp_wsgiscript}
     WSGIProcessGroup ${flaskapp_server_name}
     WSGIApplicationGroup %{GLOBAL}
     <Directory  ${flaskapp_path}>
            # set permissions as per apache2.conf file
            Options -Indexes -MultiViews +FollowSymLinks
            AllowOverride All
            Require all granted
     </Directory>
</VirtualHost>



# vim: tabstop=4 sw=4 et tw=0