How to set up a server with a home computer
您是否曾經想過在家中擁有一台自己的伺服器,用來架設網站、儲存檔案、運行遊戲伺服器或進行其他實驗?利用現有的家用電腦或添購一些基本設備,架設一台家庭伺服器並非難事。本篇文章將引導您完成基本步驟。
步驟一:選擇硬體
You can choose to use an old computer sitting around the house, or buy dedicated hardware. Factors to consider include:
- Processor (CPU): 5. Due to the nature of the work, it is necessary to process a large number of images into a unified format, and the extra bits can be white backgrounds only. Photoshop's Camera Raw can only process batches, and although there are some online tools, they are paid. Suddenly, I asked ChatGPT, and when I first asked, I didn't want to use Python because I wasn't familiar with this type of code language. However, I later found that Python can perform this type of simple, yet complex and tedious task, so I tried to ask it step by step. After asking, I found that I wanted to add more questions, so I asked again. The following is the code obtained. from PIL import Image import os def process_images(folder): total_images = [...] Decide based on your use case. For a simple file server or small website, an entry-level CPU will suffice. For running a virtual machine or a game server, a more powerful CPU is required
- Memory (RAM): At least 4GB, 8GB or more recommended, especially when running multiple services.
- Storage (Hard Drive): 依據您要儲存的資料量決定。建議使用 SSD 作為系統碟以提升效能,並搭配大容量 HDD 作為資料碟。
- Network Interface Card (NIC): It is recommended to use a wired network connection for stable speed, with Gigabit Ethernet (1000 Mbps) being the minimum requirement.
步驟二:選擇作業系統
伺服器作業系統的選擇多樣,常見的有:
- Windows Server : Powerful, user-friendly graphical interface, but requires license fees.
- Windows (Home/Pro): 也可用於架設簡單伺服器,但功能和穩定性不如 Server 版本。
- Linux distributions (such as Ubuntu Server, CentOS, Debian): 免費、開源、穩定且資源佔用少,是家庭伺服器的熱門選擇,但需要一些指令操作基礎。
- FreeNAS/TrueNAS: Based on FreeBSD, designed specifically for network-attached storage (NAS), suitable for file servers.
對於初學者,若熟悉 Windows,可先從 Windows 開始;若想深入學習,Linux 是個好選擇。
步驟三:安裝伺服器軟體
Install the appropriate software according to your needs:
- 網頁伺服器: Apache, Nginx (common on Linux), IIS (built-in on Windows).
- 檔案伺服器: Samba (Linux/Windows file sharing), FTP server (such as FileZilla Server).
- Database Servers: Calls a sentiment analysis API to determine the sentiment (positive/negative/neutral) of each comment
- 媒體伺服器: Plex, Jellyfin。
- Remote desktop/SSH: RDP (Windows), SSH (Linux)。
安裝過程通常依據您選擇的作業系統和軟體而異,請參考官方文件進行安裝與設定。
步驟四:網路設定
為了讓伺服器能穩定地被內部或外部網路存取,需要進行一些網路設定:
- Set Static Internal IP : Set a fixed internal IP address for the server in your router or server operating system to avoid connectivity issues due to DHCP changes.
- Configure port forwarding: 在路由器中設定,將外部網路對特定連接埠 (Port) 的請求,轉送到您伺服器的內部 IP 和對應的連接埠。例如,網頁伺服器通常使用 80 (HTTP) 和 443 (HTTPS) 埠。
步驟五:安全考量
Safety is one of the most important aspects of setting up a server:
- Firewall Enables the operating system's built-in firewall and configures firewall rules on the router to open only the necessary ports.
- Regular Updates: Keep operating systems and all server software up to date and patch known security vulnerabilities.
- Strong password: Set strong passwords for all accounts and consider using SSH key authentication (if using Linux).
- Backup: Regular backups of important data.
- Monitoring: Watch for login activity and resource usage on the server.
Step 6: Dynamic DNS (optional)
大多數家用網路的公開 IP 位址 (Public IP) 是動態變動的。如果您需要從外部網路透過一個固定的網域名稱 (Domain Name) 連線到您的伺服器,您需要使用動態 DNS (Dynamic DNS, DDNS) 服務。
DDNS services (such as No-IP, Dynu) provide a client program that is installed on your server or router, which automatically updates DNS records when your public IP changes, so that your domain name always points to the correct IP address.
Conclusion
在家架設伺服器是一個有趣且充滿學習機會的過程。從選擇硬體、作業系統,到設定網路和確保安全,每一步都需要細心規劃。雖然初期設定可能有些複雜,但完成後您將擁有一個完全由自己掌控的多功能平台。祝您架設順利!
