mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 04:31:49 +02:00
Add the possibilty to run ihatemoney via Apache mod_wsgi
ihatemoney.wsgi is the entry point for mod_wsgi. A virtualenv can be activated if its path is specified as an env var in the apache virtual host file
This commit is contained in:
parent
bf2c11f8a9
commit
69116884b9
3 changed files with 56 additions and 1 deletions
26
README.rst
26
README.rst
|
@ -33,7 +33,31 @@ You can also set the `TESTING` flag to `True` so no mails are sent
|
|||
Deploy it
|
||||
=========
|
||||
|
||||
To deploy it, I'm using gunicorn and supervisord.
|
||||
With Apache and mod_wsgi
|
||||
------------------------
|
||||
|
||||
1. Install Apache and mod_wsgi::
|
||||
|
||||
$ sudo apt-get install apache2
|
||||
# If you use Python3
|
||||
$ sudo apt-get install libapache2-mod-wsgi-py3
|
||||
# Or if you use Python2
|
||||
$ sudo apt-get install libapache2-mod-wsgi
|
||||
|
||||
2. Create an Apache virtual host based on the sample configuration file
|
||||
|
||||
$ sudo cp conf/apache-vhost.conf /etc/apache2/sites-available/ihatemoney.conf
|
||||
|
||||
3. Adapt it to your paths and specify your virtualenv path if you use one
|
||||
|
||||
4. Activate the virtual host and reload Apache ::
|
||||
|
||||
$ sudo a2ensite ihatemoney
|
||||
$ sudo service apache2 restart
|
||||
|
||||
|
||||
With Nginx, Gunicorn and Supervisord
|
||||
------------------------------------
|
||||
|
||||
1. Add the lines in conf/supervisord.conf to your supervisord.conf file.
|
||||
**adapt them to your paths!**
|
||||
|
|
17
conf/apache-vhost.conf
Normal file
17
conf/apache-vhost.conf
Normal file
|
@ -0,0 +1,17 @@
|
|||
<VirtualHost *:80>
|
||||
# Uncomment the following line if you use a virtualenv
|
||||
# SetEnv IHATEMONEY_VENV_PATH /path/to/your/venv
|
||||
ServerAdmin admin@example.com
|
||||
ServerName ihatemoney.example.com
|
||||
WSGIDaemonProcess ihatemoney user=www-data group=www-data threads=5
|
||||
WSGIScriptAlias / /path/to/ihatemoney/ihatemoney.wsgi
|
||||
ErrorLog /var/log/apache2/ihatemoney.example.com_error.log
|
||||
CustomLog /var/log/apache2/ihatemoney.example.com_access.log combined
|
||||
<Directory /path/to/ihatemoney>
|
||||
WSGIProcessGroup ihatemoney
|
||||
WSGIApplicationGroup %{GLOBAL}
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Directory>
|
||||
Alias /static/ /path/to/ihatemoney/budget/static/
|
||||
</VirtualHost>
|
14
ihatemoney.wsgi
Normal file
14
ihatemoney.wsgi
Normal file
|
@ -0,0 +1,14 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
__HERE__ = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Wrapper around application to get the env var set by Apache
|
||||
def application(environ, start_response):
|
||||
if environ.get('IHATEMONEY_VENV_PATH'):
|
||||
activate_this = os.path.join(environ.get('IHATEMONEY_VENV_PATH'), 'bin/activate_this.py')
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
# Add the budget directory to the path so we can then import from run
|
||||
sys.path.insert(0, os.path.join(__HERE__, 'budget'))
|
||||
from run import app as _application
|
||||
return _application(environ, start_response)
|
Loading…
Reference in a new issue