0521.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Host Your Own GitHub Alternative with Gitea</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="GitHub Alternatives,Git,Gitea,Gitea Tutorial,Source Control,Install Guide,Home Lab,Home Lab Ideas,Self-Hosted,Web Based,Web Based Tools,Browser Based,Linux,Debian,How To Install Gitea,Intall Gitea On Debian,Self-Hosted GitHub Alternative,How To Install Gitea On Linux,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Host Your Own GitHub Alternative with Gitea">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="05/31/2023 09:40:43 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Host Your Own GitHub Alternative with Gitea</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is Gitea</h2>
  26. <blockquote><em>Gitea is a community managed lightweight code hosting solution written in Go. -<a href="https://gitea.io/" target="_blank">https://gitea.io/</a></em></blockquote>
  27. <h2>Installing Gitea</h2>
  28. <ol>
  29. <li>Log into the Linux device</li>
  30. <li>Run the following commands in a terminal:
  31. <div class="codeBlock"># update software repositories<br />
  32. sudo apt update<br />
  33. # install software updates<br />
  34. sudo apt upgrade -y<br />
  35. # install preprequisites<br />
  36. sudo apt install git mariadb-server -y<br />
  37. # create gitea user<br />
  38. sudo adduser --system --shell /bin/bash --gecos &#39;Git Version Control&#39; --group --disabled-password --home /home/gitea gitea<br />
  39. # configure the MySQL database<br />
  40. sudo su<br />
  41. mysql_secure_installation</div>
  42. </li>
  43. <li>Press Enter to login as root</li>
  44. <li>Type Y and press Enter to set a root password, type the password twice to confirm</li>
  45. <li>Type Y and press Enter to remove anonymous users</li>
  46. <li>Type Y and press Enter to disallow root login remotely</li>
  47. <li>Type Y and press Enter to remove the test database</li>
  48. <li>Type Y and press Enter to reload privilege tables</li>
  49. <li>Run the following command to login into MySQL:
  50. <div class="codeBlock">mysql -u root -p</div>
  51. </li>
  52. <li>Authenticate with the root password set earlier</li>
  53. <li>Run the following commands to create the Gitea database and database user
  54. <div class="codeBlock">CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<br />
  55. CREATE USER &#39;gitea_rw&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;G1te@!&#39;;<br />
  56. GRANT ALL PRIVILEGES ON gitea.* TO &#39;gitea_rw&#39;@&#39;localhost&#39;;<br />
  57. FLUSH PRIVILEGES;<br />
  58. EXIT;<br />
  59. exit</div>
  60. </li>
  61. <li>Continue with the following commands:
  62. <div class="codeBlock"># download the Gitea binary<br />
  63. wget -O ./gitea https://github.com/go-gitea/gitea/releases/download/v1.14.2/gitea-1.14.2-linux-amd64<br />
  64. # make gitea executable<br />
  65. sudo chmod +x gitea<br />
  66. # move gitea to /usr/local/bin<br />
  67. sudo mv ./gitea /usr/local/bin/<br />
  68. # verify gitea can be found<br />
  69. gitea --version<br />
  70. # create required directory structures<br />
  71. sudo mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}<br />
  72. sudo chown gitea:gitea /var/lib/gitea/{data,indexers,log}<br />
  73. sudo chmod 750 /var/lib/gitea/{data,indexers,log}<br />
  74. sudo chown root:gitea /etc/gitea<br />
  75. sudo chmod 770 /etc/gitea<br />
  76. # create gitea service<br />
  77. sudo nano /etc/systemd/system/gitea.service</div>
  78. </li>
  79. <li>Paste the following into gitea.service
  80. <p>[Unit]<br />
  81. Description=Gitea<br />
  82. After=syslog.target<br />
  83. After=network.target<br />
  84. After=mysql.service</p>
  85. <p>[Service]<br />
  86. LimitMEMLOCK=infinity<br />
  87. LimitNOFILE=65535<br />
  88. RestartSec=2s<br />
  89. Type=simple<br />
  90. User=gitea<br />
  91. Group=gitea<br />
  92. WorkingDirectory=/var/lib/gitea/<br />
  93. ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini<br />
  94. Restart=always<br />
  95. Environment=USER=git HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea</p>
  96. <p>[Install]<br />
  97. WantedBy=multi-user.target</p>
  98. </li>
  99. <li>Press CTRL+O, Enter, CTRL+X to write the changes to gitea.service</li>
  100. <li>Continue with the following commands:
  101. <div class="codeBlock"># reload services<br />
  102. sudo systemctl daemon-reload<br />
  103. # enable gitea to run on boot and start now<br />
  104. sudo systemctl enable --now gitea</div>
  105. </li>
  106. <li>Open a web browser and navigate to http://DNSorIP:3000</li>
  107. <li>Complete the database settings on the Initial Configuration screen &gt; Click the Install Gitea button</li>
  108. <li>Click the Register Now link</li>
  109. <li>Enter a username, email and password &gt; Click the Register Account button</li>
  110. <li>Welcome to Gitea</li>
  111. </ol>
  112. <p>Source: <a href="https://about.gitlab.com/" target="_blank">https://about.gitlab.com/</a></p> </div>
  113. </div>
  114. </body>
  115. </html>