Python Flask (web framework) deployed with Apache
For a quick demo, you can use a pre-built docker image:
docker run -d -p 80:80 muneeb/apache-flask
The test page should be viewable on http://localhost. For Mac OS X, use boot2docker to get the IP of your VM:
boot2docker ip
And then view the test page at http://IP_FROM_BOOT2DOCKER e.g., http://192.168.59.103/
-
Fork this repo
-
Clone your own version
git clone git@github.com:YOUR_GITHUB_USERNAME/apache-flask.git
-
Make any modifications and commit them to github
-
Edit the apache-flask/image/Dockerfile to use your fork i.e.,
replace 'RUN git clone https://github.com/muneeb-ali/apache-flask.git /srv/www/app'
with 'RUN git clone https://github.com/YOUR_GITHUB_USERNAME/apache-flask.git /srv/www/app'
- Build the new docker image
cd apache-flask/image
docker build -t=YOUR_TAG .
- Run your new image similar to instructions above, replacing muneeb/apache-flask with YOUR_TAG
-
fork this repo
-
clone your own version
git clone git@github.com:YOUR_GITHUB_USERNAME/apache-flask.git
cd apache-flask
- install all the necessary packages (best done inside of a virtual environment)
pip install -r requirements.txt
- run the app
python runserver.py
- check out the test page and make your modifications
These instructions are for Debian, for other Linux flavors modify the Apache parts accordingly
Make sure apache2 and mod_wsgi are installed
sudo apt-get install -y apache2
sudo apt-get install -y libapache2-mod-wsgi
sudo apt-get install -y apache2-utils
For this examples, we assume your app is in /srv/www/app. In /etc/apache2/sites-available/000-default.conf file add:
ServerName 0.0.0.0
<VirtualHost _default_:80>
DocumentRoot /srv/www/app
WSGIDaemonProcess python-app user=www-data group=www-data threads=15 maximum-requests=10000 python-path=/usr/local/lib/python2.7/dist-packages
WSGIScriptAlias / /srv/www/app/apache/apache.wsgi
WSGIProcessGroup python-app
CustomLog "|/usr/bin/rotatelogs /srv/www/app/apache/logs/access.log.%Y%m%d-%H%M%S 5M" combined
ErrorLog "|/usr/bin/rotatelogs /srv/www/app/apache/logs/error.log.%Y%m%d-%H%M%S 5M"
LogLevel warn
<Directory /srv/www/app>
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>