webserver.rst 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .. _webserver:
  2. Integration with a Web Server
  3. =============================
  4. .. _apache_webserver:
  5. Apache2
  6. -------
  7. Distro Tracker can be deployed as any other Django project on Apache. For more information
  8. you can see the following
  9. `link <https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/>`_.
  10. After installing mod_wsgi, a minimal configuration would be to include a new
  11. file in sites-available with the following settings::
  12. WSGIDaemonProcess distro_tracker.some.domain python-path=/path/to/distro_tracker user=distro-tracker group=distro-tracker home=/ processes=4 threads=5 maximum-requests=5000 inactivity-timeout=1800 umask=0007 display-name=wsgi-distro_tracker.some.domain
  13. <VirtualHost *:80>
  14. ServerAdmin owner@distro_tracker.some.domain
  15. ServerName distro_tracker.some.domain
  16. DocumentRoot /path/to/assets/
  17. # To make sure all static file assets with no extension
  18. # (such as extracted source files) have the correct Content-Type
  19. DefaultType text/plain
  20. AddDefaultCharset utf-8
  21. ErrorLog ${APACHE_LOG_DIR}/distro_tracker.some.domain-error.log
  22. LogLevel warn
  23. CustomLog ${APACHE_LOG_DIR}/distro_tracker.some.domain-access.log combined
  24. WSGIScriptAlias / /path/to/distro_tracker/project/wsgi.py
  25. WSGIProcessGroup distro_tracker.some.domain
  26. Alias /static/ /path/to/assets/static/
  27. Alias /media/ /path/to/assets/media/
  28. <Directory /path/to/distro_tracker/project>
  29. <Files wsgi.py>
  30. Order allow,deny
  31. Allow from all
  32. </Files>
  33. </Directory>
  34. <Directory /path/to/assets/static>
  35. Order deny,allow
  36. Allow from all
  37. </Directory>
  38. </VirtualHost>
  39. .. note::
  40. Notice the placeholder paths which need to be set according to the local
  41. file system.
  42. .. note::
  43. In this case, the same Web server serves both the static files and runs the
  44. Django app.
  45. nginx and Gunicorn
  46. ------------------
  47. Distro Tracker does not include gunicorn in its
  48. :data:`INSTALLED_APPS <distro_tracker.project.settings.INSTALLED_APPS>`, but there is
  49. nothing to prevent users to include it and deploy it with gunicorn
  50. running as the WSGI server and a reverse proxy in front of it.
  51. Static Assets
  52. -------------
  53. When serving `distro-tracker` with a web server, the static assets like images,
  54. Javascript and CSS files should be moved to the directory given in the
  55. ``STATIC_ROOT`` setting. Running the following management command will move all
  56. static resources that Django uses to the correct directory::
  57. $ ./manage.py collectstatic