Host WebApp of G Web Development Software in Ubuntu 22.04 Using Nginx

Updated May 6, 2023

Environment

Software

  • G Web Development Software

Operating System

  • Linux

Although NI Web Server is not provided by NI in Linux OS, it is still possible to host web applications generated by G Web Development Software in a Linux environment. In this article, we will be showing you how to accomplish this on Ubuntu 22.04 using Nginx.

Prepare a Web Application Using G Web Development Software

  1. Launch G Web Development Software.
  2. Go to Learning>>Examples>>Programming WebVIs
    2023-05-06_11h12_29.png
  3. Select Call 3rd Party Web Service
    2023-05-06_11h15_00.png
  4. Select Create on the pop-up windows. 
    2023-05-06_11h16_55.png
  5. Save the project.
  6. On the left navigation menu, double-click WebApp.lvdist
    2023-05-06_11h22_59.png
  7. On the right navigation menu, click Build
    2023-05-06_11h26_46.png
  8. Once the project is built, click Locate directory in File Explorer which can be found nearby the Build button mentioned in Step 7.
  9. File Explorer will be launched with the built package displayed. Click Builds to go to the directory one level up from the current directory. 
    2023-05-06_11h34_34.png
  10. Rename the WebApp_Default Web Server folder to Earthquakes folder. Save this folder at a desired location as it will be used by the Ubuntu 22.04 computer later.

Deploy to Nginx on Ubuntu 22.04

  1. Install Nginx by using the following command if it is not yet been installed. 
    sudo apt update
    sudo apt install nginx
    
  2. Check the Nginx is active and running using the following command. 
    systemctl status nginx
  3. Copy the Earthquakes folder mentioned in Step 10 of the previous section and paste it into /var/www/html/ of the Ubuntu 22.04 computer.
  4. Change the ownership of the directory to www-data by using the following command: 
    sudo chown -R www-data:www-data /var/www/html/Earthquakes
  5. To ensure that your permissions are correct and allow the owner to read, write, and execute the files while granting only read and execute permissions to groups and others, execute the following command as well: 
    sudo chmod -R 755 /var/www/html/Earthquakes
  6. Created Earthquakes.conf in /etc/nginx/sites-available of the Ubuntu 22.04 computer with the following contents: 
    server {
            listen 80 default_server;
            listen [::]:80 default_server;
            root /var/www/html/Earthquakes;
            index index.html index.htm;
            server_name Earthquakes;
       location / {
           try_files $uri $uri/ =404;
       }
    }
  7. Enable the file by creating a link from it to the sites-enabled directory, which Nginx reads from during startup by using the following command: 
    sudo ln -s /etc/nginx/sites-available/Earthquakes /etc/nginx/sites-enabled/
  8. Ensure there are no syntax errors in any of your Nginx files by using the following command: 
    sudo nginx -t
  9. Restart Nginx to apply the changes: 
    sudo systemctl restart nginx
  10. Using an internet browser on Ubuntu 22.04 computer, browse Localhost and you will be able to see the web application is running fine. 
    2023-05-06_13h44_11.png