Skip to content

Set Up Your Ubuntu Home Server

Ubuntu server vs desktop Install Ubuntu server from USB

You can install an Ubuntu server on spare hardware to host various services like cloud-storage, pictures, contacts, calendars and tasks or multimedia streaming. Learn how to shield your server with basic and advanced security measures, and schedule backups.

Should I host my home server or rent a VPS?

Both options have pros and cons. It's a trade-off between privacy, security and convenience. Although this guide explains how to host your server at home, you can also rent a virtual private server (VPS) from providers such as Hetzner, Digital Ocean, OVH, Contabo, Scaleway and others.

Home server VPS
Better privacy
Lower upfront costs
Lower recurring costs
Easier to setup
Easier to maintain
Lower security risks
Lower risk of data loss
Lower downtime risk
Fewer latency issues
Fewer bandwidth limitations

What are the minimum hardware requirements?

It will depend on the planned usage. How many users or visits do you expect per day? Do you plan on streaming video or storing large amounts of data? The following minimum specs should be enough for a handful of services/users:

  • One or more 2 GHz processors
  • 2 to 4 GB RAM
  • 10 to 25 GB storage (or more for large file collections)
  • Fast Internet connection

Here a list of mini PCs, which are well suited as servers due to their small form factor and low price range.

How can I edit files within the terminal?

Interacting with the server requires quite heavy usage of the terminal. Configuration files and settings often need to be modified with a text editor. The vi editor is commonly used, install it by running the following terminal command:

sudo apt install vim

vi has three modes:

  • Normal mode: vi starts in normal mode, which allows to navigate through documents

  • Insert mode: by hitting the i key, vi switches to insert mode, which allows to edit and modify documents

  • Command mode: by hitting the colon key :, vi switches to command mode, which allows for example to save changes or find text within the document

The following commands should be sufficient to follow all instructions provided on this website:

Command Description
vi file.txt Open the document "file.txt" with the vi text editor.
i Switch to "Insert mode" and start modifying the file.
ESC Exit the "Insert mode" once modifications are done.
:w Save all changes made to the file, while keeping it open.
:wq or :x Save all changes made to the file, and exit vi.
:q! Exit vi, without saving any changes made to the file.
/findword Search for the word "findword" (replace with the actual word you're looking for).
n After starting the search for "findword", find the next occurrence of "findword" in the file.

Numerous tutorials exist to dive deeper in the world of vi:

Install Ubuntu Server

Conduct preliminary checks and follow the instructions provided below to set up your home server.

Preliminary checks

Checklist Description
Is my hardware compatible with Linux? Test it with a Live USB or VirtualBox
• Check the compatibility database
Ask the Internet
• Buy a Linux compatible computer, e.g. at Linux Preloaded or the Ministry of Freedom
Does my hardware fulfill the minimum requirements? • 2 GHz dual core processor
• 4 GB system memory (RAM)
• 25 GB of free storage space
Is my hardware plugged in? If you install Ubuntu Server 24.04 on a laptop, make sure it is plugged in.
Is the installation medium accessible? Check if your hardware has either a DVD drive or a free USB port.
Is my hardware connected to the internet? Check if the Internet connection is up and running.
Have I backed up my data? Back up your data, since everything stored on the hardware will be erased during the installation process!
Have I downloaded the latest Ubuntu Server version? Download the latest long-term support (LTS) version of Ubuntu Server, which is supported for 5 years, including security and maintenance updates. At the time of writing, the latest LTS was Ubuntu Server 24.04. Check out the most recent release cycle for more information.
Have I prepared a bootable device? Create a bootable USB drive with the downloaded .iso file. Alternatively, burn the downloaded .iso file to a DVD on a Windows, macOS or Ubuntu Linux machine.

Step-by-step guide

Instruction Description
Boot Insert the bootable DVD or USB drive and power on the hardware. Most machines will boot automatically from the DVD or USB drive. If that's not the case, try repeatedly hitting F12, ESC, F2 or F10 when the hardware starts up. This should provide access to the boot menu, where you can select the DVD or USB drive.
GRUB Select the menu entry Try or Install Ubuntu Server.
Welcome Select a language.
Installer update This screen appears if the server is already connected to the Internet. Select the menu entry Continue without updating.
Keyboard layout Select a keyboard layout.
Type of installation Select the default Ubuntu Server install option.
Network connections Make sure to set up a working Internet connection via Ethernet or WiFi. This is important for the rest of the process. Select Info to find out more about a given network.
Proxy These settings are optional. Provide the required information if you need to set up network proxies, else just skip this step.
Ubuntu archive Choose the Ubuntu repository. Default options should work fine.
Storage configuration Choose how to partition your disk. In this tutorial, we will use the entire disk:
• Select Set up this disk as an LVM group
• Select Encrypt the LVM group with LUKS to encrypt your server
• Provide a strong, unique security key and confirm

Caution: This step will erase all data and format the hard drive! Carefully review all settings! Make sure you backed up your data!
Profile setup Setup the user and server profile. For the purpose of this tutorial, we'll choose the following configuration (adapt accordingly):
• Your name (this is the name of the system root user): gofossroot
• Your server's name (this is the name of your server): gofossserver
• Pick a username (same name as the system root user): gofossroot
• Password: provide a strong, unique password and confirm
SSH setup These settings are optional. Just leave this section blank and continue.
Featured Server Snaps These settings are optional. Just leave this section blank and continue.
Wrap up Wait for the installation to finish. Once Ubuntu Server is installed, remove the installation medium and press ENTER when prompted.


Linux get ip address

LAMP Stack

LAMP, an acronym for Linux, Apache, MySQL, and PHP/Perl/Python, represents a common web server configuration. After rebooting, access your Ubuntu Server, decrypt the partition with the security key, and enter the root credentials. Install the LAMP stack by following the instructions below.

Step-by-step guide

Update system packages and install the LAMP stack:

sudo apt update
sudo apt upgrade
sudo apt install lamp-server^

Mind the trailing caret in the command sudo apt install lamp-server^. It indicates that lamp-server is a meta package, which installs Apache, MySQL, and PHP along with other packages and dependencies.

Verify that Apache has been successfully installed (the latest version number should appear), automatically start Apache after each reboot, and check Apache's current status (which should be Active):

apachectl -V
sudo systemctl enable apache2
sudo systemctl start apache2
sudo systemctl status apache2

Same procedure for MySQL:

mysql -V
sudo systemctl enable mysql
sudo systemctl start mysql
sudo systemctl status mysql

Make sure PHP has been successfully installed (the latest version number should appear):

php -v

Finally, some clean up:

sudo apt autoremove && sudo apt clean


How to set static ip

Static IP

The DHCP protocol assigns dynamic IPs to your home network devices, including your server. It's recommended to assign a static IP address to avoid frequent reconfiguration. The choice of the static IP depends on your network's setup. Common ranges include 192.168.0.xx or 192.168.1.xx. Modify your server settings accordingly, as shown below. Make sure to adjust commands for the chosen IP address.

Step-by-step guide

Network interface

First, let's find out the name of the server's network interface:

ip link show

A list of all network interfaces should be displayed:

  • The first entry is most likely labelled lo, the loopback interface
  • The Ethernet interface should be labelled something like enpXsY, for example enp0s1 or enp1s3
  • The WiFi interface should be labelled something like wlpXsY, for example wlp0s1 or wlp2s3

For the purpose of this tutorial, let's assume that the server's network interface is labelled enp0s3 (adjust accordingly).

Default gateway

Time to find out the name of the default gateway:

ip route show

The terminal should display a line containing the IP address of the default gateway, something similar to default via 192.168.1.1 dev enp0s3 proto dhcp. For the purpose of this tutorial, let's assume that the address of the standard gateway is 192.168.1.1 (adjust accordingly).

Network configuration

Modify the network configuration file:

sudo mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
sudo vi /etc/netplan/01-netcfg.yaml

Add the following content, while paying attention to the correct indentation and making sure to adjust each line according to your setup:

  • Specify the correct network interface. In this example we use enp0s3, but your Ethernet interface might be called enp0s1 or you might use a WiFi interface, let's say wlp0s1. In this case you need to replace the line ethernets: with wifis and the line enp0s3 with wlp0s1.
  • The entry dhcp4: no tells us that the server is assigned a static IP address. In this example we use 192.168.1.100, but you can choose another static IP address.
  • Specify the default gateway. In this example we use 192.168.1.1, but your default gateway might be labelled 192.168.0.1 or something else.
  • Select a DNS provider. In this example we use DNS4EU, but you can select the DNS provider of your choice.
network:
  version: 2
  ethernets:
    enp0s3:
      dhcp4: false
      addresses: [192.168.1.100/24]
      routes:
      - to: default
        via: 192.168.1.1
      nameservers:
         addresses: [86.54.11.1, 86.54.11.201]

Save and close the file by hitting ESC and typing :wq!.

Restrict access rights to the network configuration file:

sudo chmod 600 /etc/netplan/01-netcfg.yaml

Desactivate cloud-init to ensure your network configuration is not overridden upon reboot:

sudo touch /etc/cloud/cloud-init.disabled

Finally, apply all changes and reboot:

sudo netplan apply
sudo reboot

Verify the IP address:

ip add
Are there any privacy respecting DNS providers?

DNS provider Country DNS #1 DNS #2 Privacy Policy
DNS4EU Europe 86.54.11.1 86.54.11.201 Privacy Policy
Digitalcourage Germany 5.9.164.112 -- Privacy Policy
UncensoredDNS Denmark 89.233.43.71 91.239.100.100 Privacy Policy
Dismail Germany 116.203.32.217 159.69.114.157 Privacy Policy
DNS Watch Germany 84.200.69.80 84.200.70.40 --
FDN France 80.67.169.12 80.67.169.40 --
OpenNIC Various Various Various Various


What is static IP

Remote SSH

Establish remote access to your server from another computer, known as client. This allows your server to remain headless, without peripherals like a screen, keyboard or mouse. The remote connection is done by Secure Shell (SSH), ensuring robust authentication and encryption.

Step-by-step guide

Server setup

Let's start with the server. Run the following commands to install OpenSSH:

sudo apt install openssh-server

Create an administrator user with privileges to remotely connect to the server. For the purpose of this tutorial, we'll call this user gofossadmin. Any other name will do, just make sure to adjust the relevant commands accordingly. When prompted, provide a strong, unique password:

sudo adduser gofossadmin
sudo usermod -a -G sudo gofossadmin

Switch to the new account and test its sudo powers by updating the system:

su - gofossadmin
sudo apt update

Client setup

Now, let's set up the client. For the purpose of this tutorial, we assume the client machine runs a GNU/Linux distribution, for example Ubuntu. If your client runs Windows or macOS, use available system tools or install a SSH client such as PuTTY.

Open a terminal on the Linux client machine with the CTRL + ALT + T shortcut, or click on the Activities button on the top left and search for Terminal. Now create the same administrator user gofossadmin as on the server (adjust the name according to your own setup). Provide a strong, unique password when prompted:

sudo adduser gofossadmin

Log into the new administrator account, create a hidden directory where SSL keys will be stored and provide this directory with the right permissions:

su - gofossadmin
mkdir /home/gofossadmin/.ssh
chmod 755 /home/gofossadmin/.ssh

Generate a public/private key pair which secures the remote login to the server. Run below commands, follow the on-screen instructions and, when prompted, provide a strong, unique SSH passphrase:

cd /home/gofossadmin/.ssh
ssh-keygen -t RSA -b 4096

The output should look something like this:

Generating public/private RSA key pair.
Enter file in which to save the key (/home/gofossadmin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): *******
Enter same passphrase again: ********
Your identification has been saved in /home/gofossadmin/.ssh/id_rsa.
Your public key has been saved in /home/gofossadmin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:erdBxn9i/ORLIJ4596DvfUIIPOyfFnSMQ4SieLIbSuxI gofossadmin@gofossclient
The key's randomart image is:
+---[RSA 4096]----+
|   .+.+=     o   |
|       ..oo.+ o  |
| .S+..     %..   |
|         o+o. o  |
|        So*o o = |
|   ..oo.+     A +|
| ..+ooo       .oo|
|  .o...+  .E..   |
|         .. o==.%|
+----[SHA256]-----+

Transfer the public key from the client to the server. Make sure to replace the administrator name and IP address according to your own setup, and provide the gofossadmin password when prompted (not the SSH passphrase!):

ssh-copy-id gofossadmin@192.168.1.100

That's it! From now on you can remotely log into the server from the client machine. Just open a terminal, switch to the administrator account and connect to the server using your SSH passphrase. Don't forget to adjust the administrator name and IP address as required:

su - gofossadmin
ssh gofossadmin@192.168.1.100


Ubuntu static IP

Support

For further details or questions on Ubuntu Server, refer to Ubuntu's documentation, tutorials, wiki or community for help.