Silent low-power server and a total power consumption of about 8W.
Get rid of the annoying perl warnings:
sudo vi /etc/ssh/sshd_config
#AcceptEnv LANG LC_*
apt install powertop
powertop --html=/tmp/powertop.html
vi /usr/local/sbin/low_power_mode.sh
#!/bin/bash
# Set HDD spindown time to 3 minutes and idle disk now
hdparm -S 3 /dev/sdb
hdparm -y /dev/sdb
# VM writeback timeout
#echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs'
# Enable SATA link power management for host 0..3
echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy'
echo 'min_power' > '/sys/class/scsi_host/host1/link_power_management_policy'
echo 'min_power' > '/sys/class/scsi_host/host2/link_power_management_policy'
echo 'min_power' > '/sys/class/scsi_host/host3/link_power_management_policy'
# Enable Audio codec power management
echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'
# NMI watchdog should be turned off
echo '0' > '/proc/sys/kernel/nmi_watchdog'
# Runtime PM for I2C Adapter i2c-3 (i915 gmbus dpc)
echo 'auto' > '/sys/bus/i2c/devices/i2c-3/device/power/control'
# Runtime PM for I2C Adapter i2c-4 (i915 gmbus dpb)
echo 'auto' > '/sys/bus/i2c/devices/i2c-4/device/power/control'
# Runtime PM for I2C Adapter i2c-1 (i915 gmbus vga)
echo 'auto' > '/sys/bus/i2c/devices/i2c-1/device/power/control'
# Runtime PM for I2C Adapter i2c-2 (i915 gmbus panel)
echo 'auto' > '/sys/bus/i2c/devices/i2c-2/device/power/control'
# Runtime PM for I2C Adapter i2c-0 (i915 gmbus ssc)
echo 'auto' > '/sys/bus/i2c/devices/i2c-0/device/power/control'
# Runtime PM for I2C Adapter i2c-5 (i915 gmbus dpd)
echo 'auto' > '/sys/bus/i2c/devices/i2c-5/device/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx Series High Definition Audio Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1b.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx Series SoC Transaction Register
echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine
echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx Series Graphics & Display
echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series PCI Express Root Port 3
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.2/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor Z36xxx/Z37xxx Series Power Control Unit
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control'
# Runtime PM for PCI Device Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series PCI Express Root Port 1
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series SATA AHCI Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:13.0/power/control'
# Runtime PM for PCI Device ASMedia Technology Inc. ASM1062 Serial ATA Controller
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series SMBus Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series PCI Express Root Port 4
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.3/power/control'
# Runtime PM for PCI Device Intel Corporation Atom Processor E3800 Series PCI Express Root Port 2
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control'
.
chmod +x /usr/local/sbin/low_power_mode.sh
vi /etc/rc.local
#!/bin/bash
/usr/local/sbin/low_power_mode.sh
exit 0
.
chmod +x /etc/rc.local
Power consumption in Watts, before and after results (the spike is the reboot):
vi /etc/vim/vimrc.local
NFS has little network overhead, making it ideal for streaming video from the server to the mediaplayer.
apt install nfs-kernel-server
vi /etc/exports
/home 192.168.0.0/24(ro,fsid=0,nohide,insecure,no_subtree_check,async)
/home/photos 192.168.0.0/24(ro,nohide,insecure,no_subtree_check,async)
apt install postgresql
vi /etc/postgresql/10/main/pg_hba.conf
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.0.0/24 md5
vi /etc/postgresql/10/main/postgresql.conf
listen_addresses = '*'
.
systemctl restart postgresql
Create users/database/permissions:
sudo su - postgres
psql
\password postgres
# <setup main password>
CREATE ROLE <your-username> LOGIN ENCRYPTED PASSWORD '<your-password>';
CREATE DATABASE <your-database>;
\c <your-database>
GRANT ALL ON ALL TABLES IN SCHEMA public TO <your-username>;
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO <your-username>;
Basic packages to support mediawiki:
apt install nginx php-fpm php-intl php-cli php-apcu php-mbstring php-pgsql php-dom imagemagick
The mediawiki version which comes with Ubuntu is too old, just download the latest stable version from mediawiki.org:
mkdir /home/www/website
cd /home/www/website
wget http://download.wikimedia.org/mediawiki/1.34/mediawiki-1.34.0.tar.gz
tar xvzf mediawiki-1.34.0.tar.gz
ln -s mediawiki-1.34.0 wiki
chown -R www-data:www-data /home/www/website/wiki/images
chown -R www-data:www-data /home/www/website/wiki/cache
Go to the website and walk through the installation wizard, including copying the LocalSettings.php (Keep rewrite rules disabled in nginx config, while going through the installation wizard)
vi /etc/php/7.2/fpm/php.ini
upload_max_filesize = 10M
open_basedir = /tmp:/home/www/website/wiki:/home/www/otherwebsite/wiki
extension=gd.so
extension=intl.so
extension=iconv.so
session.save_path = "/var/lib/php/sessions"
vi /etc/php/7.2/mods-available/opcache.ini
zend_extension=opcache.so
opcache.enable=1
#opcache.enable_cli=1
opcache.file_cache=/tmp/php-opcache
vi /etc/tmpfiles.d/php-opcache.conf
d /tmp/php-opcache 1777 root root 1d
And active the opcache:
systemd-tmpfiles --create /etc/tmpfiles.d/php-opcache.conf
systemctl restart php7.2-fpm
vi LocalSettings.php
$wgScriptPath = "";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
vi /etc/nginx/sites-available/website.conf
server {
server_name website.eu www.website.eu;
root /home/www/website/wiki;
index index.php index.html;
access_log /var/log/nginx/access-website.log;
error_log /var/log/nginx/error-website.log;
client_max_body_size 50M;
location ~ \.htaccess {
deny all;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php;
}
location ^~ /maintenance/ {
return 403;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri @rewrite;
}
location ^~ /files/ {
alias /home/www/jorgbosman/files/;
}
location /robots.txt {
alias /home/www/jorgbosman/files/robots.txt;
}
location /favicon.ico {
alias /home/www/jorgbosman/files/favicon.ico;
}
}
apt update
apt install software-properties-common
add-apt-repository ppa:certbot/certbot
apt update
apt install python-certbot-nginx
certbot --nginx
Install Java8:
Download jdk-8u231-linux-x64.tar.gz from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
(create an account and accept the license agreement first)
mkdir /opt/jdk
cp -rf jdk-8u231-linux-x64.tar.gz /opt/jdk/
cd /opt/jdk/
tar -zxf jdk-8u231-linux-x64.tar.gz
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_231/bin/java 100
update-alternatives --display java
This should show:
java - auto mode
link best version is /opt/jdk/jdk1.8.0_231/bin/java
link currently points to /opt/jdk/jdk1.8.0_231/bin/java
link java is /usr/bin/java
/opt/jdk/jdk1.8.0_231/bin/java - priority 100
/opt/jdk/jdk1.8.0_231/bin/javac - priority 100
.
update-alternatives --config java
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | tee /etc/apt/sources.list.d/100-ubnt-unifi.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
apt update
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
apt update
apt install unifi
Modify java version in the init.d script:
vi /etc/init.d/unifi
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Setup the db properly:
service unifi stop
mongod --dbpath /usr/lib/unifi/data/db --port 27117 --repair
chown unifi:unifi /usr/lib/unifi/data/db/*
Modify mongod so it starts properly:
rm /usr/lib/unifi/bin/mongod
vi /usr/lib/unifi/bin/mongod
#!/bin/bash
exec /usr/bin/mongod ${*//--nohttpinterface/}
.
chmod +x /usr/lib/unifi/bin/mongod
echo "deb http://linux-packages.resilio.com/resilio-sync/deb resilio-sync non-free" | sudo tee /etc/apt/sources.list.d/resilio-sync.list
wget -qO - https://linux-packages.resilio.com/resilio-sync/key.asc | sudo apt-key add -
apt update
apt install resilio-sync
sudo vi /etc/resilio-sync/config.json
"listen" : "0.0.0.0:8888"
.
systemctl enable resilio-sync
apt install transmission-daemon
vi /etc/transmission-daemon/settings.json
"download-dir": "/data/download",
"incomplete-dir": "/data/download",