Raspberry 4 with SSD to Ubuntu server and Webmin control panel ENG
In this note, I will tell you how to make a cool home server out of your raspberry 4. To do this, you must already have:
- Raspberry 4
- SSD disk — it is not required, you can do it all with an sd card, but this is very unfortunate, because the drive plays a key role in the server
- SD Card
- Static IP
Here is my raspberry 4, I bought more UPS and WiFi socket, in case the server freezes:
1. I used the build and installation method from here https://jamesachambers.com/raspberry-pi-4-ubuntu-server-desktop-18-04-3-image-unofficial/. I will post only a brief instruction, all the information in more detail you will find in the author.
Using a solid state on the Ubuntu image is incredibly easy (even easier than Raspbian). Here’s the instructions:
- Download the Server image https://github.com/TheRemote/Ubuntu-Server-raspi4-unofficial/releases above and write it to your SD card with https://www.balena.io/etcher/ or another
- Navigate to the /boot drive on your SD card and open cmdline.txt
- Change the part of the line that says root=/dev/mmcblk0p2 to root=/dev/sda2
- Now burn the image again to your SSD
- Plug in both the SSD and Micro SD and boot up the Pi
access the server
- Username: ubuntu
- Password: ubuntu
2. Now I will describe configuring the server using the webmin panel on nginx:
timezone server
sudo dpkg-reconfigure tzdata
First and foremost 99% of your updates will be coming from Ubuntu’s official repositories directly from apt as it would with any official image. The only things set on package hold (using apt-mark hold flash-kernel linux-raspi2 linux-image-raspi2 linux-headers-raspi2 linux-firmware-raspi2) to prevent them from overwriting the firmware already on the image. If you wish, you may apt-mark unhold those same packages and you will be 100% official Ubuntu. Your installation will probably immediately break if you do it now, but when the RPI 4 support is backported this is how you can change back to theirs.
sudo apt-mark hold flash-kernel linux-raspi2 linux-image-raspi2 linux-headers-raspi2 linux-firmware-raspi2
now you can
sudo apt-get update && sudo apt-get upgrade
swap
free -h sudo fallocate -l 8G /swapfile sudo ls -lh /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile sudo swapon --show sudo cp /etc/fstab /etc/fstab.bak echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab free -h
Change the settings for paging The swappiness parameter determines how often the system loads data from RAM to swap space. Its value is expressed as a number from 0 to 100 percent. When values are close to 100, the system will try to upload more data to the swap to unload RAM. Depending on the application memory profile and the tasks assigned to the server, in some cases this is a plus. We can see the current value of the swappiness factor by entering the following:
cat /proc/sys/vm/swappiness sudo sysctl vm.swappiness=10 sudo nano /etc/sysctl.conf add down vm.swappiness=10
Change settings-load the cache, defaults to 100 Another important option is vfs_cache_pressure. It controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects. Basically, this is file system access data. As a rule, it is not so easy to find them, and they are requested often, so it is very convenient to use cache memory in this case. To find out the current value of this parameter, you can request the proc file system:
cat /proc/sys/vm/vfs_cache_pressure sudo sysctl vm.vfs_cache_pressure=50 sudo nano /etc/sysctl.conf add down vm.vfs_cache_pressure=50
use root to ssh
sudo nano /etc/ssh/sshd_config PermitRootLogin yes sudo systemctl restart ssh || systemctl restart sshd
Now install Webmin
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python wget http://prdownloads.sourceforge.net/webadmin/webmin_1.941_all.deb sudo dpkg --install webmin_1.941_all.deb wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=arm64] http://download.webmin.com/download/repository sarge contrib" sudo nano /etc/webmin/miniserv.conf ssl=0 sudo reboot
Open you control panel http://192.168.1.X:10000/ and install
- Fail2Ban
- Postfix
echo 'virtual_alias_maps = hash:/etc/postfix/virtual' | sudo tee -a /etc/postfix/main.cf echo 'home_mailbox = Maildir/' | sudo tee -a /etc/postfix/main.cf sudo dpkg-reconfigure postfix General type of mail configuration?: Internet Site System mail name: example.com (not mail.example.com) Root and postmaster mail recipient: sammy Other destinations to accept mail for: $myhostname, example.com, mail.example.com, localhost.example.com, localhost Force synchronous updates on mail queue?: No Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 Mailbox size limit: 0 Local address extension character: + Internet protocols to use: all sudo nano /etc/mailname MYDOAINNAME.COM
- Mysql
- Ngnix
/etc/init.d/apache2 stop update-rc.d apache2 remove sudo apt-get install nginx sudo /etc/init.d/nginx start
- php
sudo add-apt-repository ppa:ondrej/nginx sudo add-apt-repository ppa:ondrej/php sudo apt-get update && sudo apt-get upgrade sudo apt install php-fpm php-mysql sudo apt install memcached libmemcached-tools sudo apt install php7.4 php7.4-cgi php7.4-mysql php7.4-curl php7.4-gd php7.4-imap php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-mbstring php7.4-zip php7.4-cli php7.4-fpm memcached php7.4-curl php7.4-xml php-common php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-bcmath sudo apt install php-apcu php-memcached php-imagick sudo service php7.4-fpm status sudo nano /etc/nginx/sites-available/default # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.4-fpm.sock; # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } sudo service nginx reload
Install virtual min and usermin
wget http://prdownloads.sourceforge.net/webadmin/usermin_1.791_all.deb sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl sudo dpkg --install usermin_1.791_all.deb
- download https://download.webmin.com/download/virtualmin/virtual-server-6.08.gpl.wbm.gz
- irtualmin in Webmin Configuration> Webmin Modules, you should select the option «Grant access to all Webmin users install via the Webmin config > modules admin panel
- reboot
sudo nano /etc/usermin/miniserv.conf ssl=0 sudo reboot
install nginx in control panel
git clone https://github.com/Real-Gecko/virtualmin-nginx-fpm.git tar -zcf virtualmin-nginx-fpm.tar.gz virtualmin-nginx-fpm
Virtualmin in Webmin Configuration> Webmin Modules, you should select the option «Grant access to all Webmin users install via the admin panel install via the admin panel virtualmin-nginx-fpm.tar.gz
/etc/init.d/php7.4-fpm start sudo systemctl restart nginx
Now you can create users and their sites. I use cloudflare as an NS server. I delegate the domain to cloudflare and already specify the server’s IP address in cloudflare.