You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
8.2 KiB
Markdown

1 year ago
# Beginners Speedrun to Selfhosting
###### guide-by-example
You want to selfhost stuff.<br>
1 year ago
You know little and want to start somewhere, FAST!
1 year ago
1 year ago
# Requirements
1 year ago
11 months ago
* A **spare PC** that will be the server. Can be a **virtualmachine**.
7 months ago
* **Google** and **chatGPT**.<br>
7 months ago
If the guide says do X, and steps seem insufficient,
7 months ago
you google that shit and add the word **youtube**,
or you ask chatGPT few questions.
# Install a Linux on the server
7 months ago
![debian_logo](https://i.imgur.com/LHdGx2S.png)
7 months ago
* **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.
* Make a **bootable usb** from the iso, recommend using [ventoy](https://www.ventoy.net/en/doc_start.html)
* Download ventoy; run; select usb; click install; exit;
* Copy the iso on to the usb as you would any file.
* **Boot from the usb**, maybe on newer machines need to disable secure boot in bios
* **Click through the installation**
* [Theres plenty of youtube videos.](https://youtu.be/rf3EN7e-34g?t=419)
* Leave `root` password empty, so that sudo is installed automaticly
* 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>
* This means no graphical interface, just command line.
1 year ago
1 year ago
# Basic setup of the linux server
![ssh](https://i.imgur.com/ElFrBog.png)
7 months ago
**SSH** - a tiny application that allows you to execute commands from your comfy
windows PC on the damn server.<br>
During Debian install you should have had SSH server checked,
7 months ago
so it would be installed automatically.
7 months ago
If you missed, install it - `sudo apt install ssh`
1 year ago
7 months ago
Now to **find IP address** of the machine so we can remotely connect to it.
1 year ago
7 months ago
* 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>
1 year ago
nope I am not explaining IP addresses
7 months ago
To [check status](https://i.imgur.com/frlyy6P.png) of ssh - `systemctl status sshd`
1 year ago
1 year ago
# Remote connect to the server
![mobasterm_logo](https://i.imgur.com/aBL85Tr.png)
1 year ago
* **install** [mobaXterm](https://mobaxterm.mobatek.net/) on your windows machine
* use it to **connect** to the server using its ip address and username
7 months ago
* [have a pic](https://i.imgur.com/lhRGt1p.png)
* [have a video](https://youtu.be/A7pHiPgW2u8&t=10s)
1 year ago
1 year ago
# Install docker
![docker_logo](https://i.imgur.com/6SS5lFj.png)
1 year ago
7 months ago
**Docker** - a thing that makes hosting super easy, people prepared *recipes*,
7 months ago
you copy paste them, edit a bit, run them.
1 year ago
7 months ago
* **install docker** - `sudo curl -fsSL https://get.docker.com | bash`<br>
1 year ago
* add your user to docker group so you dont need to sudo all the time<br>
`sudo gpasswd -a noob docker`
7 months ago
* log out - `exit`, log back in
7 months ago
* intall [**ctop**](https://github.com/bcicen/ctop) to get some monitoring and management.<br>
Unfortunately ctop is not in debians repositories, so longer uglier two commands to install it:
7 months ago
* `sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-darwin-amd64`
* `sudo chmod +x /usr/local/bin/ctop`
1 year ago
7 months ago
# First docker compose
1 year ago
7 months ago
![nging_welcome](https://i.imgur.com/Iv0B6bN.png)
Well, its time to learn how to create and **edit files** and copy paste shit
1 year ago
in to them, IN LINUX!<br>
1 year ago
Honestly could be annoying as fuck at first, but mobaXterm should make it easier
7 months ago
with that left directory pane that lets you move around,
and the right/middle mouse click for paste.<br>
But now will be listed general commands in linux to move around and
`nano` editor will be used as it is relatively simple and everywhere.
*extra info:* `arrow-up key` in terminal will cycle through old comamnds in history
* Be in your home directory, the command `cd` will always get you there.
* Create directory `mkdir docker`
* Go in to it `cd docker`
* Create directory `mkdir nginx`
* Go in to it `cd nginx`
1 year ago
* Oh look at you being all hacker in terminal, following simple directions
7 months ago
* Create empty docker-compose.yml file `nano docker-compose.yml`
* Paste in to it this *recipe*, spacing matters
1 year ago
```
services:
nginx:
image: nginx:latest
container_name: nginx
hostname: nginx
ports:
- "80:80"
```
7 months ago
* Save using `ctrl+s`; exit `ctrl+x`
7 months ago
* Run command `sudo docker compose up -d`<br>
7 months ago
[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)
1 year ago
* on your windows machine go to your browser<br>
1 year ago
in address bar put the ip of your server `192.168.1.8` bam<br>
7 months ago
You should see the pic above - **Welcome to nginx!**
1 year ago
7 months ago
*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.
But since port 80 is the default http port, it is what browser tries by default.
7 months ago
# Moving beyond terminal
![dockge_pic](https://i.imgur.com/Vh0JN5F.png)
Beginners hate terminal.
[Dockge](https://github.com/louislam/dockge) comes to rescue with its web interface.
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)
7 months ago
* Create new directory dockge `mkdir ~/docker/dockge`
7 months ago
* Go in to the docker directory `cd ~/docker/dockge`
* Create empty docker-compose.yml file `nano docker-compose.yml`
* Paste in to it this *recipe*, spacing matters
```
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`
7 months ago
* Run command `sudo docker compose up -d`<br>
7 months ago
* 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>
Now you can setup new stuff from webgui, pasting compose and .env files.
1 year ago
10 months ago
# understanding what you just did
1 year ago
10 months ago
* on a linux server a docker container is running, its a webserver and it is
accessible for others on your network.<br>
1 year ago
Most of selfhosted stuff is just webserver with some database.
* 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)
or own minecraft server(minecraft server) is just one `docker-compose.yml` away.
10 months ago
# understanding what you did not get done
1 year ago
* 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
to see your awesome nginx welcome running.
1 year ago
She tells you that the dumb fuck you are, you do not have public IP and ports
1 year ago
forwarded.<br>
To get that working is bit challenging, probably deserves own page,
10 months ago
not really speedrun, but thorough steps as shit gets sideways fast and people
1 year ago
can dick around for hours trying wrong shit.
* everything here is just basic setup that breaks easily,
1 year ago
server got dynamic IP, turn it off for a weekend and it might get a different ip
assigned next time it starts. Container is not set to start on boot,...
1 year ago
* you dont understand how this shit works, fixing not working stuff be hard,
but now you can start to consume all the guides and tutorials on
docker compose and try stuff...
1 year ago
## where to go from here
Can check out [this repo](https://github.com/DoTheEvo/selfhosted-apps-docker)
10 months ago
It has tiny section for noobs, with few links to docker tutorials.<br>
You should get some understanding of docker networks going,
making sure you create custom named one and use that in your compose files.
Then its time to start trying stuff like bookstack or jellyfin or minecraft.