You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

from-binary.en-us.md 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. ---
  2. date: "2017-06-19T12:00:00+02:00"
  3. title: "Installation from binary"
  4. slug: "install-from-binary"
  5. sidebar_position: 15
  6. toc: false
  7. draft: false
  8. aliases:
  9. - /en-us/install-from-binary
  10. menu:
  11. sidebar:
  12. parent: "installation"
  13. name: "From binary"
  14. sidebar_position: 15
  15. identifier: "install-from-binary"
  16. ---
  17. # Installation from binary
  18. All downloads come with SQLite, MySQL and PostgreSQL support, and are built with
  19. embedded assets. This can be different from Gogs.
  20. ## Download
  21. You can find the file matching your platform from the [downloads page](https://dl.gitea.com/gitea/) after navigating to the version you want to download.
  22. ### Choosing the right file
  23. **For Linux**, you will likely want `linux-amd64`. It's for 64-bit Intel/AMD platforms, but there are other platforms available, including `arm64` (e.g. Raspberry PI 4), `386` (i.e. 32-bit), `arm-5`, and `arm-6`.
  24. **For Windows**, you will likely want `windows-4.0-amd64`. It's for all modern versions of Windows, but there is also a `386` platform available designed for older, 32-bit versions of Windows.
  25. *Note: there is also a `gogit-windows` file available that was created to help with some [performance problems](https://github.com/go-gitea/gitea/pull/15482) reported by some Windows users on older systems/versions. You should consider using this file if you're experiencing performance issues, and let us know if it improves performance.*
  26. **For macOS**, you should choose `darwin-arm64` if your hardware uses Apple Silicon, or `darwin-amd64` for Intel.
  27. **For FreeBSD**, you should choose `freebsd12-amd64` for 64-bit Intel/AMD platforms.
  28. ### Downloading with wget
  29. Copy the commands below and replace the URL within the one you wish to download.
  30. ```sh
  31. wget -O gitea https://dl.gitea.com/gitea/@version@/gitea-@version@-linux-amd64
  32. chmod +x gitea
  33. ```
  34. Note that the above command will download Gitea @version@ for 64-bit Linux.
  35. ## Verify GPG signature
  36. Gitea signs all binaries with a [GPG key](https://keys.openpgp.org/search?q=teabot%40gitea.io) to prevent against unwanted modification of binaries.
  37. To validate the binary, download the signature file which ends in `.asc` for the binary you downloaded and use the GPG command line tool.
  38. ```sh
  39. gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
  40. gpg --verify gitea-@version@-linux-amd64.asc gitea-@version@-linux-amd64
  41. ```
  42. Look for the text `Good signature from "Teabot <teabot@gitea.io>"` to assert a good binary,
  43. despite warnings like `This key is not certified with a trusted signature!`.
  44. ## Recommended server configuration
  45. **NOTE:** Many of the following directories can be configured using [Environment Variables](administration/environment-variables.md) as well!
  46. Of note, configuring `GITEA_WORK_DIR` will tell Gitea where to base its working directory, as well as ease installation.
  47. ### Prepare environment
  48. Check that Git is installed on the server. If it is not, install it first. Gitea requires Git version >= 2.0.
  49. ```sh
  50. git --version
  51. ```
  52. Create a user to run Gitea (e.g. `git`)
  53. ```sh
  54. # On Ubuntu/Debian:
  55. adduser \
  56. --system \
  57. --shell /bin/bash \
  58. --gecos 'Git Version Control' \
  59. --group \
  60. --disabled-password \
  61. --home /home/git \
  62. git
  63. # On Fedora/RHEL/CentOS:
  64. groupadd --system git
  65. adduser \
  66. --system \
  67. --shell /bin/bash \
  68. --comment 'Git Version Control' \
  69. --gid git \
  70. --home-dir /home/git \
  71. --create-home \
  72. git
  73. ```
  74. ### Create required directory structure
  75. ```sh
  76. mkdir -p /var/lib/gitea/{custom,data,log}
  77. chown -R git:git /var/lib/gitea/
  78. chmod -R 750 /var/lib/gitea/
  79. mkdir /etc/gitea
  80. chown root:git /etc/gitea
  81. chmod 770 /etc/gitea
  82. ```
  83. > **NOTE:** `/etc/gitea` is temporarily set with write permissions for user `git` so that the web installer can write the configuration file. After the installation is finished, it is recommended to set permissions to read-only using:
  84. >
  85. > ```sh
  86. > chmod 750 /etc/gitea
  87. > chmod 640 /etc/gitea/app.ini
  88. > ```
  89. If you don't want the web installer to be able to write to the config file, it is possible to make the config file read-only for the Gitea user (owner/group `root:git`, mode `0640`) however you will need to edit your config file manually to:
  90. * Set `INSTALL_LOCK= true`,
  91. * Ensure all database configuration details are set correctly
  92. * Ensure that the `SECRET_KEY` and `INTERNAL_TOKEN` values are set. (You may want to use the `gitea generate secret` to generate these secret keys.)
  93. * Ensure that any other secret keys you need are set.
  94. See the [command line documentation](administration/command-line.md) for information on using `gitea generate secret`.
  95. ### Configure Gitea's working directory
  96. **NOTE:** If you plan on running Gitea as a Linux service, you can skip this step, as the service file allows you to set `WorkingDirectory`. Otherwise, consider setting this environment variable (semi-)permanently so that Gitea consistently uses the correct working directory.
  97. ```sh
  98. export GITEA_WORK_DIR=/var/lib/gitea/
  99. ```
  100. ### Copy the Gitea binary to a global location
  101. ```sh
  102. cp gitea /usr/local/bin/gitea
  103. ```
  104. ### Adding bash/zsh autocompletion (from 1.19)
  105. A script to enable bash-completion can be found at [`contrib/autocompletion/bash_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete). This can be copied to `/usr/share/bash-completion/completions/gitea`
  106. or sourced within your `.bashrc`.
  107. Similarly a script for zsh-completion can be found at [`contrib/autocompletion/zsh_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/zsh_autocomplete). This can be copied to `/usr/share/zsh/_gitea` or sourced within your
  108. `.zshrc`.
  109. YMMV and these scripts may need further improvement.
  110. ## Running Gitea
  111. After you complete the above steps, you can run Gitea two ways:
  112. ### 1. Creating a service file to start Gitea automatically (recommended)
  113. See how to create [Linux service](installation/run-as-service-in-ubuntu.md)
  114. ### 2. Running from command-line/terminal
  115. ```sh
  116. GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
  117. ```
  118. ## Updating to a new version
  119. You can update to a new version of Gitea by stopping Gitea, replacing the binary at `/usr/local/bin/gitea` and restarting the instance.
  120. The binary file name should not be changed during the update to avoid problems in existing repositories.
  121. It is recommended that you make a [backup](administration/backup-and-restore.md) before updating your installation.
  122. If you have carried out the installation steps as described above, the binary should
  123. have the generic name `gitea`. Do not change this, i.e. to include the version number.
  124. ### 1. Restarting Gitea with systemd (recommended)
  125. As we explained before, we recommend to use systemd as the service manager. In this case, `systemctl restart gitea` should be fine.
  126. ### 2. Restarting Gitea without systemd
  127. To restart your Gitea instance, we recommend to use SIGHUP signal. If you know your Gitea PID, use `kill -1 $GITEA_PID`, otherwise you can use `killall -1 gitea`.
  128. To gracefully stop the Gitea instance, a simple `kill $GITEA_PID` or `killall gitea` is enough.
  129. **NOTE:** We don't recommend to use the SIGKILL signal (`-9`); you may be forcefully stopping some of Gitea's internal tasks, and it will not gracefully stop (tasks in queues, indexers, etc.)
  130. See below for troubleshooting instructions to repair broken repositories after
  131. an update of your Gitea version.
  132. ## Troubleshooting
  133. ### Old glibc versions
  134. Older Linux distributions (such as Debian 7 and CentOS 6) may not be able to load the
  135. Gitea binary, usually producing an error such as `./gitea: /lib/x86_64-linux-gnu/libc.so.6:
  136. version 'GLIBC\_2.14' not found (required by ./gitea)`. This is due to the integrated
  137. SQLite support in the binaries provided by dl.gitea.com. In this situation, it is usually
  138. possible to [install from source](installation/from-source.md), without including
  139. SQLite support.
  140. ### Running Gitea on another port
  141. For errors like `702 runWeb()] [E] Failed to start server: listen tcp 0.0.0.0:3000:
  142. bind: address already in use`, Gitea needs to be started on another free port. This
  143. is possible using `./gitea web -p $PORT`. It's possible another instance of Gitea
  144. is already running.
  145. ### Running Gitea on Raspbian
  146. As of v1.8, there is a problem with the arm7 version of Gitea, and it doesn't run on Raspberry Pis and similar devices.
  147. It is recommended to switch to the arm6 version, which has been tested and shown to work on Raspberry Pis and similar devices.
  148. <!---
  149. please remove after fixing the arm7 bug
  150. --->
  151. ### Git error after updating to a new version of Gitea
  152. If during the update, the binary file name has been changed to a new version of Gitea,
  153. Git Hooks in existing repositories will not work any more. In that case, a Git
  154. error will be displayed when pushing to the repository.
  155. ```
  156. remote: ./hooks/pre-receive.d/gitea: line 2: [...]: No such file or directory
  157. ```
  158. The `[...]` part of the error message will contain the path to your previous Gitea
  159. binary.
  160. To solve this, go to the admin options and run the task `Resynchronize pre-receive,
  161. update and post-receive hooks of all repositories` to update all hooks to contain
  162. the new binary path. Please note that this overwrites all Git Hooks, including ones
  163. with customizations made.
  164. If you aren't using the Gitea built-in SSH server, you will also need to re-write
  165. the authorized key file by running the `Update the '.ssh/authorized_keys' file with
  166. Gitea SSH keys.` task in the admin options.