Try   HackMD

Construct VM as XAMPP Server on NAS (QNAP)

tags: 主機維護

Chia-Hung Huang, 黃嘉宏
Sat, Apr 9, 2022 9:45 AM

Build a New VM

  1. Get the .iso file, and put it into Public/OS/.
  2. Go to Visualization Station 3 on NAS and create a new VM. Select the .iso file you just put into Public/OS/ and set the Storage to Public/VM/ . For other setting details, please refer to the settings of the other VMs already on NAS.

Network Settings on NAS

  1. Go to Network & Virtual Switch on NAS.
  2. Select an idle Physical Adapter (or create a new one).
  3. Add a virtual switch, choose Advanced Mode, and connect the physical adapter to the VM you just created. Please note that you should NEVER touch the System Default Gateway, or the whole NAS service may crush.
    • Select Stacic IP, Use the same settings as the selected adapter
    • Select IPv6 Auto-Configuration (Stateless)
    • For DNS Settings, manually assign Primary DNS server to 140.112.2.2 and Secondary DNS server to 140.112.4.254
  4. In the Overview tab, make sure there is a blue earth icon, which means "Internet connected", on the Physical Adapter and Vitrual Switch you just created. You can refer to the following image for example.
  5. In the ControlPanel of the NAS service, go to Network & File > Network Access > Service Binding, and enable Web server and SQL server of the newly-added physical adapter.

Network Settings on VM

  • 前往設定 > 網路和網際網路 > 乙太網路 > 內容 > IP 設定,手動指派 IP:
    • IPv4 位址:Physical Adapter 的 IP
    • 子網路首碼長度:24
    • 閘道:140.112.30.254
    • DNS 伺服器:140.112.2.2140.112.4.254
  • 確認 VM 可以連上網路

XAMPP Server

  1. Install XAMPP and install : https://www.apachefriends.org/de/download.html
  2. To avoid the UAC interference, please install XAMPP in a folder with the name xampp directly under C:/ (i.e. C:/xampp, NOT C:/program Files/xampp)
  3. Create a new web root directory C:/WebRoot
  4. Go to the XAMPP Control Panel. Click Config (as shown in the image) and modify the following files:
    • Apache(httpd.conf):
      ​​​​​​​​# Original
      ​​​​​​​​Listen 80
      
      ​​​​​​​​# Add IP port
      ​​​​​​​​Listen 80
      ​​​​​​​​
      ​​​​​​​​
      ​​​​​​​​# Original
      ​​​​​​​​DocumentRoot "C:/xampp/htdocs"
      ​​​​​​​​<Directory "C:/xampp/htdocs">
      ​​​​​​​​
      ​​​​​​​​# Change to
      ​​​​​​​​DocumentRoot "C:/WebRoot"
      ​​​​​​​​<Directory "C:/WebRoot">
      
    • Apache(httpd-ssl.conf)
      ​​​​​​​​# Original
      ​​​​​​​​DocumentRoot "C:/xampp/htdocs"
      ​​​​​​​​
      ​​​​​​​​# Change to
      ​​​​​​​​DocumentRoot "C:/WebRoot"
      
    • PHP(php.ini)
      ​​​​​​​​# Original
      ​​​​​​​​include_path=C:\xampp\php\PEAR
      ​​​​​​​​
      ​​​​​​​#Change to
      ​​​​​​​include_path=".;C:\xampp\php;C:\xampp\php\pear;C:\WebRoot;"
      
  5. Forbid apache server to show the directory indexes.
    • httpd.conf
      ​​​​​​​​# Original
      ​​​​​​​​Options Indexes FollowSymLinks Includes ExecCGI
      ​​​​​​​​
      ​​​​​​​​# Change to
      ​​​​​​​​Options FollowSymLinks Includes ExecCGI
      
  6. Restart the Apache server. The WebRoot directory is now accessible from outside network with its IP.
  7. Since the VM is built on the NAS, so it cannot be reached through NAS VPN.

Follow-up

For further works, please refer to DocuSky 架設程序 (移機)