0583.html 9.0 KB

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