0583.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>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="Self-Hosted Reddit Alternative,Install Lemmy on Linux,Install Lemmy on Debian,Lemmy,Reddit,Self-Hosted,Linux,Link Aggregator,Open Source,Install Guide,Home Lab,Browser Based,Web Based,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Install Lemmy Self-Hosted Reddit Alternative on Linux">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  12. <script type="text/javascript">
  13. $(function(){
  14. $('textarea').each(function(i,e){
  15. theTextarea = $(this);
  16. theTextarea.height((theTextarea[0].scrollHeight-5) +'px');
  17. });
  18. $('li').each(function(i,e){
  19. if(!$(this).hasClass('noCheckbox')){
  20. var uuid = 'li_' + Math.floor(Math.random() * Math.floor(1000000)).toString() + '_' + i.toString();
  21. $(this).contents().wrap('<span id="'+ uuid +'"><label for="cb_'+ uuid +'"></label></span>');
  22. $(this).prepend('<input type="checkbox" class="completeBox" id="cb_' + uuid +'" rel="'+ uuid +'" />')
  23. }
  24. });
  25. $('code,div.codeBlock,textarea.codeBlock').each(function(i,e){
  26. theElement = $(this);
  27. var lines = theElement.html().split("\n");
  28. theElement.empty();
  29. for(l=0;l<lines.length;l++){
  30. if($.trim(lines[l]) != '' && $.trim(lines[l]).substr(0,1) != '#' && $.trim(lines[l]).indexOf(' #') == -1 && lines[l].substr(0, 4).toUpperCase() != 'REM '){
  31. theElement.append('<input type="image" src="images/clipboard.png" value="" class="copy-text" rel="copy_'+ i +'_'+ l +'" data-clipboard-text="'+ $.trim(lines[l].replace(/"/g, '&quot;')) +'" /><span id="copy_'+ i +'_'+ l +'">'+ lines[l] +'</span>');
  32. } else {
  33. theElement.append(lines[l]);
  34. }
  35. }
  36. });
  37. $(document).on('click','input.copy-text',function(){
  38. theButton = $(this);
  39. $('input.copy-text').attr('src','images/clipboard.png');
  40. $('span.copy-animation,span.copy-animation-ps').removeClass('copy-animation copy-animation-ps');
  41. try {
  42. if($('#'+ theButton.attr('rel')).parent('div').hasClass('PS')){
  43. $('#'+ theButton.attr('rel')).addClass('copy-animation-ps');
  44. } else if($('#'+ theButton.attr('rel')).parent('div').hasClass('CMD')){
  45. $('#'+ theButton.attr('rel')).addClass('copy-animation-cmd');
  46. } else {
  47. $('#'+ theButton.attr('rel')).addClass('copy-animation');
  48. }
  49. navigator.clipboard.writeText(theButton.data('clipboard-text').replace(/<[^>]*>?/gm, ''));
  50. theButton.attr('src','images/clipboard_active.png');
  51. } catch(err) {
  52. }
  53. return false;
  54. });
  55. $(document).on('click','input.completeBox',function(){
  56. theBox = $(this);
  57. $('#'+ theBox.attr('rel')).addClass('strikethrough');
  58. theBox.prop('disabled',true);
  59. theBox.parent('li').prevAll().each(function(i,e){
  60. theLI = $(this);
  61. if(theLI.find('input[type=checkbox]').not(':checked')){
  62. $('#'+ theLI.find('input[type=checkbox]').attr('rel')).addClass('strikethrough');
  63. theLI.find('input[type=checkbox]').prop('checked',true).prop('disabled',true);
  64. }
  65. });
  66. });
  67. if(window.self !== window.top){
  68. window.parent.$('iframe.stepsFrame').height((this['scrollingElement']['scrollHeight']+20) +'px');
  69. }
  70. });
  71. </script>
  72. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  73. </head>
  74. <body>
  75. <div id="gridContainer">
  76. <div class="topMargin"></div>
  77. <div id="listName" class="topMargin">
  78. <h1>Install Lemmy Self-Hosted Reddit Alternative on Linux</h1>
  79. </div>
  80. <div></div>
  81. <div id="content">
  82. <h2>What is Lemmy?</h2>
  83. <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>
  84. <ol>
  85. <li>Log into the Linux device</li>
  86. <li>Run the following commands in a terminal window
  87. <div class="codeBlock"># update software repositories<br />
  88. sudo apt update<br />
  89. # install available software updates<br />
  90. sudo apt upgrade -y<br />
  91. # install prerequisites<br />
  92. sudo apt install git build-essential gcc libssl-dev pkg-config libpq-dev curl gnupg2 espeak postgresql -y<br />
  93. # enable the postgresql service and start it<br />
  94. sudo systemctl enable postgresql --now<br />
  95. # connect to postgresql<br />
  96. sudo -u postgres psql postgres<br />
  97. # create lemmy database user<br />
  98. create user lemmy with password &#39;L3mmy&#39; superuser;<br />
  99. # create lemmy database<br />
  100. create database lemmy with owner lemmy;<br />
  101. # close postgresql connection<br />
  102. exit<br />
  103. # add nodejs software repository<br />
  104. curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -<br />
  105. # install nodejs<br />
  106. sudo apt install nodejs -y<br />
  107. # install yarn<br />
  108. sudo npm install -g yarn<br />
  109. # create lemmy user<br />
  110. sudo useradd -m -d /opt/lemmy lemmy<br />
  111. # install rust, enter 1 at the prompt<br />
  112. curl https://sh.rustup.rs -sSf | sh<br />
  113. # configure the shell<br />
  114. source $HOME/.cargo/env<br />
  115. # clone the lemmy git repository<br />
  116. git clone https://github.com/LemmyNet/lemmy.git ./server<br />
  117. # change directory to the source code<br />
  118. cd server<br />
  119. # build lemmy<br />
  120. cargo build --release<br />
  121. # change directory out of lemmy server<br />
  122. cd ..<br />
  123. # move lemmy to /opt/lemmy<br />
  124. sudo mv ./server /opt/lemmy/<br />
  125. # switch user to lemmy<br />
  126. sudo su lemmy<br />
  127. # change directory to lemmy home<br />
  128. cd ~<br />
  129. # print working directory, should output /opt/lemmy<br />
  130. pwd<br />
  131. # clone lemmy frontend<br />
  132. git clone https://github.com/LemmyNet/lemmy-ui.git --recurse-submodules ./lemmy-ui<br />
  133. # change directory to lemmy-ui<br />
  134. cd lemmy-ui<br />
  135. # clean npm cache<br />
  136. npm cache clean --force<br />
  137. # install npm dependencies<br />
  138. npm install<br />
  139. # fix npm vulnerabilities<br />
  140. npm audit fix<br />
  141. # build lemmy-ui<br />
  142. yarn build:prod<br />
  143. # exit lemmy shell<br />
  144. exit<br />
  145. # create lemmy service file<br />
  146. sudo nano /etc/systemd/system/lemmy.service</div>
  147. </li>
  148. <li>Paste the following configuration into lemmy.service
  149. <p>[Unit]<br />
  150. Description=Lemmy</p>
  151. <p>[Service]<br />
  152. User=lemmy<br />
  153. Group=lemmy<br />
  154. Environment=LEMMY_DATABASE_URL=postgres://lemmy:L3mmy@localhost:5432/lemmy<br />
  155. ExecStart=/opt/lemmy/server/target/release/lemmy_server<br />
  156. WorkingDirectory=/opt/lemmy/server</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"># create lemmy-ui service bash file<br />
  163. sudo nano /opt/lemmy/lemmy-ui/lemmy-ui.sh</div>
  164. </li>
  165. <li>Paste the following configuration into lemmy-ui.sh
  166. <p>#!/usr/bin/bash<br />
  167. /usr/bin/node /opt/lemmy/lemmy-ui/dist/js/server.js</p>
  168. </li>
  169. <li>Continue with the following commands
  170. <div class="codeBlock"># make lemmy-ui.sh executable<br />
  171. sudo chmod +x /opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  172. # create lemmy service file<br />
  173. sudo nano /etc/systemd/system/lemmy-ui.service</div>
  174. </li>
  175. <li>Paste the following configuration into lemmy-ui.service
  176. <p>[Unit]<br />
  177. Description=Lemmy-UI</p>
  178. <p>[Service]<br />
  179. ExecStart=/opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  180. Restart=always<br />
  181. User=lemmy<br />
  182. Group=lemmy<br />
  183. Environment=PATH=/usr/bin:/usr/local/bin<br />
  184. Environment=NODE_ENV=production<br />
  185. WorkingDirectory=/opt/lemmy/lemmy-ui</p>
  186. <p>[Install]<br />
  187. WantedBy=multi-user.target</p>
  188. </li>
  189. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  190. <li>Continue with the following commands
  191. <div class="codeBlock"># reload systemd services<br />
  192. sudo systemctl daemon-reload<br />
  193. # start lemmy service on boot and now<br />
  194. sudo systemctl enable lemmy --now<br />
  195. # start lemmy-ui service on boot and now<br />
  196. sudo systemctl enable lemmy-ui --now</div>
  197. </li>
  198. <li>Open a web browser and navigate to http://DNSorIP:1234</li>
  199. <li>Enter a username, email and password to create a site administrator account &gt; Click Sign Up</li>
  200. <li>Enter a site name and any additional optional values &gt; Click Create</li>
  201. <li>Welcome to Lemmy</li>
  202. </ol>
  203. <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 />
  204. <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>
  205. </div>
  206. </div>
  207. </body>
  208. </html>