install.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. Installing pagure
  2. =================
  3. There are two ways to install pagure:
  4. * via the RPM package (recommended if you are using a RPM-based GNU/Linux distribution)
  5. * via the setup.py
  6. Installing pagure via RPM
  7. -------------------------
  8. Here as well there are two ways of obtaining the RPM:
  9. * From the main repositories
  10. Pagure is packaged for Fedora since Fedora 21 and is available for RHEL and
  11. its derivative via the `EPEL repository <https://fedoraproject.org/wiki/EPEL>`.
  12. So installing it is as easy as:
  13. ::
  14. dnf install pagure pagure-milters pagure-ev pagure-webhook
  15. or
  16. ::
  17. yum install pagure pagure-milters pagure-ev pagure-webhook
  18. The ``pagure`` package contains the core of the application and the doc server.
  19. (See the ``Overview`` page for a global overview of the structure of the
  20. project).
  21. The ``pagure-milters`` package contains, as the name says, the milter (a
  22. mail filter to hook into a MTA).
  23. The ``pagure-ev`` package contains the eventsource server.
  24. The ``pagure-webhook`` package contains the web-hook server.
  25. .. note:: The last three packages are optional, pagure would work fine without
  26. them but the live-update, the webhook and the comment by email
  27. services will not work.
  28. * From the sources
  29. If you wish to run a newer version of pagure than what is in the repositories
  30. you can easily rebuild it as RPM.
  31. Simply follow these steps:
  32. # Clone the sources::
  33. git clone https://pagure.io/pagure.git
  34. # Go to the folder::
  35. cd pagure
  36. # Build a tarball of the latest version of pagure::
  37. python setup.py sdist
  38. # Build the RPM::
  39. rpmbuild -ta dist/pagure*.tar.gz
  40. This will build pagure from the version present in your clone.
  41. Once, the RPM is installed the services ``pagure_milter`` and ``pagure_ev``
  42. are ready to be used but the database and the web-application parts still
  43. need to be configured.
  44. Installing pagure via setup.py
  45. ------------------------------
  46. Pagure includes in its sources a ``setup.py`` automating the installation
  47. of the web applications of pagure (ie: the core + the doc server).
  48. To install pagure via this mechanism simply follow these steps:
  49. # Clone the sources::
  50. git clone https://pagure.io/pagure.git
  51. # Go to the folder::
  52. cd pagure
  53. # Install the latest version of pagure::
  54. python setup.py build
  55. sudo python setup.py install
  56. .. note:: To install the eventsource server or the milter, refer to their
  57. respective documentations.
  58. # Install the additional files as follow:
  59. +------------------------------+------------------------------------------+
  60. | Source | Destination |
  61. +=============================+===========================================+
  62. | ``files/pagure.cfg.sample`` | ``/etc/pagure/pagure.cfg`` |
  63. +------------------------------+------------------------------------------+
  64. | ``files/alembic.ini`` | ``/etc/pagure/alembic.ini`` |
  65. +------------------------------+------------------------------------------+
  66. | ``files/pagure.conf`` | ``/etc/httpd/conf.d/pagure.conf`` |
  67. +------------------------------+------------------------------------------+
  68. | ``files/pagure.wsgi`` | ``/usr/share/pagure/pagure.wsgi`` |
  69. +------------------------------+------------------------------------------+
  70. | ``createdb.py`` | ``/usr/share/pagure/pagure_createdb.py`` |
  71. +------------------------------+------------------------------------------+
  72. Set-up pagure
  73. -------------
  74. Once pagure's files are installed, you still need to set up some things.
  75. * Create the folder release
  76. This folder is used by project maintainers to upload the tarball of the
  77. releases of their project.
  78. This folder must be accessible by the user under which the application is
  79. running (in our case: ``git``).
  80. ::
  81. mkdir -p /var/www/releases
  82. chown git:git /var/www/releases
  83. * Create the folders where the repos, forks and checkouts will be stored
  84. Pagure stores the sources of a project in a git repo, offers a place to
  85. store the project's documentation in another repo, stores a JSON dump of all
  86. issues and of all pull-requests in another two repos, and keeps a local
  87. checkout of remote projects when asked to do remote pull-requests.
  88. All these repositories are stored in different folders that must be
  89. created manually.
  90. For example you can place them under ``/srv/git/repositories/`` which would
  91. make ``/srv/git`` the home of your gitolite user.
  92. You would then create the folders with:
  93. ::
  94. mkdir /srv/git/repositories/{docs,forks,tickets,requests,remotes}
  95. * Configure apache
  96. If installed by RPM, you will find an example apache configuration file
  97. at: ``/etc/httpd/conf.d/pagure.conf``.
  98. If not installed by RPM, the example file is present in the sources at:
  99. ``files/pagure.conf``.
  100. Adjust it for your needs.
  101. * Configure the WSGI file
  102. If you installed by RPM, you will find example WSGI files at:
  103. ``/usr/share/pagure/pagure.wsgi`` for the core server and
  104. ``/usr/share/pagure/doc_pagure.wsgi`` for the doc server.
  105. If you did not install by RPM, these files are present in the sources at:
  106. ``files/pagure.wsgi`` and ``files/doc_pagure.wsgi``.
  107. Adjust them for your needs
  108. * Give apache permission to read the repositories owned by the ``git`` user.
  109. For the sake of this document, we assume that the web application runs under
  110. the ``git`` user, the same user as your gitolite user, but apache itself
  111. runs under the ``httpd`` (or ``apache2``) user. So by default, apache
  112. will not be allowed to read git repositories created and managed by gitolite.
  113. To give apache this permission (required to make git clone via http work),
  114. we use file access control lists (aka FACL):
  115. ::
  116. setfacl -m user:apache:rx --default
  117. setfacl -Rdm user:apache:rx /srv/git
  118. setfacl -Rm user:apache:rx /srv/git
  119. Where ``/srv/git`` is the home of your gitolite user (which will thus need
  120. to be adjusted for your configuration).
  121. * Set up the configuration file of pagure
  122. This is an important step which concerns the file ``/etc/pagure/pagure.cfg``.
  123. If you have installed pagure by RPM, this file is already there, otherwise
  124. you can find an example one in the sources at: ``files/pagure.cfg.sample``
  125. that you will have to copy to the right location.
  126. Confer the ``Configuration`` section of this documentation for a full
  127. explanation of all the options of pagure.
  128. * Create the database
  129. You first need to create the database itself. For this, since pagure can
  130. work with: `PostgreSQL <http://www.postgresql.org/>`_,
  131. `MySQL <http://www.mysql.com/>`_ or `MariaDB <http://mariadb.org/>`_, we
  132. would like to invite you to consult the documentation of your database system
  133. for this operation.
  134. Once you have specified in the configuration file the to url used to connect
  135. to the database, and create the database itself, you can now create the
  136. tables, the database scheme.
  137. For changes to existing tables, we rely on `Alembic <http://alembic.readthedocs.org/>`_.
  138. It uses `revisions` to perform the upgrades, but to know which upgrades are
  139. needed and which are already done, the current revision needs to be saved
  140. in the database. This will allow alembic to know and apply the new revision
  141. when running it.
  142. In the ``alembic.ini`` file, one of the configuration key is most important:
  143. ``script_location`` which is the path to the ``versions`` folder containing
  144. all the alembic migration files. The ``sqlalchemy.url`` configuration key if
  145. missing will be replaced by the url filled in the configuration file of
  146. pagure.
  147. To create the database tables, you need to run the script
  148. ``/usr/share/pagure/pagure_createdb.py`` and specify the configuration
  149. to use for pagure and for alembic.
  150. For example:
  151. ::
  152. python /usr/share/pagure/pagure_createdb.py -c /etc/pagure/pagure.cfg -i /etc/pagure/alembic.ini
  153. This will tell ``/usr/share/pagure/pagure_createdb.py`` to use the database
  154. information specified in the file ``/etc/pagure/pagure.cfg`` and to stamp
  155. the database at the last alembic revision.
  156. .. warning:: Pagure's default configuration is using sqlite. This is fine
  157. for development purpose but not for production use as sqlite does
  158. not support all the operations needed when updating the database
  159. schema. Do use PostgreSQL, MySQL or MariaDB in production.
  160. For changes to existing tables, we rely on `Alembic <http://alembic.readthedocs.org/>`_.
  161. It uses `revisions` to perform the upgrades, but to know which upgrades are
  162. needed and which are already done, the current revision needs to be saved
  163. in the database. This will allow alembic to know apply the new revision when
  164. running it.
  165. In the ``alembic.ini`` file, one of the configuration key is most important:
  166. ``script_location`` which is the path to the ``versions`` folder containing
  167. all the alembic migration files. The ``sqlalchemy.url`` configuration key if
  168. missing will be replaced by the url filled in the configuration file of
  169. pagure.
  170. .. warning:: Calling ``pagure_createdb.py`` is asked regularly in the
  171. UPGRADING.rst documentation, especially to handle database schema
  172. changes upon upgrades, but the ``--initial`` argument should only
  173. be used the first time as it will otherwise break upgrading the
  174. database schema via alembic.
  175. .. note:: When install from source the script is called ``createdb.py`` and
  176. not ``pagure_createdb.py``.
  177. Set up virus scanning
  178. ---------------------
  179. Pagure can automatically scan uploaded attachments for viruses using Clam.
  180. To set this up, first install clamav-data-empty, clamav-server,
  181. clamav-server-systemd and clamav-update.
  182. Then edit /etc/freshclam.conf, removing the Example line and run freshclam once
  183. to get an up to date database.
  184. Copy /usr/share/doc/clamav-server/clamd.conf to /etc/clamd.conf and edit that
  185. too, again making sure to remove the Example line. Make sure to set LocalSocket
  186. to a file in a directory that exists, and set User to an existing system user.
  187. Then start the clamd service and set VIRUS_SCAN_ATTACHMENTS = True in the
  188. Pagure configuration.