0675.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Updated - Install Lemmy Self-Hosted Reddit Alternative on Linux</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Browser Based,Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,Lemmy,Link Aggregator,Linux,Reddit,Open Source,Install Lemmy On Linux,Install Lemmy On Debian,Self-hosted Reddit Alternative,Federated Reddit Alternative,Federated Link Aggregator,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Updated - Install Lemmy Self-Hosted Reddit Alternative on Linux">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="12/19/2022 11:17:54 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>Updated - Install Lemmy Self-Hosted Reddit Alternative on Linux</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is Lemmy?</h2>
  26. <p><em>Lemmy is an open-source, federated link aggregator similar to Reddit and built with Rust.</em> -<a href="https://lemmy.ml/" target="_blank">https://lemmy.ml/</a></p>
  27. <ol>
  28. <li>Log into the Linux device</li>
  29. <li>Run the following commands in a terminal window
  30. <div class="codeBlock"># update software repositories<br />
  31. sudo apt update<br />
  32. # install available software updates<br />
  33. sudo apt upgrade -y<br />
  34. # install prerequisites<br />
  35. sudo apt install git build-essential gcc libssl-dev pkg-config libpq-dev curl gnupg2 espeak postgresql -y<br />
  36. # enable the postgresql service and start it<br />
  37. sudo systemctl enable postgresql --now<br />
  38. # connect to postgresql<br />
  39. sudo -u postgres psql postgres<br />
  40. # create lemmy database user<br />
  41. create user lemmy with password &#39;L3mmy&#39; superuser;<br />
  42. # create lemmy database<br />
  43. create database lemmy with owner lemmy;<br />
  44. # close postgresql connection<br />
  45. exit<br />
  46. # add nodejs software repository<br />
  47. curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -<br />
  48. # install nodejs<br />
  49. sudo apt install nodejs -y<br />
  50. # install yarn<br />
  51. sudo npm install -g yarn<br />
  52. # create lemmy user<br />
  53. sudo useradd -m -d /opt/lemmy lemmy<br />
  54. # install rust, enter 1 at the prompt<br />
  55. curl https://sh.rustup.rs -sSf | sh<br />
  56. # configure the shell<br />
  57. source &quot;$HOME/.cargo/env&quot;<br />
  58. # lookup the latest tagged release<br />
  59. regex=&#39;\/([0-9|\.]*)&lt;\/id&gt;&#39; &amp;&amp; response=$(curl -s https://github.com/LemmyNet/lemmy/releases.atom) &amp;&amp; [[ $response =~ $regex ]] &amp;&amp; latestTag=&quot;${BASH_REMATCH[1]}&quot;<br />
  60. # clone the lemmy git repository<br />
  61. git clone https://github.com/LemmyNet/lemmy.git ./server<br />
  62. # change directory to the source code<br />
  63. cd server<br />
  64. # checkout the latest tag<br />
  65. git checkout $latestTag<br />
  66. # update submodules <br />
  67. git submodule update --init --recursive<br />
  68. # generate a random 32 character string<br />
  69. openssl rand -base64 32<br />
  70. # edit the lemmy config file<br />
  71. nano ./config/config.hjson</div>
  72. </li>
  73. <li>Set the following values in the conf file
  74. <p>database: {<br />
  75. &emsp;password: L3mmy<br />
  76. }<br />
  77. hostname: &lt;% DNS or IP of host %&gt;<br />
  78. bind: &quot;127.0.0.1&quot;<br />
  79. tls_enabled: false<br />
  80. jwt_secret: &quot;&lt;% Random string from above %&gt;&quot;</p>
  81. </li>
  82. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  83. <li>Continue with the following commands
  84. <div class="codeBlock"># set the database connection variable<br />
  85. LEMMY_DATABASE_URL=postgres://lemmy:L3mmy@localhost:5432/lemmy<br />
  86. # build lemmy<br />
  87. cargo build --release<br />
  88. # change directory out of lemmy server<br />
  89. cd ..<br />
  90. # write the version to .txt<br />
  91. echo $latestTag &gt; /tmp/lemmy_version.txt<br />
  92. # move lemmy to /opt/lemmy<br />
  93. sudo mv ./server /opt/lemmy/<br />
  94. # switch user to lemmy<br />
  95. sudo su lemmy<br />
  96. # change directory to lemmy home<br />
  97. cd ~<br />
  98. # print working directory, should output /opt/lemmy<br />
  99. pwd<br />
  100. # clone lemmy frontend<br />
  101. git clone https://github.com/LemmyNet/lemmy-ui.git --recurse-submodules ./lemmy-ui<br />
  102. # change directory to lemmy-ui<br />
  103. cd lemmy-ui<br />
  104. # checkout the latest tag<br />
  105. git checkout $(cat /tmp/lemmy_version.txt)<br />
  106. # update submodules <br />
  107. git submodule update --init --recursive<br />
  108. # install npm dependencies<br />
  109. npm install --force<br />
  110. # build lemmy-ui<br />
  111. yarn build:prod<br />
  112. # exit lemmy shell<br />
  113. exit<br />
  114. # set owner of /opt/lemmy<br />
  115. sudo chown lemmy:lemmy /opt/lemmy/ -R<br />
  116. # create lemmy service file<br />
  117. sudo nano /etc/systemd/system/lemmy.service</div>
  118. </li>
  119. <li>Paste the following configuration into lemmy.service
  120. <p>[Unit]<br />
  121. Description=Lemmy</p>
  122. <p>[Service]<br />
  123. User=lemmy<br />
  124. Group=lemmy<br />
  125. Environment=LEMMY_DATABASE_URL=postgres://lemmy:L3mmy@localhost:5432/lemmy<br />
  126. ExecStart=/opt/lemmy/server/target/release/lemmy_server<br />
  127. WorkingDirectory=/opt/lemmy/server</p>
  128. <p>[Install]<br />
  129. WantedBy=multi-user.target</p>
  130. </li>
  131. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  132. <li>Continue with the following commands
  133. <div class="codeBlock"># create lemmy-ui service bash file<br />
  134. sudo nano /opt/lemmy/lemmy-ui/lemmy-ui.sh</div>
  135. </li>
  136. <li>Paste the following configuration into lemmy-ui.sh
  137. <p>#!/usr/bin/bash<br />
  138. /usr/bin/node /opt/lemmy/lemmy-ui/dist/js/server.js</p>
  139. </li>
  140. <li>Continue with the following commands
  141. <div class="codeBlock"># make lemmy-ui.sh executable<br />
  142. sudo chmod +x /opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  143. # create lemmy service file<br />
  144. sudo nano /etc/systemd/system/lemmy-ui.service</div>
  145. </li>
  146. <li>Paste the following configuration into lemmy-ui.service
  147. <p>[Unit]<br />
  148. Description=Lemmy-UI</p>
  149. <p>[Service]<br />
  150. ExecStart=/opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  151. Restart=always<br />
  152. User=lemmy<br />
  153. Group=lemmy<br />
  154. Environment=PATH=/usr/bin:/usr/local/bin<br />
  155. Environment=NODE_ENV=production<br />
  156. WorkingDirectory=/opt/lemmy/lemmy-ui</p>
  157. <p>[Install]<br />
  158. WantedBy=multi-user.target</p>
  159. </li>
  160. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  161. <li>Continue with the following commands
  162. <div class="codeBlock"># reload systemd services<br />
  163. sudo systemctl daemon-reload<br />
  164. # start lemmy service on boot and now<br />
  165. sudo systemctl enable lemmy --now<br />
  166. # start lemmy-ui service on boot and now<br />
  167. sudo systemctl enable lemmy-ui --now</div>
  168. </li>
  169. <li>Open a web browser and navigate to http://DNSorIP:1234</li>
  170. <li>Enter a username, email and password to create a site administrator account &gt; Click Sign Up</li>
  171. <li>Enter a site name and any additional optional values &gt; Click Create</li>
  172. <li>Welcome to Lemmy</li>
  173. </ol>
  174. <p>Sources: <a href="https://join-lemmy.org/docs/en/contributing/local_development.html" target="_blank">https://join-lemmy.org/docs/en/contributing/local_development.html</a>,<br />
  175. <a href="https://join-lemmy.org/docs/en/administration/from_scratch.html" target="_blank">https://join-lemmy.org/docs/en/administration/from_scratch.html</a></p> </div>
  176. </div>
  177. </body>
  178. </html>