|
| 1 | +# Setup |
| 2 | + |
| 3 | +## Setup with Apache2 |
| 4 | +1. Install mod_python for Apache2 webserver |
| 5 | + |
| 6 | +1. Install required Python modules |
| 7 | + * git -- (https://pypi.python.org/pypi/GitPython) |
| 8 | + * BeautifulSoup -- (https://pypi.python.org/pypi/BeautifulSoup) |
| 9 | + * markdown2 -- (https://pypi.python.org/pypi/markdown2) |
| 10 | + |
| 11 | + Example on a Debian 9 system: |
| 12 | + |
| 13 | + ``` |
| 14 | + apt-get install python-git python-beautifulsoup |
| 15 | + apt-get install pip python-setuptools |
| 16 | + pip install markdown2 |
| 17 | + ``` |
| 18 | + |
| 19 | +1. Clone gitblog.py as webroot on your server |
| 20 | + |
| 21 | + ``` |
| 22 | + INSTALL_DIR=/var/www/gitblog.py |
| 23 | + git clone https://github.com/pecharmin/gitblog.py.git $INSTALL_DIR |
| 24 | + # Checkout a reference you would like to run |
| 25 | + cd $INSTALL_DIR |
| 26 | + git checkout stable # <-- or whatever reference you prefer |
| 27 | + ``` |
| 28 | + |
| 29 | +1. Setup a git bare repository on your server and push your local content to it |
| 30 | + |
| 31 | + ``` |
| 32 | + BLOG_DOMAIN=gitblog.tld |
| 33 | + mkdir -p /var/git |
| 34 | + git init --bare /var/git/${BLOG_DOMAIN}.git |
| 35 | + ``` |
| 36 | + |
| 37 | +1. Ensure that the run-user of the Apache2 Webserver is able to read |
| 38 | + the git repository (and not be able to write to it). |
| 39 | + |
| 40 | +1. Setup a local git repository on your desktop and create a directory structure |
| 41 | + |
| 42 | + ``` |
| 43 | + BLOG_DOMAIN=gitblog.tld |
| 44 | + # cd wherever you place your git repositories |
| 45 | + git init $BLOG_DOMAIN |
| 46 | + cd $BLOG_DOMAIN |
| 47 | + echo '# Hello World' > hello |
| 48 | + git add hello |
| 49 | + git commit -m 'First git blog entry' |
| 50 | + git remote add origin ssh://user@webserver:22/var/git/gitblog.tld.git |
| 51 | + git push -u origin master |
| 52 | + ``` |
| 53 | + |
| 54 | +1. Create a virtual host for your webserver configuration |
| 55 | + |
| 56 | + ``` |
| 57 | + <VirtualHost *:80> |
| 58 | + ServerName gitblog.tld |
| 59 | + |
| 60 | + |
| 61 | + LogLevel warn |
| 62 | + ErrorLog /var/log/apache2/error_log-%{SERVER_NAME} |
| 63 | + CustomLog /var/log/apache2/access_log-%{SERVER_NAME} vhost |
| 64 | + |
| 65 | + DocumentRoot /var/www/gitblog.py |
| 66 | + |
| 67 | + <Location /> |
| 68 | + Require all granted |
| 69 | + SetHandler mod_python |
| 70 | + PythonHandlerModule gitblog |
| 71 | + PythonPath "sys.path + ['/var/www/gitblog.py']" # <-- adjust here |
| 72 | + PythonOptimize On |
| 73 | + PythonAutoReload Off |
| 74 | + PythonDebug Off |
| 75 | + PythonOption gitblog.wwwroot /var/git/gitblog.tld.git # <-- adjust here |
| 76 | + #PythonOption gitblog.footer False |
| 77 | + </Location> |
| 78 | + |
| 79 | + # Compress output by filter |
| 80 | + <IfModule mod_deflate.c> |
| 81 | + SetOutputFilter DEFLATE |
| 82 | + </IfModule> |
| 83 | + |
| 84 | + # Cache website responses |
| 85 | + <IfModule mod_cache.c> |
| 86 | + <IfModule mod_disk_cache.c> |
| 87 | + CacheRoot /var/cache/apache2/gitblog.tld/ |
| 88 | + CacheEnable disk / |
| 89 | + CacheDirLevels 5 |
| 90 | + CacheDirLength 3 |
| 91 | + </IfModule> |
| 92 | + </IfModule> |
| 93 | + </VirtualHost> |
| 94 | + ``` |
| 95 | + |
| 96 | +## gitblog configuration options |
| 97 | + |
| 98 | +The behavior of gitblog.py can be configured by passing key/value pairs |
| 99 | +from Apache2 using PythonOption directives: |
| 100 | + |
| 101 | +| Option name | Default | Description | Possible values | |
| 102 | +|-----------------------------|------------------------|---------------------------------------------|-----------------------| |
| 103 | +| gitblog.report_errors | False | Should errors be returned to users? | Boolean | |
| 104 | +| gitblog.www_repo | /dev/null | Path to the content git base repository | Filesystem path | |
| 105 | +| gitblog.default_ref | HEAD | Default git reference to display | Any git reference | |
| 106 | +| gitblog.default_output_type | html | Output format for called site | html, plain, markdown | |
| 107 | +| gitblog.footer | True | Display footer meta information | Boolean | |
| 108 | +| gitblog.date_format | %Y-%m-%d %H:%M | Date format in footer | String, see datetime | |
| 109 | +| gitblog.markdown2_extras | toc | Extra options when parsing content source | Array, see markdown2 | |
| 110 | +| gitblog.max_age_blob | 1800 | Cache-Control max-age for non-text elements | Integer | |
| 111 | +| gitblog.max_age_tree | 600 | Cache-Control max-age for directory lising | Integer | |
| 112 | +| gitblog.denied_path | [ private, templates ] | Paths not to deliver (without leeding /) | Array[String] | |
| 113 | +| gitblog.redirect_code | HTTP_MOVED_PERMANENTLY | HTTP response code for redirects on links | HTTP_MOVED_PERMANENTLY, HTTP_MOVED_TEMPORARILY, HTTP_TEMPORARY_REDIRECT | |
0 commit comments