Many people don’t know how to build their own server. Here, the editor of Kenpai Technology (kenpai.com ) will introduce to you how to build your own server and the methods and techniques for building a server. I hope it will be helpful to everyone.
Step 1: Choose your hardware
The threshold for a personal server is lower than you think: a second-hand small host for 200-300 yuan, or an unused laptop, or a low-power host with an ITX motherboard and a small chassis. If you have enough budget and don’t care about power, you can even buy a tower server. In short, the hardware price range of personal servers is very smooth, and you can find a suitable solution from a few hundred to tens of thousands. I suggest starting with a small host or an old laptop.
Common functions of home servers include: home NAS, download machine, smart home server, home theater, living room game console, soft router, surveillance video recorder, etc. In order to meet the above requirements, I have the following suggestions for the hardware of the small host:
1. CPU with 4 cores or more and memory with 8G or more to meet the performance requirements of multi-tasking;
2. There are more than 2 hard disk slots, or at least 1 onboard hard disk + 1 2.5-inch SATA hard disk slot (the system and data are on 2 independent hard disks respectively);
3. The small host used as a soft router should have more than 2 network ports, and as an audio and video server, it is best to support HDMI2.0 or above;
I recommend two reference configurations: CPU: J4105 Memory: 8G or CPU: N4100 Memory: 8G. The current price should be around five or six hundred yuan.
Here is another tip: small hosts are usually powered by 12V-19V DC. The cost of low-voltage DC power supply plus UPS is much lower than AC power supply. There are many mature solutions for 18650 lithium batteries on the Internet, which come with DC male and female connectors and can be used out of the box. Therefore, it is recommended to equip the small host with a rechargeable battery to act as a UPS, which costs only a few dozen yuan.
The best home server hardware for beginners, in my opinion, is an old laptop that is not in use. The advantages of an old laptop are as follows:
1. The laptop comes with its own battery, which is equivalent to having its own UPS;
Second, the notebook comes with a screen, keyboard, and touchpad, and basically does not require other peripherals for operation and maintenance, making it easy to use;
3. Laptops generally do not consume much power. When the screen is off, the power consumption does not exceed 15W, which is not much higher than that of a small host.
4. Laptops generally have 3 hard drive slots, which is convenient for expanding storage (the optical drive slot of the laptop can also be converted into a hard drive slot);
The price of an old laptop is close to that of a small host with the same performance. You can find a laptop that can be used as a home server for 500 or 600 yuan. However, I would like to remind you of a few points:
1. The minimum performance recommendation for an old laptop is to support smooth operation of Windows 10. It is not recommended to choose a laptop that is too old even if it is cheap;
Second, thin and light notebooks that do not support expansion of hard disks and only have onboard hard disks (usually 64G, 128G) are not recommended;
The playability of building a host by yourself is stronger than the above two solutions. The advantages of the host over the small host and laptop are as follows:
1. It has a PCI-E interface and powerful expansion capabilities (installing 10G network cards, SAS disk array cards, etc.);
Second, the chassis can be customized with multiple disk slots, making it more suitable as a home NAS;
3. High performance ceiling. If you don’t consider power consumption and directly increase the CPU, the performance will be stronger. You can build a pretty good personal server for 2,000 yuan. For example, the cost of a small host with Ryzen 5600G is less than 3,000 yuan, but the performance is not in the same level as NAS of the same price.
If your goal is a real commercial server, then among rack servers, blade servers, and tower servers, tower servers are more suitable for home use. Tower servers are about the same size as home computer hosts. You can learn about Dell’s Power Edge series and HP’s MicroServer Gen series. Standard server hardware is more suitable for enthusiasts in terms of price and power consumption. For general users, this type of hardware has excessive performance as a home server.
I believe that after reading the above content, everyone has a basic understanding of how to choose hardware and the price of hardware. If you need my help to recommend specific hardware, you can send me a private message or leave a message directly.
Let me share my own hardware solution: Since I work in a different place, I have two devices at home and in my rental house respectively: N4100+8G small host (originally bought for 600 yuan), 6200U+8G ThinkPad (an idle notebook). I also eliminated an HP T610 thin client: AMD T56N+4G (originally bought for 160 yuan), the main problem was that the performance was not enough.
Step 2: Install the system
The technical threshold for a personal server is really not high. If there is one, there is only one: being able to install the system. Once you have tried each system, you have successfully gotten started.
What system should I choose for my server? Unlike servers in enterprise scenarios, personal servers do not need to be trouble-free all year round, do not need to consider fault tolerance and redundancy, and even firewall settings do not need to be too complicated, so you are quite free to install any system. Whatever NAS on the market can do, Windows 10 with Docker for Windows installed can basically do it. So if you don’t want to bother installing Windows 10, just install Windows 10. But I still strongly recommend Linux distributions because SSH is so convenient.
If you want to learn Linux, you need to master three basic skills: 1. Basic Bash shell commands; 2. Basic Vim operations; 3. Basic SSH operations. You can find tutorials online to learn these skills.
There are many Linux distributions. I have come across Ubuntu (currently in use), Manjaro, and Linux mint (suitable for computers with low configuration). These can be used out of the box, and there are some reference materials online. For domestic Linux, you can choose Deepin. As for Arch Linux and Gentoo Linux, which need to be compiled and installed, they are not suitable for novices. If your personal server has excess performance (more than 8 cores, more than 32G memory), you want to build multiple systems. You can learn about ESXi and PVE, and use virtualization technology to run multiple systems at the same time. However, I am not so obsessed with performance. Docker can already meet the needs of most usage scenarios, so I don’t have the need to build ESXi myself.
I won’t explain how to install the system as it is basic knowledge here, but I recommend a magic tool for system installation: Ventoy. After Ventoy creates an installation USB flash drive, it will generate two partitions. The smaller partition is the boot partition, and the larger partition is the data partition. Put the system image and commonly used software packages in the data partition.
After copying the system image to the Ventoy bootable USB drive, set the BIOS to boot from the USB drive to start installing the system. The most powerful feature of Ventoy is that it supports copying multiple system images at the same time, and you can choose to install the image without having to repeatedly make a bootable USB drive. If you are installing and maintaining Windows, you are more accustomed to PE with richer functions. I recommend two of them: U-Start and Micro PE. Most of the other PE systems have a lot of private goods.
Let me share a common misconception among novices: Should I choose between Windows and Linux? First of all, never think in a fan circle way. You don’t have to choose between Windows and Linux. Both systems are very powerful and worth learning. Windows is more convenient for daily use, but Linux is also very powerful in some professional situations.
Step 3: Network Settings
If your server has a public IP address, then remote access to the server is not a difficult task. However, most people do not have a fixed public IP address. In this case, virtual LAN solutions such as zerotier and tailscale can help you. I first came into contact with zerotier, so I will use zerotier as an example. Tailscale is based on wireguard and I believe the effect should also be good.
First, register an account on the zerotier official website, and then create a virtual LAN on the Networks page. You will get a NETWORK ID, through which you can add other devices to the same virtual LAN.
The next step is to install the zerotier client on different devices, and then add the NETWORK ID set above. The windows client has a UI interface that is relatively simple to operate. I will mainly introduce the operation of the Linux client:
#Install zerotiercurl -s https://install.zerotier.com | sudo bash#Join the network after successful installationsudo zerotier-cli join NETWORK ID#Restart the service to ensure that the settings take effectservice zerotier-one restart#Zerotier is mainly managed by zerotier-cli (operating program) and zerotier-one (server)
In addition to Windows and Linux, zerotier can also be installed on openwrt routers and smartphones. After your device joins the network, there is another step to do, which is to enter the background and check the device to join the virtual LAN. At this time, you can see the virtual LAN IP of the device in Manged IPs. Through this IP, different devices can communicate as if they were in a local area network. Zerotier is based on UDP communication. If both parties can achieve a direct connection, the speed is still very good. If a direct connection is not achieved, the speed is less than 1M and the delay is more than 500ms. The network situation can be improved by setting up a moon server. This requires the purchase of a cloud server. I will introduce how to operate in the zerotier improvement article.
With a virtual LAN, you can set up various services through Docker on your home server and access them remotely.
Step 4: Deploy the application
Building a web service is no longer a difficult operation. The emergence of Docker makes service building very simple (current operations and maintenance are mainly focused on cluster maintenance). Docker is based on Linux, but Windows has WSL so it can also be installed. You can install Docker through Docker for Windows or in WSL. Here is a detailed introduction:
4.1 Install Docker
Install Docker on Ubuntu
sudo apt install docker.iosudo systemctl start docker sudo systemctl enable docker #If necessary, you can also install docker-composesudo apt install docker-compose
To install Docker on Windows, you can go to the Docker official website to download the Docker Desktop for Windows installation package and run the installation directly. From the user experience, I recommend using Docker in a native Linux environment.
4.2 Deployment of Applications
Server application deployment is to install different programs according to the needs. It is difficult to describe this content in a short article. For example, there is a lot of content in building a smart home server with homeassistant. So I will continue to add to it in the following articles. Here I will mainly talk about two methods of application deployment:
The first is direct installation. Software like Samba and Calibre can be installed directly. Both can be accessed through the local area network, and through zerotier, they can be accessed on the external network.
Samba – File Server
It is very simple to set up file sharing in Windows, and it is also very simple to install Samba in Linux:
#Install samba sudo apt install samba
After the installation is complete, you only need to set the designated folder to be shared. Other hosts can access the shared content of the server by simply accessing the LAN host IP address.
Calibre – Personal e-book library
The Windows version of Calibre is to download the installation package, while the Linux version can be installed using the command line:
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
After installing Calibre, open Calibre to start the content service. All devices in the local area network can access the library through the browser.
The second method is to install it through Docker. The advantage of Docker installation is that it is easy to install and delete. It can help your server build a lot of services and save a lot of configuration time. Docker can also run on Windows. I will continue to explain Docker in detail later, but here are a few applications:
For example, the speedtest service can tell you how fast the internet connection is between you and your server. It is very easy to install with docker. After installation, you only need to visit http://local:8090 to test the speed.
#Pull the image docker pull adolfintel/speedtest#Run speedtestdocker run –restart=always -d -p 8090:80 adolfintel/speedtest
The above is all about how to build your own server and the methods and techniques for building a server. I hope the above content can help you solve related problems.