2023-06-04 00:52:13 +00:00
# Beginners Speedrun to Selfhosting
###### guide-by-example
You want to selfhost stuff.< br >
2023-06-04 21:39:45 +00:00
You know little and want to start somewhere, FAST!
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
#### Requirements
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
* A **spare PC** that will be the server, can be a **virtualmachine** .
2024-02-25 10:59:29 +00:00
* **Google** and **chatGPT** .< br >
2024-03-16 09:41:53 +00:00
If the guide says do X and the steps seem insufficient,
2024-02-25 10:59:29 +00:00
you google that shit and add the word **youtube** ,
or you ask chatGPT few questions.
2024-03-28 23:29:18 +00:00
#### Common terminology
2024-03-16 09:41:53 +00:00
2024-03-28 23:29:18 +00:00
* `repository` - a place on the internet from which linux distro installs stuff.
* `root` - a name for an administrator account in linux.
2024-03-16 09:41:53 +00:00
* `sudo` - [executes ](https://www.explainxkcd.com/wiki/images/b/b1/sandwich.png )
2024-03-28 23:29:18 +00:00
command as root with all privilages.
2024-03-16 09:41:53 +00:00
2024-03-16 12:47:39 +00:00
# Install a Linux
2024-02-25 10:59:29 +00:00
2024-02-25 13:53:16 +00:00
![debian_logo ](https://i.imgur.com/LHdGx2S.png )
2024-02-25 10:59:29 +00:00
* **Download linux iso**. I picked [Debian\(650MB\) ](https://www.debian.org/ )
* *Why that linux and not xxx linux?*< br >
* Fuck you, thats why. I am not writing a novel here.
2024-03-16 13:40:58 +00:00
* Make a **bootable usb** from the iso, [ventoy ](https://www.ventoy.net ) is recommend. [ChatGPT ](https://i.imgur.com/gODUfJm.png ).
* [Download ](https://www.ventoy.net/en/download.html ) ventoy; extract;
run `Ventoy2Disk.exe` ; select a usb; click install; exit;
* Copy the Debian iso on to the usb as you would any file.
2024-02-25 10:59:29 +00:00
* **Boot from the usb**, maybe on newer machines need to disable secure boot in bios
* **Click through the installation**
2024-03-16 13:40:58 +00:00
* During first time install, would recommend actually reading whats written on screen each step.< br >
2024-03-16 12:47:39 +00:00
Theres also plenty of [youtube videos, ](https://www.youtube.com/results?search_query=installing+debian&sp=EgIIBQ%253D%253D )
which go in to [details ](https://youtu.be/rf3EN7e-34g?t=419 ).
2024-03-16 09:41:53 +00:00
* Leave `root` password **empty** , so that sudo is installed automatically
2024-02-25 10:59:29 +00:00
* this will disable root account, if you would want it, just set password for root< br >
`sudo passwd root`
* For username lets say `noob` with password `aaa`
* During software selection [uncheck everything ](https://i.imgur.com/MKrPMx2.png )
except:
* SSH server
* standard system utilities< br >
2024-03-28 23:29:18 +00:00
This linux will have no graphical interface, just command line.
2023-06-04 00:52:13 +00:00
2024-03-16 12:47:39 +00:00
# SSH
2023-06-04 21:39:45 +00:00
2024-03-16 12:47:39 +00:00
![ssh_pic ](https://i.imgur.com/ElFrBog.png )
2023-06-04 21:39:45 +00:00
2024-02-25 10:59:29 +00:00
**SSH** - a tiny application that allows you to execute commands from your comfy
2024-03-16 12:47:39 +00:00
windows PC on the damn server. [ChatGPT ](https://i.imgur.com/vJjJxZT.png ).
2024-02-25 10:59:29 +00:00
During Debian install you should have had SSH server checked,
2024-02-25 11:24:56 +00:00
so it would be installed automatically.
2024-03-16 09:41:53 +00:00
If you missed it, install it with - `sudo apt install ssh`
2023-06-04 00:52:13 +00:00
2024-04-07 08:36:57 +00:00
*extra info:* to [check status ](https://i.imgur.com/frlyy6P.png ) of ssh - `systemctl status sshd`
2024-02-25 10:59:29 +00:00
Now to **find IP address** of the machine so we can remotely connect to it.
2023-06-04 00:52:13 +00:00
2024-02-25 10:59:29 +00:00
* Log in `noob` / `aaa` and be in terminal.
* `ip r` - shows [at the end the IP ](https://i.imgur.com/eGkYmKB.png ) of the machine< br >
lets say you got `192.168.1.8` < br >
2024-03-16 12:47:39 +00:00
Nope I am not explaining IP addresses.
2023-06-04 00:52:13 +00:00
2024-05-30 20:42:36 +00:00
Beware, an IP address can change if the server is shutdown for a while.
Lookup `static IP` or `IP reservation` .
2023-06-04 00:52:13 +00:00
2024-03-16 12:47:39 +00:00
### Remote connect to the server
2023-06-04 21:39:45 +00:00
![mobasterm_logo ](https://i.imgur.com/aBL85Tr.png )
2023-06-04 00:52:13 +00:00
* **install** [mobaXterm ](https://mobaxterm.mobatek.net/ ) on your windows machine
* use it to **connect** to the server using its ip address and username
2024-03-16 09:41:53 +00:00
* [have a pic ](https://i.imgur.com/dHncQBv.png )
2024-02-25 10:59:29 +00:00
* [have a video ](https://youtu.be/A7pHiPgW2u8&t=10s )
2023-06-04 00:52:13 +00:00
2024-03-31 20:00:17 +00:00
Now you should be able to execute commands on the server from your main PC.
2023-06-04 21:39:45 +00:00
# Install docker
![docker_logo ](https://i.imgur.com/6SS5lFj.png )
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
**Docker** - a thing that makes hosting easier. People prepared *recipes* ,
you copy paste them, edit a bit, run them. Bam a container is running
and answering at some IP. [ChatGPT ](https://i.imgur.com/eyWePqj.png ).
2023-06-04 00:52:13 +00:00
2024-04-07 08:36:57 +00:00
* **install docker** - `sudo wget -qO- https://get.docker.com | bash` < br >
2024-03-16 09:41:53 +00:00
The above method is called
2024-03-28 23:29:18 +00:00
[Install using the convenience script ](https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script ),
2024-03-16 12:47:39 +00:00
cuz oldman Debian cant be bothered to keep docker up to date in its repos.
2024-03-28 23:29:18 +00:00
* **add your user to docker group** so you dont need to sudo all the time< br >
2023-06-04 00:52:13 +00:00
`sudo gpasswd -a noob docker`
2024-03-28 23:29:18 +00:00
* log out - `exit` , log back in so the group change takes effect
* **install [ctop ](https://github.com/bcicen/ctop )** to get some basic monitoring and management.< br >
Unfortunately ctop is also not in Debians repositories, so uglier
2024-03-16 09:41:53 +00:00
[two commands ](https://github.com/bcicen/ctop?tab=readme-ov-file#linux-generic ) to install it:
* `sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /usr/local/bin/ctop`
2024-02-25 10:59:29 +00:00
* `sudo chmod +x /usr/local/bin/ctop`
2023-06-04 00:52:13 +00:00
2024-02-25 10:59:29 +00:00
# First docker compose
2023-06-04 00:52:13 +00:00
2024-02-25 10:59:29 +00:00
![nging_welcome ](https://i.imgur.com/Iv0B6bN.png )
2024-06-17 23:18:36 +00:00
Time to spin up some simple docker container. Let's go with nginx - a web server.
It's just a tiny application that waits for a browser trying to connect to serve
a web page.
It is also time to learn how to create and **edit files** and copy paste shit
2024-03-16 12:47:39 +00:00
in to them, IN LINUX!
2024-03-16 13:40:58 +00:00
Honestly could be annoying, but mobaXterm should make it easier
2024-02-25 10:59:29 +00:00
with that left directory pane that lets you move around,
and the right/middle mouse click for paste.< br >
2024-05-30 20:42:36 +00:00
But here are general linux commands to move around and to edit files using
2024-04-07 08:36:57 +00:00
`nano` editor.
2024-02-25 10:59:29 +00:00
2024-03-16 12:47:39 +00:00
*extra info:* `arrow-up key` in terminal will cycle through old commands in history
2024-02-25 10:59:29 +00:00
2024-03-16 12:47:39 +00:00
* Be in your home directory, the command `cd` will always get you there.
[ChatGPT. ](https://i.imgur.com/i32So7T.png )
2024-02-25 10:59:29 +00:00
* Create directory `mkdir docker`
* Go in to it `cd docker`
* Create directory `mkdir nginx`
* Go in to it `cd nginx`
2023-06-04 00:52:13 +00:00
* Oh look at you being all hacker in terminal, following simple directions
2024-02-25 10:59:29 +00:00
* Create empty docker-compose.yml file `nano docker-compose.yml`
* Paste in to it this *recipe* , spacing matters
2023-06-04 00:52:13 +00:00
```
services:
nginx:
image: nginx:latest
container_name: nginx
hostname: nginx
ports:
- "80:80"
```
2024-02-25 10:59:29 +00:00
* Save using `ctrl+s` ; exit `ctrl+x`
2024-02-25 14:57:35 +00:00
* Run command `sudo docker compose up -d` < br >
2024-02-25 10:59:29 +00:00
[This is what it should look like ](https://imgur.com/a/vtHYNr9 )
* You can run `ctop` to see container status, resource use, logs,
details, or to exec in to the container. [Like so. ](https://imgur.com/a/ChGjk7i )
2023-06-04 00:52:13 +00:00
* on your windows machine go to your browser< br >
2023-06-04 21:39:45 +00:00
in address bar put the ip of your server `192.168.1.8` bam< br >
2024-02-25 10:59:29 +00:00
You should see the pic above - **Welcome to nginx!**
2023-06-04 00:52:13 +00:00
2024-02-25 11:24:56 +00:00
*extra info:* it should actually be`192.168.1.8:80`,
with the port 80 we see in the compose being used in the url too.
2024-03-16 12:47:39 +00:00
But since port 80 is the default http port, it is what browsers go for anyway.
2024-02-25 11:24:56 +00:00
2024-03-28 23:29:18 +00:00
### understanding what you just did
* On a linux server a docker container is running, its a webserver and it is
accessible for others on your network.< br >
2024-04-07 08:36:57 +00:00
Most of selfhosted stuff is just a webserver with some database.
2024-03-28 23:29:18 +00:00
* If this part is done that means that shit like hosting own netflix(jellyfin),
or google drive/calendar/photos(nextcloud), or own password manager(vaultwarden)
2024-04-07 08:36:57 +00:00
or own minecraft server(crafty) is just one `docker-compose.yml` away.
2024-03-28 23:29:18 +00:00
### understanding what you did not get done
2024-04-07 08:36:57 +00:00
* this shit is on your own local network, not accessible from the *"outside"* .
Cant call grandma and tell her to write `192.168.1.8` in to her browser
2024-03-28 23:29:18 +00:00
to see your awesome nginx welcome running.
She tells you that the dumb fuck you are, you do not have public IP and ports
forwarded.< br >
2024-05-30 20:42:36 +00:00
To get that working can be a bit challenging - [port forwarding guide ](https://github.com/DoTheEvo/selfhosted-apps-docker/blob/master/network-knowledge-base/port_forwarding.md )
2024-03-28 23:29:18 +00:00
* everything here is just basic setup that breaks easily,
server got dynamic IP, turn it off for a weekend and it might get a different ip
assigned next time it starts. Nginx container is not set to start on boot,...
* you dont understand how this shit works, deploying more complicated stuff,
fixing not working stuff be hard, but now you can start to consume all
the guides and tutorials on docker compose and try stuff...
# WebGUI
* *my recommendation is to not abandon the ssh + terminal. Persevere.
Use it, make it comfortable, natural, not foreign and bothersome.
This is what gets you proficiency and ability to solve problems...
2024-04-07 08:09:56 +00:00
but I understand...*
2024-03-28 23:29:18 +00:00
2024-04-07 08:09:56 +00:00
Several options to manage docker from a browser.
2024-03-28 23:29:18 +00:00
2024-05-30 20:42:36 +00:00
* Portainer CE - the most popular, deployed as a container,
they started to be bothersome with the paid version so fuck em
2024-03-28 23:29:18 +00:00
* **CasaOS** - simple install, seems nice and growing in popularity
* **Dockge** - a very new one, but seems nice and simple
* TrueNAS SCALE - NAS operating systems with docker managment
* openmediavault - NAS operating systems with docker managment
2024-05-30 20:42:36 +00:00
* Unraid - paid NAS operating systems with docker and VMs managment
2024-03-28 23:29:18 +00:00
# CasaOS
2024-04-07 12:17:29 +00:00
![casa_logo ](https://i.imgur.com/rFo7L9k.png )
* [The official site ](https://casaos.io )
2024-03-28 23:29:18 +00:00
2024-05-30 20:42:36 +00:00
Easy to create public shares, easy to deploy docker containers
2024-03-31 20:00:17 +00:00
from their *"app store"*
2024-03-28 23:29:18 +00:00
#### Installation
* `docker compose down` any containers you run, or remove them in ctop, or
do clean Debian install again
* To install CasaOS execute:< br >
2024-04-07 08:36:57 +00:00
`wget -qO- https://get.casaos.io | sudo bash`
2024-03-28 23:29:18 +00:00
* Afterwards, it tells the ip to visit.
* First login set credentials
---
< details >
< summary > < b > < font size = "+1" > Create a network share < / font > < / b > < / summary >
2024-03-29 01:34:29 +00:00
[share.webm ](https://github.com/DoTheEvo/selfhosted-apps-docker/assets/1690300/c640665f-9400-4cf2-949b-07753ad8a86c )
2024-03-28 23:29:18 +00:00
< / details >
---
---
< details >
2024-05-30 20:42:36 +00:00
< summary > < b > < font size = "+1" > Deploy Jellyfin - selfhosted netflix< / font > < / b > < / summary >
2024-03-28 23:29:18 +00:00
2024-05-30 20:42:36 +00:00
[jellyfin.webm ](https://github.com/DoTheEvo/selfhosted-apps-docker/assets/1690300/0dac601a-f159-4745-abc1-1279b25875dd )
2024-03-28 23:29:18 +00:00
< / details >
---
---
< details >
2024-05-30 20:42:36 +00:00
< summary > < b > < font size = "+1" > Deploy Crafty - Minecraft server manager< / font > < / b > < / summary >
2024-03-28 23:29:18 +00:00
2024-05-30 20:42:36 +00:00
[crafty.webm ](https://github.com/DoTheEvo/selfhosted-apps-docker/assets/1690300/ea163089-5329-4530-8361-83bb526fbe2d )
2024-03-28 23:29:18 +00:00
< / details >
---
---
< details >
< summary > < b > < font size = "+1" > Deploy something not in the app store< / font > < / b > < / summary >
2024-05-30 20:42:36 +00:00
will add something later
2024-03-28 23:29:18 +00:00
< / details >
---
---
# Dockge
2024-02-25 10:59:29 +00:00
![dockge_pic ](https://i.imgur.com/Vh0JN5F.png )
Beginners hate terminal.
2024-03-16 09:41:53 +00:00
[Dockge ](https://github.com/louislam/dockge ) comes to the rescue with its web interface.
2024-02-25 10:59:29 +00:00
Same as nginx example was deployed, we deploy dockge
using slightly edited compose file from their
[github page. ](https://github.com/louislam/dockge/blob/master/compose.yaml )
2024-03-16 09:41:53 +00:00
* Create a new directory dockge `mkdir ~/docker/dockge`
2024-06-17 23:18:36 +00:00
* Go in to the dockge directory `cd ~/docker/dockge`
2024-03-16 09:41:53 +00:00
* Create an empty docker-compose.yml file `nano docker-compose.yml`
* Paste the *recipe* , spacing matters
2024-02-25 10:59:29 +00:00
```
services:
dockge:
image: louislam/dockge:1
container_name: dockge
hostname: dockge
restart: unless-stopped
ports:
- "5001:5001"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/app/data
- /opt/stacks:/opt/stacks
environment:
- DOCKGE_STACKS_DIR=/opt/stacks
```
* Save using `ctrl+s` ; exit `ctrl+x`
2024-02-25 14:57:35 +00:00
* Run command `sudo docker compose up -d` < br >
2024-02-25 10:59:29 +00:00
* on your windows machine go to your browser< br >
in address bar put the ip of your server `192.168.1.8:5001` bam< br >
2024-03-16 12:47:39 +00:00
Now you can do stuff from webgui, pasting compose and .env files.
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
## where to go from here
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
Google and consume docker tutorials and videos and try to spinning up
some containers.< br >
Heres some stuff I encountered and liked.
2023-06-04 00:52:13 +00:00
2024-03-28 23:29:18 +00:00
* [8 min video on docker ](https://www.youtube.com/watch?v=rIrNIzy6U_g )
2024-05-30 20:42:36 +00:00
* [Docker Fundamentals Course ](https://www.youtube.com/playlist?list=PLTk5ZYSbd9Mg51szw21_75Hs1xUpGObDm )
2024-03-28 23:29:18 +00:00
* [docker compose cheat sheet ](https://devopscycle.com/blog/the-ultimate-docker-compose-cheat-sheet/ )
* [Good stuff ](https://adamtheautomator.com/docker-compose-tutorial/ )
* [https://devopswithdocker.com/getting-started ](https://devopswithdocker.com/getting-started )
* [NetworkChuck ](https://www.youtube.com/@NetworkChuck/videos )
\- youtube channel
has some decent stuff, specificly [this docker networking ](https://youtu.be/bKFMS5C4CG0 )
video is fucking great and the general
[introduction to docker compose ](https://youtu.be/DM65_JyGxCo ) is good too.
* [Christian Lempa ](https://www.youtube.com/@christianlempa/search?query=docker )
\- lot of videos about docker
2023-06-04 01:04:10 +00:00
2024-03-28 23:29:18 +00:00
Check of course [this github repo you are in right ](https://github.com/DoTheEvo/selfhosted-apps-docker )
for some stuff to deploy.
2023-11-15 21:40:20 +00:00