0583.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Install Lemmy Self-Hosted Reddit Alternative on Linux</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <h2>What is Lemmy?</h2>
  25. <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>
  26. <ol>
  27. <li>Log into the Linux device</li>
  28. <li>Run the following commands in a terminal window
  29. <div class="codeBlock"># update software repositories<br />
  30. sudo apt update<br />
  31. # install available software updates<br />
  32. sudo apt upgrade -y<br />
  33. # install prerequisites<br />
  34. sudo apt install git build-essential gcc libssl-dev pkg-config libpq-dev curl gnupg2 espeak postgresql -y<br />
  35. # enable the postgresql service and start it<br />
  36. sudo systemctl enable postgresql --now<br />
  37. # connect to postgresql<br />
  38. sudo -u postgres psql postgres<br />
  39. # create lemmy database user<br />
  40. create user lemmy with password &#39;L3mmy&#39; superuser;<br />
  41. # create lemmy database<br />
  42. create database lemmy with owner lemmy;<br />
  43. # close postgresql connection<br />
  44. exit<br />
  45. # add nodejs software repository<br />
  46. curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -<br />
  47. # install nodejs<br />
  48. sudo apt install nodejs -y<br />
  49. # install yarn<br />
  50. sudo npm install -g yarn<br />
  51. # create lemmy user<br />
  52. sudo useradd -m -d /opt/lemmy lemmy<br />
  53. # install rust, enter 1 at the prompt<br />
  54. curl https://sh.rustup.rs -sSf | sh<br />
  55. # configure the shell<br />
  56. source $HOME/.cargo/env<br />
  57. # clone the lemmy git repository<br />
  58. git clone https://github.com/LemmyNet/lemmy.git ./server<br />
  59. # change directory to the source code<br />
  60. cd server<br />
  61. # build lemmy<br />
  62. cargo build --release<br />
  63. # change directory out of lemmy server<br />
  64. cd ..<br />
  65. # move lemmy to /opt/lemmy<br />
  66. sudo mv ./server /opt/lemmy/<br />
  67. # switch user to lemmy<br />
  68. sudo su lemmy<br />
  69. # change directory to lemmy home<br />
  70. cd ~<br />
  71. # print working directory, should output /opt/lemmy<br />
  72. pwd<br />
  73. # clone lemmy frontend<br />
  74. git clone https://github.com/LemmyNet/lemmy-ui.git --recurse-submodules ./lemmy-ui<br />
  75. # change directory to lemmy-ui<br />
  76. cd lemmy-ui<br />
  77. # clean npm cache<br />
  78. npm cache clean --force<br />
  79. # install npm dependencies<br />
  80. npm install<br />
  81. # fix npm vulnerabilities<br />
  82. npm audit fix<br />
  83. # build lemmy-ui<br />
  84. yarn build:prod<br />
  85. # exit lemmy shell<br />
  86. exit<br />
  87. # create lemmy service file<br />
  88. sudo nano /etc/systemd/system/lemmy.service</div>
  89. </li>
  90. <li>Paste the following configuration into lemmy.service
  91. <p>[Unit]<br />
  92. Description=Lemmy</p>
  93. <p>[Service]<br />
  94. User=lemmy<br />
  95. Group=lemmy<br />
  96. Environment=LEMMY_DATABASE_URL=postgres://lemmy:L3mmy@localhost:5432/lemmy<br />
  97. ExecStart=/opt/lemmy/server/target/release/lemmy_server<br />
  98. WorkingDirectory=/opt/lemmy/server</p>
  99. <p>[Install]<br />
  100. WantedBy=multi-user.target</p>
  101. </li>
  102. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  103. <li>Continue with the following commands
  104. <div class="codeBlock"># create lemmy-ui service bash file<br />
  105. sudo nano /opt/lemmy/lemmy-ui/lemmy-ui.sh</div>
  106. </li>
  107. <li>Paste the following configuration into lemmy-ui.sh
  108. <p>#!/usr/bin/bash<br />
  109. /usr/bin/node /opt/lemmy/lemmy-ui/dist/js/server.js</p>
  110. </li>
  111. <li>Continue with the following commands
  112. <div class="codeBlock"># make lemmy-ui.sh executable<br />
  113. sudo chmod +x /opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  114. # create lemmy service file<br />
  115. sudo nano /etc/systemd/system/lemmy-ui.service</div>
  116. </li>
  117. <li>Paste the following configuration into lemmy-ui.service
  118. <p>[Unit]<br />
  119. Description=Lemmy-UI</p>
  120. <p>[Service]<br />
  121. ExecStart=/opt/lemmy/lemmy-ui/lemmy-ui.sh<br />
  122. Restart=always<br />
  123. User=lemmy<br />
  124. Group=lemmy<br />
  125. Environment=PATH=/usr/bin:/usr/local/bin<br />
  126. Environment=NODE_ENV=production<br />
  127. WorkingDirectory=/opt/lemmy/lemmy-ui</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"># reload systemd services<br />
  134. sudo systemctl daemon-reload<br />
  135. # start lemmy service on boot and now<br />
  136. sudo systemctl enable lemmy --now<br />
  137. # start lemmy-ui service on boot and now<br />
  138. sudo systemctl enable lemmy-ui --now</div>
  139. </li>
  140. <li>Open a web browser and navigate to http://DNSorIP:1234</li>
  141. <li>Enter a username, email and password to create a site administrator account &gt; Click Sign Up</li>
  142. <li>Enter a site name and any additional optional values &gt; Click Create</li>
  143. <li>Welcome to Lemmy</li>
  144. </ol>
  145. <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 />
  146. <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>
  147. </div>
  148. </div>
  149. </body>
  150. </html>