Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Nginx installation
📖 Scenario: You are setting up a simple web server on a Linux machine using Nginx. This server will host a basic website to share information with your friends and family.
🎯 Goal: Learn how to install Nginx, start the service, and verify that it is running correctly.
📋 What You'll Learn
Install Nginx using the package manager
Start the Nginx service
Enable Nginx to start automatically on boot
Check the status of the Nginx service
💡 Why This Matters
🌍 Real World
Installing and managing Nginx is a common task for hosting websites and web applications on servers.
💼 Career
System administrators and DevOps engineers often install and configure Nginx to serve web content reliably.
Progress0 / 4 steps
1
Install Nginx
Run the command sudo apt update to update the package list, then run sudo apt install -y nginx to install Nginx.
Nginx
Hint
Use apt commands with sudo to install software on Ubuntu.
2
Start and enable Nginx service
Run the command sudo systemctl start nginx to start Nginx, then run sudo systemctl enable nginx to make it start automatically on boot.
Nginx
Hint
Use systemctl commands to manage services.
3
Check Nginx service status
Run the command sudo systemctl status nginx to check if Nginx is active and running.
Nginx
Hint
The status command shows if the service is running.
4
Verify Nginx is serving the default page
Run the command curl -I http://localhost to see the HTTP headers and confirm Nginx is serving the default web page.
Nginx
Hint
The curl -I command shows HTTP headers. Look for HTTP/1.1 200 OK to confirm success.
Practice
(1/5)
1. What is the primary purpose of installing Nginx on a server?
easy
A. To compile software code
B. To manage database connections
C. To serve web pages and handle web traffic
D. To monitor system hardware
Solution
Step 1: Understand Nginx's role
Nginx is a web server software used to serve web pages and manage web traffic.
Step 2: Compare options
The options for compiling software, managing database connections, and monitoring hardware are unrelated to Nginx's main function.
Final Answer:
To serve web pages and handle web traffic -> Option C
Quick Check:
Nginx = Web server [OK]
Hint: Nginx is a web server, not a database or compiler [OK]
Common Mistakes:
Confusing Nginx with database software
Thinking Nginx compiles code
Assuming Nginx monitors hardware
2. Which command correctly installs Nginx on a Debian-based system?
easy
A. sudo yum install nginx
B. sudo apt-get install nginx
C. sudo pacman -S nginx
D. sudo dnf install nginx
Solution
Step 1: Identify package manager for Debian
Debian-based systems use apt or apt-get for package management.
Step 2: Match command to Debian
Only 'sudo apt-get install nginx' uses the correct package manager for Debian.
Final Answer:
sudo apt-get install nginx -> Option B
Quick Check:
Debian uses apt-get [OK]
Hint: Use apt-get for Debian, yum/dnf for RedHat, pacman for Arch [OK]
Common Mistakes:
Using yum on Debian systems
Using pacman on non-Arch systems
Confusing dnf with apt-get
3. After installing Nginx, what is the output of sudo systemctl status nginx if Nginx is running correctly?
medium
A. Active: active (running)
B. nginx: command not found
C. Failed to start nginx.service: Unit not found.
D. Active: inactive (dead)
Solution
Step 1: Understand systemctl status output
The command shows service status; 'active (running)' means the service is running.
Step 2: Identify correct output for running service
Only Active: active (running) shows 'Active: active (running)', indicating Nginx is running properly.
Final Answer:
Active: active (running) -> Option A
Quick Check:
Running service = active (running) [OK]
Hint: Look for 'active (running)' in status output [OK]
Common Mistakes:
Confusing inactive with active
Thinking 'Unit not found' means running
Misreading command not found as service status
4. You ran sudo systemctl start nginx but Nginx did not start. Which command helps you find the error logs to debug?
medium
A. sudo nginx -v
B. sudo apt-get update
C. sudo systemctl enable nginx
D. sudo journalctl -u nginx
Solution
Step 1: Identify command for viewing service logs
To debug service start issues, check logs with 'journalctl -u nginx'.
Step 2: Eliminate unrelated commands
'sudo nginx -v' shows version, 'sudo systemctl enable nginx' enables service on boot, 'sudo apt-get update' updates packages; none show logs.
Final Answer:
sudo journalctl -u nginx -> Option D
Quick Check:
Logs for debugging = journalctl -u nginx [OK]
Hint: Use journalctl -u nginx to see service logs [OK]
Common Mistakes:
Using version check instead of logs
Enabling service instead of checking logs
Running package update unrelated to debugging
5. To ensure Nginx starts automatically after a server reboot, which command should you run?
hard
A. sudo systemctl enable nginx
B. sudo systemctl start nginx
C. sudo systemctl restart nginx
D. sudo systemctl stop nginx
Solution
Step 1: Understand systemctl enable
Enabling a service configures it to start automatically on boot.
Step 2: Differentiate start and enable
Start runs service now; enable sets auto-start on reboot. Restart and stop do not enable auto-start.
Final Answer:
sudo systemctl enable nginx -> Option A
Quick Check:
Auto-start service = systemctl enable [OK]
Hint: Enable service to auto-start on boot, start only runs now [OK]