1 ************************************
2 phorkie - PHP and Git based pastebin
3 ************************************
4 Self-hosted pastebin software written in PHP.
5 Pastes are editable, may have multiple files and are stored in git repositories.
7 Project page: http://sourceforge.net/p/phorkie/
9 .. contents:: Table of Contents
14 - every paste is a git repository
16 - repositories can be cloned
17 - clone url can be displayed
18 - remote pastes can be forked (rel="vcs-git" and gist.github.com)
19 - single click forking of forks on different servers to your own
23 - delete existing files
24 - replace file with upload
25 - multiple files in one paste
26 - syntax highlighting with GeSHi
27 - rST and Markdown rendering
28 - image upload + display
29 - OpenID authentication
30 - external tool support
34 - history in the sidebar
36 - old files can be downloaded easily
37 - search across pastes: description, file names and file content
39 - options: quoting, logical and, or, not, partial words
40 - webhook support - get notified when pastes are created, edited or deleted
41 - atom feed for new and updated pastes
42 - notifies remote instances via linkbacks when a paste has been forked
51 Download ``phorkie-0.4.0.phar`` and put it in your web server's document root
54 No further setup needed.
56 .. note:: Only valid if your webserver is configured to let
57 PHP handle ``.phar`` files.
59 Unfortunately, no Linux distribution has this activated by default.
61 .. warning:: PHP has some bugs in its .phar handling code (e.g. with FPM).
63 So currently, the ``.phar`` option is considered experimental.
68 1. Unzip the phorkie release file::
70 $ tar xjvf phorkie-0.4.0.tar.bz2
72 2. Create the git directories::
74 $ mkdir -p www/repos/git www/repos/work
75 $ chmod og+w www/repos/git www/repos/work
77 3. Install dependencies_
79 4. Copy ``data/config.php.dist`` to ``data/config.php`` and adjust it
82 $ cp data/config.php.dist data/config.php
83 $ $EDITOR data/config.php
85 Look at ``config.default.php`` for values that you may adjust.
87 5. Set your web server's document root to ``/path/to/phorkie/www/``
88 Alternatively, you can add a symlink to the ``www`` folder into your
89 web server's existing document root tree (being careful to keep
90 main phorkie folder outside the document root for security purposes)
91 and ensure you set the ``baseurl`` config option appropriately. You
92 must also set the ``RewriteBase`` in the ``.htaccess`` file or adjust
93 the nginx configuration accordingly.
95 6. Open http://yourhost/setup in your web browser to see if everything
98 7. Go to http://yourhost/
103 phorkie stands on the shoulders of giants.
105 It requires the following programs to be installed
108 - Git v1.7.5 or later
109 - PHP v5.3.0 or later
110 - PEAR v1.9.2 or later
114 $ pear install versioncontrol_git-alpha
115 $ pear install services_libravatar-alpha
116 $ pear install http_request2
118 $ pear install date_humandiff-alpha
119 $ pear install openid-alpha
121 $ pear channel-discover pear.twig-project.org
122 $ pear install twig/Twig
124 $ pear channel-discover pear.geshi.org
125 $ pear install geshi/geshi
127 $ pear channel-discover zustellzentrum.cweiske.de
128 $ pear install zz/mime_type_plaindetect-alpha
130 $ pear channel-discover pear.michelf.ca
131 $ pear install michelf/Markdown
133 $ pear channel-discover pear2.php.net
134 $ pear install pear2/pear2_services_linkback-alpha
137 You can use composer to install all dependencies automatically::
141 Note that the ``.phar`` package already contains all dependencies.
148 phorkie makes use of an Elasticsearch__ installation, if you have one.
150 It is used to provide search capabilities and the list of recent pastes.
152 __ http://www.elasticsearch.org/
157 Edit ``config.php``, setting the ``elasticsearch`` property to the HTTP URL
158 of the index, e.g. ::
160 http://localhost:9200/phorkie/
162 You must use a search namespace with Elasticsearch such as ``phorkie/``.
163 Run the index script to import all existing pastes into the index::
165 php scripts/index.php
167 That's all. Open phorkie in your browser, and you'll notice the search box
173 In case something really went wrong and you need to reset the search
174 index, run the following command::
176 $ curl -XDELETE http://localhost:9200/phorkie/
177 {"ok":true,"acknowledged"}
179 Phorkie will automatically re-index everything when ``setupcheck`` is enabled
180 in the configuration file.
182 You may also manually run the reindexing script with::
184 $ php scripts/index.php
191 Make git repositories clonable
192 ==============================
196 By default, the pastes are clonable via ``http`` as long as the ``repos/git/``
197 directory is within the ``www/`` directory.
199 No further setup needed.
204 You may use ``git-daemon`` to provide public ``git://`` clone urls.
205 Install the ``git-daemon-run`` package on Debian/Ubuntu.
207 Make the repositories available by symlinking the paste repository
208 directory (``$GLOBALS['phorkie']['cfg']['repos']`` setting) into
209 ``/var/cache/git``, e.g.::
211 $ ln -s /home/user/www/paste/repos/git /var/cache/git/paste
213 Edit your ``config.php`` and set the ``$GLOBALS['phorkie']['cfg']['git']['public']``
214 setting to ``git://$yourhostname/git/paste/``.
215 The rest will be appended automatically.
218 You're on your own to setup writable repositories.
221 Protect your site with OpenID
222 =============================
223 You have the option of enabling OpenID authentication to help secure your
225 Set the ``$GLOBALS['phorkie']['auth']`` values in the
226 ``data/config.php`` file as desired.
228 There are two different types of security you can apply.
229 First, you can restrict to one of three ``securityLevels``:
231 - completely open (``0``)
232 - protection of write-enabled functions such as add, edit, etc. (``1``)
233 - full site protection (``2``)
235 Additionally, you can restrict your site to ``listedUsersOnly``.
236 You will need to add the individual OpenID urls to the
237 ``$GLOBALS['phorkie']['auth']['users']`` variable.
240 Get information about paste editors
241 ===================================
242 Phorkie stores the user's OpenID or IP address (when not logged in) when
244 It is possible to get this information for each single commit::
246 // IP / OpenID for the latest commit
247 $ git notes --ref=identity show
250 // show IP / OpenID for a given commit
251 $ git notes --ref=identity show 29f82a
255 Notifications via webhooks
256 ==========================
257 Depending on how you use phorkie, it might be nice to notify some other service
258 when pastes are added or updated.
259 Phorkie contains a simply mechanism to post data to a given URL which
260 you can then use as needed.
262 The data are json-encoded POSTed to the URLs contained in the
263 ``$GLOBALS['phorkie']['cfg']['webhooks']`` setting array, with
264 a MIME type of ``application/vnd.phorkie.webhook+json``::
270 'email': 'anonymous@phorkie',
273 'name': 'webhooktest',
274 'url': 'http://example.org/33',
275 'description': 'webhooktest',
278 'email': 'anonymous@phorkie',
283 The event may be ``create``, ``edit`` or ``delete``.
297 Display page for paste
301 Display raw file contents
302 ``/[0-9]/tool/[a-zA-Z]+/(.+)``
303 Run a tool on the given file
304 ``/[0-9]/rev/[a-z0-9]+``
305 Show specific revision of the paste
309 Show DOAP document for paste
311 Create a fork of the paste
312 ``/search?q=..(&page=[0-9]+)?``
313 Search for term, with optional page
315 List all pastes, with optional page
321 Shows form for new paste
323 Login page for protecting site
325 Check if everything is setup correctly and all dependencies are installed
327 Edit logged-in user information
330 Internal directory layout
331 =========================
336 1/ - work directory for paste #1
337 2/ - work directory for paste #2
339 1.git/ - git repository for paste #1
340 description - Description for the repository
341 2.git/ - git repository for paste #2
345 If you use nginx, place the following lines into your ``server`` block:
349 if (!-e $request_uri) {
350 rewrite ^/([0-9]+)$ /display.php?id=$1;
351 rewrite ^/([0-9]+)/delete$ /delete.php?id=$1;
352 rewrite ^/([0-9]+)/delete/confirm$ /delete.php?id=$1&confirm=1;
353 rewrite ^/([0-9]+)/doap$ /doap.php?id=$1;
354 rewrite ^/([0-9]+)/edit$ /edit.php?id=$1;
355 rewrite ^/([0-9]+)/fork$ /fork.php?id=$1;
356 rewrite ^/([0-9]+)/raw/(.+)$ /raw.php?id=$1&file=$2;
357 rewrite ^/([0-9]+)/rev/(.+)$ /revision.php?id=$1&rev=$2;
358 rewrite ^/([0-9]+)/rev-raw/(.+)$ /raw.php?id=$1&rev=$2&file=$3;
359 rewrite ^/([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3;
361 rewrite ^/fork-remote$ /fork-remote.php;
362 rewrite ^/help$ /help.php;
363 rewrite ^/new$ /new.php;
364 rewrite ^/feed/new$ /feed-new.php;
365 rewrite ^/feed/updated$ /feed-updated.php;
366 rewrite ^/list$ /list.php;
367 rewrite ^/list/([0-9]+)$ /list.php?page=$1;
369 rewrite ^/search$ /search.php;
370 rewrite ^/search/([0-9]+)$ /search.php?page=$1;
372 rewrite ^/login$ /login.php;
373 rewrite ^/setup$ /setup.php;
374 rewrite ^/user$ /user.php;