0663.html 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Running Shlink URL Shortener in Docker on Ubuntu Server</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,Docker Made Easy,Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,Web Based,Web Based Tools,Shlink,Shlink.io,URL Shortener,Self-Hosted URL Shortener,Docker,Ubuntu,Linux,FOSS,Free Open Source Software,Free Software,Docker Simplified,Container,Containerization,Docker How To,Open Source,Open Source Software,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Running Shlink URL Shortener in Docker on Ubuntu Server">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="12/10/2022 09:59:33 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>Running Shlink URL Shortener in Docker on Ubuntu Server</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is Shlink?</h2>
  26. <blockquote><em>A PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own custom domain.</em> -<a href="https://github.com/shlinkio/shlink" target="_blank">https://github.com/shlinkio/shlink</a></blockquote>
  27. <h2>Installing Docker</h2>
  28. <ol>
  29. <li>Log into the Linux host and run the following commands in a terminal window
  30. <div class="codeBlock"># install prerequisites<br />
  31. sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y<br />
  32. # add docker gpg key<br />
  33. curl -fsSL https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release)/gpg | sudo apt-key add -<br />
  34. # add docker software repository<br />
  35. sudo add-apt-repository &quot;deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release) $(lsb_release -cs) stable&quot;<br />
  36. # install docker<br />
  37. sudo apt install docker-ce docker-compose containerd.io -y<br />
  38. # enable and start docker service<br />
  39. sudo systemctl enable docker &amp;&amp; sudo systemctl start docker<br />
  40. # add the current user to the docker group<br />
  41. sudo usermod -aG docker $USER<br />
  42. # reauthenticate for the new group membership to take effect<br />
  43. su - $USER</div>
  44. </li>
  45. </ol>
  46. <h2>Running Shlink Container</h2>
  47. <ol>
  48. <li>Continue with the following commands in a terminal window
  49. <div class="codeBlock"># create working directories<br />
  50. mkdir ~/docker/shlink -p &amp;&amp; mkdir ~/docker/mariadb -p<br />
  51. # set owner of working directories<br />
  52. sudo chown &quot;$USER&quot;:&quot;$USER&quot; ~/docker -R<br />
  53. # run the mariadb docker container<br />
  54. docker run -d --name <span class="codeBlock">mariadb -e</span> MYSQL_ROOT_PASSWORD=&#39;r00tp@$$&#39; -e MYSQL_USER=shlinkio_rw -e MYSQL_PASSWORD=&#39;$hlink10!&#39; -e MYSQL_DATABASE=shlinkio -v ~/docker/mariadb:/var/lib/mysql --restart=unless-stopped mariadb:latest<br />
  55. # run the shlink docker container<br />
  56. <span class="codeBlock">docker run -d --name shlink --link mariadb -e DEFAULT_DOMAIN=b.rto:8080 -e USE_HTTPS=false -e DB_DRIVER=maria -e DB_NAME=shlinkio -e DB_USER=shlinkio_rw -e DB_PASSWORD=&#39;$hlink10!&#39; -e DB_HOST=mariadb -e DB_PORT=3306 -p 8080:8080 --restart=unless-stopped shlinkio/shlink:stable</span><br />
  57. # run the shlink web client<br />
  58. docker run -d --name shlink-web-client -p 8888:80 -v ~/docker/shlink/servers.json:/usr/share/nginx/html/servers.json --restart=unless-stopped shlinkio/shlink-web-client<br />
  59. # generate shlink API key<br />
  60. docker exec -it shlink shlink api-key:generate</div>
  61. </li>
  62. <li>Copy the generated API key to the clipboard</li>
  63. <li>Open a web browser and navigate to http://DNSorIP:8888</li>
  64. <li>Click the Add a server button</li>
  65. <li>Enter a name for the server, the URL should be http://DNSorIP:8080 and paste the copied API key created earlier</li>
  66. <li>Welcome to <span class="codeBlock">Shlink</span></li>
  67. </ol>
  68. <p>Source: <a href="https://hub.docker.com/r/shlinkio/shlink" target="_blank">https://hub.docker.com/r/shlinkio/shlink</a><br />
  69. Documentation: <a href="https://shlink.io/documentation/install-docker-image/" target="_blank">https://shlink.io/documentation/install-docker-image/</a></p> </div>
  70. </div>
  71. </body>
  72. </html>