|
| 1 | +--- |
| 2 | +title: NGINX Baseline Testing |
| 3 | +weight: 5 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +### Baseline testing with a static website on NGINX |
| 11 | +Perform baseline testing of NGINX on an **Ubuntu Pro 24.04 LTS** virtual machine by deploying a custom static HTML page. This verifies that NGINX is correctly serving content on the Arm64 platform. |
| 12 | + |
| 13 | +1. Create a Static Website Directory: |
| 14 | + |
| 15 | +Prepare a folder to host your HTML content. |
| 16 | +```console |
| 17 | +mkdir -p ~/my-static-site |
| 18 | +``` |
| 19 | +2. Create an HTML file and Web page: |
| 20 | + |
| 21 | +Create a HTML file `nano my-static-site/index.html` with the content below to design a visually appealing static landing page. |
| 22 | + |
| 23 | +```html |
| 24 | +<!DOCTYPE html> |
| 25 | +<html lang="en"> |
| 26 | +<head> |
| 27 | + <meta charset="UTF-8"> |
| 28 | + <title>Welcome to NGINX on Azure Ubuntu Pro</title> |
| 29 | + <style> |
| 30 | + body { |
| 31 | + background: linear-gradient(to right, #4facfe, #00f2fe); |
| 32 | + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; |
| 33 | + display: flex; |
| 34 | + justify-content: center; |
| 35 | + align-items: center; |
| 36 | + height: 100vh; |
| 37 | + margin: 0; |
| 38 | + color: white; |
| 39 | + text-align: center; |
| 40 | + } |
| 41 | + .box { |
| 42 | + background: rgba(0, 0, 0, 0.3); |
| 43 | + padding: 40px; |
| 44 | + border-radius: 12px; |
| 45 | + box-shadow: 0 0 15px rgba(0, 0, 0, 0.4); |
| 46 | + } |
| 47 | + h1 { |
| 48 | + margin-bottom: 10px; |
| 49 | + font-size: 2.5rem; |
| 50 | + } |
| 51 | + p { |
| 52 | + font-size: 1.2rem; |
| 53 | + } |
| 54 | + </style> |
| 55 | +</head> |
| 56 | +<body> |
| 57 | + <div class="box"> |
| 58 | + <h1> Welcome to NGINX on Azure Ubuntu Pro 24.04 LTS!</h1> |
| 59 | + <p>Your static site is running beautifully on ARM64 </p> |
| 60 | + </div> |
| 61 | +</body> |
| 62 | +</html> |
| 63 | +``` |
| 64 | +3. Move the Website to NGINX's Accessible Directory: |
| 65 | + |
| 66 | +Since NGINX runs under the `www-data` user and may not have access to files inside `/home/ubuntu`, move the site to a directory where NGINX has permissions by default: |
| 67 | + |
| 68 | +```console |
| 69 | +sudo mkdir -p /var/www/my-static-site |
| 70 | +sudo cp -r ~/my-static-site/* /var/www/my-static-site/ |
| 71 | +sudo chown -R www-data:www-data /var/www/my-static-site |
| 72 | +``` |
| 73 | + |
| 74 | +4. Create NGINX Config File to Serve Static Website: |
| 75 | + |
| 76 | +Point NGINX to serve your static HTML content. |
| 77 | +```console |
| 78 | +sudo nano /etc/nginx/conf.d/static-site.conf |
| 79 | +``` |
| 80 | +Now, add the following configuration: |
| 81 | + |
| 82 | +```NGINX |
| 83 | +server { |
| 84 | + listen 80; |
| 85 | + server_name localhost; |
| 86 | +
|
| 87 | + location / { |
| 88 | + root /var/www/my-static-site; |
| 89 | + index index.html; |
| 90 | + } |
| 91 | +
|
| 92 | + access_log /var/log/nginx/static-access.log; |
| 93 | + error_log /var/log/nginx/static-error.log; |
| 94 | +} |
| 95 | +``` |
| 96 | +Make sure `/home/ubuntu/my-static-site` is the correct path to your **index.html**. |
| 97 | + |
| 98 | +5. Test the NGINX Configuration: |
| 99 | + |
| 100 | +```console |
| 101 | +sudo nginx -t |
| 102 | +``` |
| 103 | +You should see an output similar to: |
| 104 | +```output |
| 105 | +nginx: the configuration file /etc/nginx/nginx.conf syntax is ok |
| 106 | +nginx: configuration file /etc/nginx/nginx.conf test is successful |
| 107 | +``` |
| 108 | + |
| 109 | +6. Reload or Restart NGINX: |
| 110 | + |
| 111 | +Apply configuration changes and restart the web server. |
| 112 | +```console |
| 113 | +sudo nginx -s reload |
| 114 | +sudo systemctl restart nginx |
| 115 | +``` |
| 116 | + |
| 117 | +7. Test the Static Website on browser: |
| 118 | + |
| 119 | +Access your website at your public IP on port 80. |
| 120 | +```console |
| 121 | +http://<your-vm-public-ip>/ |
| 122 | +``` |
| 123 | +Make sure port 80 is open in your Azure Network Security Group (NSG). |
| 124 | + |
| 125 | +8. You should see the NGINX welcome page confirming a successful deployment: |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +This verifies the basic functionality of NGINX installation before proceeding to the benchmarking. |
0 commit comments