Installing and migrating XUNO on premise

This article talks about the basic installation and migration process of XUNO on a Windows 2016 server located in a school environment. Each installation and migration will be different but should follow these basic installation steps.

In this article

XUNO server minimum requirements
The new XUNO server must meet the minimum requirements found here. Installation of XUNO on a server that does not meet these requirements will result in problems installing and maintaining the XUNO installation.

XUNO DNS host record
Before the XUNO website will be accessible, the school technician will need to create a DNS record which resolves the host header 'xuno' to the server on which XUNO is to be installed. This should be done after the migration has been completed, and the old server has been shut down.    
To check if the DNS record has been created correctly, run the following command in command prompt:

nslookup xuno

Up-to-date
To ensure the migration will run smoothly and all the required packages install correctly, please make sure your server is running with the latest Windows Updates.    

Installing IIS

The following steps will guide you through installing and configuring IIS on the XUNO server.

  1. On the XUNO server, open the Server Manager console
  2. Navigate to Add roles and features
  3. Click Next on the Before You Begin page
  4. Leave Role-based or feature-based installation selected as the installation type and click Next
  5. Click Next to leave the current server as the destination server
  6. Find and check Web Server (IIS) from the list of available server roles
  7. Click on Role Services 
  8. Find and check CGI from the list of Role Services, under Application Development
  9. Click Next then Install to finalize the installation
  10.  Tick to restart the server if necessary

Installing XUNO on the new Server

The following steps will guide you through installing the XUNO website files. 

  1. Download the XUNO installation file onto the XUNO server. (Click the button above, and you will receive the download link as a reply email).
  2. Run the installation file on the XUNO server and follow the prompts

    Destination Location
    Do not install XUNO in the default installation located in C:\Inetpub\wwwroot\xuno. Instead, install the XUNO installation folder in a new folder called 'Websites' located in the root path of a local server drive. e.g. C:\Websites\XUNO

  3. Once the website files are installed, navigate to the 'XUNO' folder in Windows Explorer
  4. Create the folders: docs, tmp, photos, reports (if they do not already exist)
  5. Right click on the docs folder and select Properties
  6. Click on the Security tab
  7. Click on the Edit button
  8. Click on the Add button
  9. Under the 'Enter the object names to select' text box, type IUSR and click 'Check Names'
  10. Click on the Advanced button
  11. Click on the Locations button and select the local XUNO server
  12. Click on the Find Now button
  13. In the search results, find and select the IIS_IUSRS group
  14. Click the OK button to return to the 'Select Users or Groups' window
  15. Click the OK button to return to the 'Permissions for <folder>' window
  16. Make sure that IUSR and IIS_IUSRS have modify access set.
  17. Click the OK button to return to the '<folder> Properties' window
  18. Click the OK button to confirm the permission changes and close the '<folder> Properties' window
  19. Repeat steps 6 to 18 for the following folders: includes\customimages, tmp, uploads, photos, reports and C:\Windows\Temp
  20. Right click on the secure folder and select Properties
  21. Click on the Security tab
  22. Click on the Advanced button
  23. Check the checkbox which reads Replace all child object permission entries with...
  24. Remove the IUSR and IIS_IUSRS rows (if they exist)
  25. Save your changes

Configuring the XUNO website in IIS

The following steps will guide you through creating the XUNO website in IIS.

  1. Open the Internet Information Services Manager (in the Windows Administrative Tools folder via the Start Menu)
  2. In the left panel of the IIS Manager, open Sites and delete the default website as it is not being used
  3. Right-click Sites and select Add Website...
  4. Name the website 'XUNO'
  5. Set the physical path of the website to the XUNO installation directory e.g. C:\Websites\XUNO
  6. Set the host name of the website to 'xuno'
  7. Click the OK button to create the website

Important! Do not add an empty binding to the XUNO website. The only bindings added should be specific to XUNO.

Installing PHP and SQL Server Drivers for IIS

The following steps will guide you through installing and configuring PHP and SQL Server Drivers on the XUNO server.

  1. Open the Internet Information Services Manager which can be found under Administrative Tools
  2. Select the IIS server from the navigation panel on the left.
  3. From the actions panel located on the right, select Get New Web Platform Components which will launch the Web Platform Installer
  4. Select the Products tab
  5. Search for 'SQL server 5.3 PHP x64' in the search bar and hit Enter (we are looking for the latest PHP version & SQL server drivers that are supported in IIS)
  6. Find the latest version (At the time of writing it is 'Microsoft Drivers 5.3 (x64) for PHP v7.2 for SQL Server in IIS') do not choose x86 or IISExpress versions.
  7. Click Add and then click Install below
  8. Follow the prompts to install
  9. Follow the steps found in part 3 from step 7 onwards, of the article How to update PHP to configure the php.ini file for the XUNO installation

You should now be able to test the installation of XUNO by selecting the XUNO website from the IIS navigation panel and then clicking the Browse xuno on *:80 (http) button from the actions panel on the left hand side of the console.

Installing MySQL

The following steps will guide you through installing and configuring MySQL on the XUNO server.

You will need to install Visual C++ Redistributable for Visual Studio 2015 (both x86 and x64) before installing MySQL. You can download that here

  1. Download and run the MySQL installer on the XUNO server
  2. Open the installer
  3. Click to accept the license terms
  4. Choose Custom setup type
  5. Click on Edit
  6. Change Age to Other Releases and Architecture to 64-bit
  7. Click Filter to show options
  8. Expand MySQL Server/s
  9. At the moment XUNO supports the latest build of MySQL Server 5.7 so expand that and select the latest build (At the time of writing it is MySQL Server 5.7.24 - X64)
  10. Now expand Applications and select the latest version of MySQL Workbench (At the time of writing it is MySQL Workbench 8.0.1.2 - x64)
  11. Click Next 
  12. Click Execute to Install the requirements if any
  13. Click Execute to Install
  14. Click Next to continue
  15. Click Next to continue
  16. Choose Standalone MySQL Server / Classic MySQL Replication
  17. Choose Config Type: Server Computer
  18. Click Next to continue
  19. Choose a complicated MySQL Root password
  20. Click Next to continue
  21. Click Next to continue
  22. Click Next to continue without enabling X Protocol
  23. Click Execute to Apply Configuration
  24. Click Next to continue
  25. Click Finish  complete installation
  26. Press Windows Key + Pause
  27. On the left pane, click Advanced system settings
  28. Click Environment Variables
  29. Down the bottom in System variables, choose to edit Path
  30. Click New, and then Browse
  31. Navigate to the MySQL bin folder (Normally found at C:\Program Files\MySQL\MySQL Server 5.7\bin)
  32. Click Ok to add the folder to Path
  33. Open up a new command prompt and type 'mysql'
  34. If you get the message:
    ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
    	

    Then Success! Otherwise try restarting the server

Optimising the MySQL Database

Using Windows as a database server means that we will need to optimise the database before we attempt to import any data.
The easiest way to do this is to run a short script in Powershell that will optimize the database based on the server hardware.

  1. You will need to open Powershell ISE as an admin, do this by pressing the Windows Key and then type ise
  2. Once Powershell ISE shows up, press CTRL + SHIFT + ENTER to open it as an administrator 
  3. On the top right of ISE click the down arrow next to the word Script
  4. Paste the following into ISE (next to the number 1):
  5.     #Optimise Mysql Database
        Stop-Service -Name 'MySQL57' -Force;
        $megabytes = "M";
        $ram = [math]::Round((((Get-CimInstance -Class "cim_physicalmemory" | Measure-Object -Property Capacity -Sum).Sum) / 1MB));
        $innodbbufferpool = [math]::Round(($ram * .7));
        $innodblogfile = [math]::Round(($innodbbufferpool * .6));
        $newinnodbbufferpool = "$innodbbufferpool" + $megabytes;
        $newinnodblogfile = "$innodblogfile" + $megabytes;
    
        $corecount = ((Get-CimInstance -ClassName 'Win32_Processor' | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum);
    
        $myinifile = (Get-Content -Path "$using:dbdirectory\my.ini")
        $myinivalues = @{ "max_connections=151" = "max_connections=300";
          "thread_cache_size=10" = "thread_cache_size=30";
          "innodb_flush_log_at_trx_commit=1" = "innodb_flush_log_at_trx_commit=0";
          "innodb_buffer_pool_size=8M" = "innodb_buffer_pool_size=$newinnodbbufferpool";
          "innodb_log_file_size=48M" = "innodb_log_file_size = $newinnodblogfile";
          "sort_buffer_size=256K" = "sort_buffer_size=1M";
          "innodb_thread_concurrency=25" = "innodb_thread_concurrency=$corecount";
          "innodb_buffer_pool_instances=8" = "innodb_buffer_pool_instances=$corecount";
          "join_buffer_size=256K" = "join_buffer_size=256M";
    
        }
    
        foreach ($Entry in $myinivalues.Keys) {
          $myinifile = $myinifile -replace $Entry,$myinivalues[$Entry]
        }
    
        Set-Content -Path "$using:dbdirectory\my.ini" -Value $myinifile;
        Remove-Item -Path "$using:dbdirectory\Data\ib_logfile0";
        Remove-Item -Path "$using:dbdirectory\Data\ib_logfile1";
        Start-Service -Name 'MySQL57';
    	
  6. Press F5 to run the script

Archiving and backing up XUNO data

Important! Before we go further, you will need to make sure IIS is stopped on the old server. You can do this by opening IIS, clicking on the server and clicking Stop on the right actions panel

The following steps are going to help migrate your data to the new server, ensuring no data loss

  1. Create a new folder on the Desktop of your old server
  2. Open the new folder and in the address bar up the top get rid of the current text, and type in powershell
  3. once Powershell opens up, type in ise and press Enter
  4. In the ISE editor, paste the following and press enter:
  5.  
    function Get-Backup {
        param(
            [Parameter(mandatory = $true,
                ValueFromPipeline = $false)]
            [string]$schoolname,
            [Parameter(mandatory = $true,
                ValueFromPipeline = $false)]
            [string]$databasename,
            [Parameter(mandatory = $true,
                ValueFromPipeline = $false)]
            [string]$dbpassword,
            [Parameter(mandatory = $false,
                ValueFromPipeline = $false)]
            [string]$xunofolder,
            [Parameter(mandatory = $false,
                ValueFromPipeline = $false)]
            [string]$dbserver = 'localhost'
        )
        $year = (Get-Date -UFormat "%Y")
        $month = (Get-Date).Month
        $day = (Get-Date).Day
        $backupname = "$($schoolname)_$($year)_$($month)_$($day).sql";
        $backupfolder = $backupname.Replace(".sql", "");
        $foldertozip = New-Item -Name "$($backupfolder)" -ItemType Directory -Force;
        cmd.exe /c "mysqldump -uroot --password=`"$($dbpassword)`" -h `"$($dbserver)`" --extended-insert --routines  $($databasename) > $($backupname)";
        Copy-Item -Path $backupname -Destination "$($backupfolder)\$($backupname)"
        $source = $foldertozip;
        $destination = "$($foldertozip).zip"
        $xunofolderzip = "xunofolder.zip"
        Add-Type -Assembly "system.io.compression.filesystem";
        [io.compression.zipfile]::CreateFromDirectory($source, $destination);
        if (!([string]::IsNullOrEmpty($xunofolder))) {
            [io.compression.zipfile]::CreateFromDirectory($xunofolder, $xunofolderzip);
        }
        Remove-Item $backupfolder -Recurse -Force;
        Write-Host -Object "done"
    }
    
    
    

    The above script will backup, copy and archive both your database and your XUNO folder

    If you get an error running the above script, you will need to download and install the latest version of the .NET Framework found here and the latest version of the Windows Management Framework found here.

  6. Once you have loaded the above function into memory by pressing enter, you will need to type the following into ISE:
  7. Get-Backup -schoolname <NAME OF DATABASE ZIP FILE> -databasename <NAME OF THE XUNO DATABASE> -dbpassword <DATABASE PASSWORD> -xunofolder <LOCATION OF XUNO DIRECTORY>
    	
  8. The above command needs the following information for it's parameters (do not include the <> symbols):
    1. -schoolname This is the name that you would like that database zip file to have, it can be any name but should not include spaces or special characters
    2. -databasename This is the name of the XUNO database on this server
    3. -dbpassword This is the password for the XUNO database on this server
    4. -xunofolder This is the full path to your XUNO installation e.g if your installation is in the Websites folder it will look like "C:\Websites\Xuno" (include the quotes)

Copy Data Across

Now that we have both the XUNO Database and the XUNO folder in a ZIP file, we can copy them across to the new server. 

  1.  From the old XUNO server, copy the ZIP files to the Desktop of the new server.
  2. The transferring of this ZIP file from the old server to your new server, can take a long time depending on the size of the folders and your network speed.
    It has taken over 24 hours in the past so grab a coffee!

  3. Once copied, on the new server extract the xunofolder.zip to the path of the XUNO installation. Be sure to click Yes to overwrite any existing files
  4. Go to the includes > custom folder in the XUNO directory, and open customconfig.inc.php
  5. Change the old 'password' to the new XUNO Database password
  6. Change the 'server' value to the address of the new XUNO server, if the old one is listed 

Import Database

It's time to import the database so we can start using XUNO

  1. Open File Explorer, and navigate to the Desktop (don't worry there is a reason for it!)
  2. Extract the xunofolder.zip file
  3. In the address bar up the top get rid of the existing text, type in cmd and press Enter
  4. In the command prompt window that has just opened, type the following and press Enter:
  5. mysql -uroot -p -e "CREATE SCHEMA <OLD DATABASE NAME>;"
    	
    And then:
    mysql -uroot -p "OLD DATABASE NAME" < "FILE.SQL"
    	

    The first command will create the database for us. Change OLD DATABASE NAME to the name of the database on the old server (do not include the <>)

    The second command will import the data into the newly created database. 

    Change  OLD DATABASE NAME to the name of the database on the old server (do not include the quotes).

    Change the name of the SQL file to the name of the SQL file that has been extracted (do not include the quotes).

  6. Run the XUNO setup again on the new server. You can download it from here
  7. Celebrate! You have completed the migration.

You will now need to make sure all DNS records are pointing to the new server

You will also need to ensure the eduHub sync is pointing to the new XUNO server. Have a look at the instructions here to setup eduHub for the new server

If necessary, don't forget to set scheduled backups of your XUNO database. Have a look at our article here that talks about setting a scheduled task using our backup template. 

Still need help? Contact Us Contact Us