How to set up Apache on Armbian

1. Install apache and php
sudo apt install apache2
sudo apt install php

2. Enable user directory
in /etc/apache2/mods-enabled/
sudo ln -s ../mods-available/userdir.conf userdir.conf
sudo ln -s ../mods-available/userdir.conf userdir.conf

3. Remove Indexes for securiety in /etc/apache2/apache2.conf
<Directory /var/www/>
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

4. Enable php engine for user directory in /etc/apache2/mods-enable/php7.3.conf
<FilesMatch “^\.ph(ar|p|ps|tml)$”>
    # Require all denied
</FilesMatch>
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        # php_admin_flag engine Off
    </Directory>
</IfModule>

Slow Down Host Network with Hyper-V External Network Switch

Problem:
If external virtual switch is created on Virtual Switch Manager, network performance of host network is significantly decreased. Internal virtual switch is not affected.

Solutions:
1. Using ICS of host network
https://www.technig.com/connect-hyper-v-machines-to-internet/

2. Using RRAS for NAT configuration
https://www.dell.com/support/kbdoc/en-us/000118763/configuring-windows-server-2012-r2-as-a-router

3. Disabling VMQ and/or RSC
https://www.dell.com/support/kbdoc/en-us/000145221/windows-server-slow-network-performance-on-hyper-v-virtual-machines-with-virtual-machine-queue-vmq-enabled
https://docs.microsoft.com/en-us/windows-server/networking/technologies/hpn/rsc-in-the-vswitch

For VMQ:> Set-VMNetworkAdapter –ManagementOS -Name -VmqWeight 0
For RSC:> Set-VMSwitch -Name vSwitchName -EnableSoftwareRsc $false

4. Using NAT via Powershell
https://petri.com/using-nat-virtual-switch-hyper-v
https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/setup-nat-network

New-VMSwitch -SwitchName “NATSwitch” -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceAlias “vEthernet (NATSwitch)”
New-NetNAT -Name “NATNetwork” -InternalIPInterfaceAddressPrefix 192.168.0.0/24

Install Windows Server 2019 on Deskmini A300

0. Create VHDX for Windows Server (optional)

D:\vhd>diskpart

Microsoft DiskPart 버전 10.0.19041.610

Copyright (C) Microsoft Corporation.
컴퓨터: WORK

DISKPART> create vdisk file=d:\vhd\windows2019.vhdx maximum=262144 type=expandable

  100 퍼센트 완료

DiskPart가 가상 디스크 파일을 만들었습니다.

DISKPART> select vdisk file=d:\vhd\windows2019.vhdx

DiskPart가 가상 디스크 파일을 선택했습니다.

DISKPART> attach vdisk

  100 퍼센트 완료

DiskPart가 가상 디스크 파일을 연결했습니다.

DISKPART> create partition primary

DiskPart에서 지정한 파티션을 만들었습니다.

DISKPART> format fs=ntfs quick

  100 퍼센트 완료

DiskPart가 볼륨을 성공적으로 포맷했습니다.

DISKPART> assign

DiskPart에서 드라이브 문자 또는 탑재 지점을 할당했습니다.

DISKPART> exit

DiskPart 마치는 중...

D:\vhd>dism /get-wiminfo /wimfile:g:\sources\install.wim

배포 이미지 서비스 및 관리 도구
버전: 10.0.19041.746

이미지 정보 : g:\sources\install.wim

인덱스 : 1
이름 : Windows Server 2019 Standard
설명 : (권장) 이 옵션은 대부분의 Windows 그래픽 환경을 생략합니다. 명령 프롬프트와 PowerShell을 사용하거나 Windows 관리 센터 또는 기타 도구를 사용하여 원격으로 관리합니다.
크기 : 8,172,089,251바이트

인덱스 : 2
이름 : Windows Server 2019 Standard (데스크톱 경험)
설명 : 이 옵션은 별도의 드라이브 공간을 사용하는 완전한 Windows 그래픽 환경을 설치합니다. 이 옵션은 Windows 바탕화면을  사용하려고 하거나 이를 필요로 하는 앱이 있을 때 유용합니다.
크기 : 14,379,288,723바이트

인덱스 : 3
이름 : Windows Server 2019 Datacenter
설명 : (권장) 이 옵션은 대부분의 Windows 그래픽 환경을 생략합니다. 명령 프롬프트와 PowerShell을 사용하거나 Windows 관리 센터 또는 기타 도구를 사용하여 원격으로 관리합니다.
크기 : 8,170,791,267바이트

인덱스 : 4
이름 : Windows Server 2019 Datacenter (데스크톱 경험)
설명 : 이 옵션은 별도의 드라이브 공간을 사용하는 완전한 Windows 그래픽 환경을 설치합니다. 이 옵션은 Windows 바탕화면을  사용하려고 하거나 이를 필요로 하는 앱이 있을 때 유용합니다.
크기 : 14,362,818,387바이트

작업을 완료했습니다.

D:\vhd>dism /apply-image /imagefile:g:\sources\install.wim /index:4 /applydir:f:\

배포 이미지 서비스 및 관리 도구
버전: 10.0.19041.746

이미지 적용 중
[==========================100.0%==========================]
작업을 완료했습니다.

D:\vhd>bcdboot f:\Windows
부팅 파일을 만들었습니다.

D:\vhd>bcdedit

Windows 부팅 관리자
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-us
inherit                 {globalsettings}
bootshutdowndisabled    Yes
default                 {default}
resumeobject            {########-####-####-####-############}
displayorder            {default}
                        {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows 부팅 로더
-------------------
identifier              {default}
device                  partition=F:
path                    \Windows\system32\winload.efi
description             Windows Server
locale                  en-us
inherit                 {bootloadersettings}
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=F:
systemroot              \Windows
resumeobject            {########-####-####-####-############}
nx                      OptOut

Windows 부팅 로더
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  ko-KR
inherit                 {bootloadersettings}
recoverysequence        {########-####-####-####-############}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {########-####-####-####-############}
nx                      OptIn
bootmenupolicy          Standard
hypervisorlaunchtype    Auto

D:\vhd>

1. First time boot and automatic initial configuration.
SATA Floppy Image is required if RAID is configured.

2. Install Graphic Driver.
AMD Radeon™ Software Adrenalin 2020 Edition fails to be installed on Windows Server.
In INF file, you can find “NTamd64.10.0.1…14310” which means OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION(0x0000001).
Whereas, wProductType of Windows Server is VER_NT_SERVER(0x00000003), and thus, INF should be patched before installation to work properly.
In addition, by adding ;(semi-colon) in front of HKR,,CoInstallers32,%REG_MULTI_SZ%, Open CL would also work fine.
Or use PowerShell script for automation of above steps.

3. Install AMD GPIO Driver.
AMD GPIO Driver can be installed manually by updating Unknown Device (Microsoft ACPI Complaint System).

Driver files can be obtained from Asrock support page. (AMD all in 1 with VGA driver)

4. Enable Audio Services.
Enable service, Windows Audio and Windows Audio Endpoint Builder

5. Enable Wireless Features (optional).
5-A. Add features, Wireless LAN Service

5-B. And then, reboot once

5-C. Enable service, WLAN Autoconfig

5-D. Install Intel® Wireless Bluetooth® for Windows® 10 Driver

5-E. Resolve unknown device driver manually
https://www.intel.com/content/www/us/en/support/articles/000056758/intel-nuc.html

Hotspot on startup, armbian

Issue:
Use armbian-config to create a hotspot. The hotspot is well created, however, doesn’t start on next reboot. Have to go back to armbian-config and manage hotspot to start it again.

Solution:

/lib/systemd/systemd-sysv-install enable hostapd

Access Registry with PowerShell

Working with Registry is very similar to working with files and folders with PowerShell.
Set-Location cmdlet can set the current working location to registry.

PS C:\Windows\system32> Set-Location Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PS Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER>

The registry provider’s full name is Microsoft.PowerShell.Core\Registry, but this can be shortened to just Registry.

PS C:\Windows\system32> Set-Location Registry::HKEY_CURRENT_USER
PS Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER>

In addation, PowerShell has two pre-defined registry ‘drives’:
HKLM for HKEY_LOCAL_MACHINE
HKCU for HKEY_CURRENT_USER

PS C:\Windows\system32> Set-Location HKCU:
PS HKCU:\>

However, other registry roots are not defined.

PS HKLM:\> Set-Location HKCR:
Set-Location : 드라이브를 찾을 수 없습니다. 이름이 'HKCR'인 드라이브가 없습니다.
위치 줄:1 문자:1
+ Set-Location HKCR:
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (HKCR:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS HKLM:\>

You can define other roots by yourself with New-PSDrive cmdlet.

PS HKLM:\> New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Name      Used (GB)      Free (GB)    Provider    Root    CurrentLocation
----      ---------      ---------    --------    ----    ---------------
HKCR                                            Registry  HKEY_CLASSES_ROOT

PS HKLM:\> Set-Location HKCR:
PS HKCR:\>

Modify File Time Stamps using PowerShell

Usages:
(Get-Item [filename]).CreationTime = [date/time]
(Get-Item [filename]).LastAccessTime = [date/time]
(Get-Item [filename]).LastWriteTime = [date/time]

PS C:\> (Get-Item .\test.txt).LastAccessTime = Get-Date
→ This command converts 'last access time' of 'test.txt' to current date and time

PS C:\> (Get-Item .\christmas.tree).LastWriteTime = '2016-12-25 AM0:00'
→ This command converts 'last write time' of 'christmas.tree' to specific date and time
Batch Processing with ForEach:
Get-ChildItem | ForEach-Object { $_.LastWriteTime = Get-Date }

PS C:\> Get-ChildItem | ForEach-Object { $_.LastWriteTime = Get-Date }
→ This command converts 'last write time' to current date and time of all files in working directory

PS C:\> $i = 0; Get-ChildItem | ForEach-Object { $_.LastWriteTime = (Get-Date).AddDays(-1).AddMinutes($i++) }
→ This command converts 'last write time' to yesterday with increasing minutes

How to prevent resizing terminal when using screen

# Long time I had this in my private screenrc file. But many people
# seem to want it (jw):
# we do not want the width to change to 80 characters on startup:
# on suns, /etc/termcap has :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:
#termcap xterm ‘is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l’
#terminfo xterm ‘is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l’

in /etc/screenrc