install.rst 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. Installing pagure
  2. =================
  3. There are two ways to install pagure:
  4. * via the RPM package (recommanded if you are using a RPM-based 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`` automatint 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 files 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 an example WSGI file at:
  103. ``/usr/share/pagure/pagure.wsgi`` and ``/usr/share/pagure/docs_pagure.wsgi``
  104. 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. To create the database tables, you need to run the script
  138. ``/usr/share/pagure/pagure_createdb.py`` and specify it the configuration
  139. file to use via an environment variable.
  140. For example:
  141. ::
  142. PAGURE_CONFIG=/etc/pagure/pagure.cfg python /usr/share/pagure/pagure_createdb.py
  143. This will tell ``/usr/share/pagure/pagure_createdb.py`` to use the database
  144. information specified in the file ``/etc/pagure/pagure.cfg``.
  145. .. warning:: Pagure's default configuration is using sqlite. This is fine
  146. for development purpose but not for production use as sqlite does
  147. not support all the operations needed when updating the database
  148. schema. Do use PostgreSQL, MySQL or MariaDB in production.
  149. * Stamp the alembic revision
  150. For changes to existing tables, we rely on `Alembic <http://alembic.readthedocs.org/>`_.
  151. It uses `revisions` to perform the upgrades, but to know which upgrades are
  152. needed and which are already done, the current revision needs to be saved
  153. in the database. This will allow alembic to know apply the new revision when
  154. running it.
  155. You can save the current revision in the database using the following command:
  156. ::
  157. cd /etc/pagure
  158. alembic stamp $(alembic heads |awk '{ print $1 }')
  159. The ``cd /etc/pagure`` is needed as the command must be run in the folder
  160. where the file ``alembic.ini`` is. This file contains two important pieces
  161. of information:
  162. * ``sqlalchemy.url`` which is the URL used to connect to the database, likely
  163. the same URL as the one in ``pagure.cfg``.
  164. * ``script_location`` which is the path to the ``versions`` folder containing
  165. all the alembic migration files.
  166. The ``alembic stamp`` command is the one actually saving the current revision
  167. into the database. This current revision is found using ``alembic heads``
  168. which returns the most recent revision found by alembic, and since the
  169. database was just created, it is at the latest revision.