User Tools

Site Tools


unraid:virtual:webpageu20.04

This is an old revision of the document!


Install www.brimble.com on Ubuntu 20.04 LTS as Unraid Virtual Machine

This will guide you through the setup of brimble.com on an installation of Ubuntu 20.04 LTS as an Unraid Virtual Machine.

VM Settings

  • Autostart: Yes
  • Name: brimble.com.20.04vX
  • Description: Brimblecom Webpage
  • CPU Mode: Host Passthrough
  • Logical CPUs: 6/7
  • Internal Memory: 4096
  • Max Memory: 4096
  • Machine: Q35-4.1
  • BIOS: OVMF
  • USB Controller: 2.0 (EHCI) (I don't have USB 3.0 on current hardware)
  • OS Install ISO: select the ubuntu - 20.04 iso
  • OS Install CDRom Bus: SATA
  • Primary vDisk Location: Auto if on the array, below options for ssd
    • /mnt/disks/samsung_ssd/brimble.com.20.04vX/vdisk1.img –> This one is vDisk on SSD (Current setup uses this)
    • /dev/disk/by-id/ata-“ID OF DRIVE” –> This one is passthrough
  • Primary vDisk Size: 40G
  • Primary vDisk Type: raw
  • Primary vDisk Bus: VirtIO if on the array, below options for ssd
    • VirtIO –> This one is vDisk on SSD (Current setup uses this)
    • SATA –> This one is passthrough
  • Unraid Share: /mnt/usr/backup
  • Unraid Mount tag: backup
    • Hit plus sign to add more shares (If after creation use XML mode (duplicate and increment function to 0x1))
  • Graphics Card: VNC
  • VNC Video Driver: QXL (best)
  • VNC Password: leave this blank (or set password if concerned folks will get access to unraid!)
  • VNC Keyboard: English-United States
  • Sound Card: none
  • Network MAC: whatever it is
  • Network Bridge: br0
  • USB Devices: none
  • Other PCI Devices: none

Install to Virtual Machine

  • Custom storage layout
  • Partitions: (ext4)
Size Location Notes
4 GB swap (primary) should be min sqrt(RAM) and max double RAM
6 GB / (logical) current install uses about 2.6 GB
5 GB /home (logical) current install uses about 45 MB
1 GB /boot (logical) current install uses about 145 MB
19.498 GB /var (logical) current install uses about 9.3 GB
4 GB /tmp (logical) current install uses about 21 MB
  • Full Name: Dirk Rockface
  • Server: brimble
  • User Name: dirk
  • Finish installing. I didn't install any “common packages” from the setup CD.

Setup

Update Packages

sudo apt-get update
sudo apt-get dist-upgrade

Install SSH Server

sudo apt-get install openssh-server

Mount Unraid Shares

  • add the following to /etc/fstab where backup is whatever you called the Unraid Mount tag and /mnt/backup is whatever folder you made in ubuntu to mount to.
    backup /mnt/backup 9p trans=virtio,version=9p2000.L,_netdev,rw 0 0
    • Note: if you've already created the VM and THEN added the unraid tag, your NIC name was changed (probably from enp1s0 to enp3s0) run ifconfig -a to see new name then modify /etc/netplan/50-cloud-init.yaml
    • Note: also, to add more shares after initial creation, use XML mode, duplicate the section, and increment the function to 0x1

Install ex-fat (for USB drives or FAT formats)

sudo apt-get install exfat-fuse exfat-utils

Reboot

sudo reboot -h now

Create ssh-rsa key auth

  • Turn off Password Auth
    sudo vim /etc/ssh/sshd_config
    UsePAM yes
    PasswordAuthentication no

Reboot

sudo reboot -h now

Install Tomcat

sudo apt-get install tomcat9

Copy webpage files

sudo rm -rf /var/lib/tomcat9/webapps/ROOT
sudo cp -a /mnt/backup/webpage/webapps/. /var/lib/tomcat9/webapps/
  • Note: You might have to set ownership and permissions back to normal for those folders
    sudo chown tomcat:tomcat webapps
    sudo chmod 755 webapps

Allow Directory Browsing

sudo vim /etc/tomcat9/web.xml
<init-param>
  <param-name>listings</param-name>
  <param-value>true</param-value>
</init-param>

Install MySql (if not using a docker)

sudo apt-get install mysql-server

Import database dump

sudo mysql -u root -p < dumpfile.sql

Create mysql user

sudo mysql -u root -p
CREATE USER 'dirk'@'localhost' IDENTIFIED BY 'password';
show databases;
GRANT ALL PRIVILEGES ON *.* TO 'dirk'@'localhost';
exit

Allow write access for user

GRANT FILE ON *.* TO 'dirk'@'localhost';
exit

Allow mysql to write to files

sudo aa-status
  • This should show mysqld in enforce mode
sudo vim /etc/apparmor.d/usr.sbin.mysqld
  • add folders near the bottom like this:
    /var/lib/tomcat9/webapps/ r,
    /var/lib/tomcat9/webapps/** rwk,
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
  • add at bottom:
    secure_file_priv=""
  • while in this file, decrease sleep time to avoid max connections (default is 8 hrs)
    wait_timeout = 20
  • Note: In order to get sql to write, I had to make everything in the webapps folder root:dirk (which it probably was) and the export folder 777. Not sure which of those did the trick (or both)
  • Note: New in mysqlserver v8: files writen from mysql are only readable by root and the mysql group so you have to add the use tomcat (the one reading the files in the march madness bracket) to the mysql group (the one creating the files)
    sudo usermod -a -G mysql tomcat
  • Changes will take effect after restart
    sudo reboot -h now

Tomcat - Mysql linking / JDK / JAVA cleanup

  • Install Java Development Kit
     sudo apt-get install default-jdk
  • Install Java / Mysql connector
     sudo apt-get install libmysql-java
  • Note: This was not supported in 20.04 at the time and must be installed manually.
  • Create symlink for connector
    sudo ln -sf /usr/share/java/mysql-connector-java.8.0.20.jar /usr/share/tomcat9/lib/mysql-connector-java.jar
  • Faster tomcat startup
  • New change for 20.04: had to add
    &serverTimezone=UTC

    to the end of the SQL_PARAMS section in all of the config.jsp files. They should be all converted for the next install and no action required. (hopefully)

  • If webinf files need to be compiled:
    sudo javac -cp /usr/share/java/servlet-api-3.0.jar:/usr/share/java/jsp-api-2.2.jar util/*.java
  • reboot
    sudo reboot -h now

Install Samba

sudo apt-get install samba
sudo smbpasswd -a dirk
sudo vim /etc/samba/smb.conf
[webapps]
  comment = Webpage Files
    path = /var/lib/tomcat9/webapps
    available = yes
    browsable = yes
    guest ok = yes
    read only = no
    writable = yes
    admin users = dirk
  • you may have to chmod correct permissions for webapps folder (775)

Add football season

LOAD DATA LOCAL INFILE "/home/dirk/2019o.csv" INTO TABLE games COLUMNS TERMINATED BY ',';
UPDATE games SET vscore = NULL where year = 2019;
UPDATE games SET hscore = NULL where year = 2019;

Allow rsync to run on own

sudo visudo -f /etc/sudoers.d/nopass
dirk ALL=(ALL:ALL) NOPASSWD:/usr/bin/rsync

Add cron job for backup

crontab -e
0 3 * * * /home/dirk/scripts/backup

Change timezone

sudo dpkg-reconfigure tzdata
unraid/virtual/webpageu20.04.1615432195.txt.gz · Last modified: by dirk