Installing Nginx/Apache
Install and perform initial configuration of both Nginx and Apache web servers on a fresh Linux server instance.
Installing Nginx/Apache is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What is a Web Server?
A web server is software that stores website files (like HTML, CSS, images) and delivers them to users' web browsers. When you type a website address, a web server processes your request and sends back the content.
In this lesson, we'll focus on two popular web servers: Nginx and Apache.
Nginx or Apache? A Quick Look
Both Nginx and Apache are excellent choices for serving web content, but they have different strengths:
- Nginx: Known for high performance, efficiency, and scalability. It's often used as a reverse proxy, load balancer, and for serving static content.
- Apache: Highly flexible and feature-rich with a vast module ecosystem. It's very popular for dynamic web applications.
You'll often find them used together!
Prepare Your Server for Installation
Before installing any new software, it's a good practice to update your server's package lists. This ensures you get the latest versions and security patches.
We use sudo to run commands with administrative privileges.
sudo apt updateInstall Nginx Web Server
Now, let's install Nginx. On Debian/Ubuntu-based systems, you can use the apt package manager.
The -y flag automatically confirms any prompts during installation.
sudo apt install nginx -yControl Nginx Service
After installation, Nginx usually starts automatically. You can manage its service using systemctl. Here are some common commands:
- Start:
sudo systemctl start nginx - Enable:
sudo systemctl enable nginx(starts on boot) - Status:
sudo systemctl status nginx
Use stop or restart similarly.
sudo systemctl status nginxTest Nginx: First Web Page!
To verify Nginx is working, open your web browser and navigate to your server's IP address (e.g., http://YOUR_SERVER_IP). You should see the default Nginx welcome page.
If you have a firewall (like UFW), you might need to allow HTTP traffic:
sudo ufw allow 'Nginx HTTP'Install Apache Web Server
Next, let's install Apache. The process is very similar to Nginx on Debian/Ubuntu systems, using the same apt package manager.
sudo apt install apache2 -yControl Apache Service
Just like Nginx, Apache's service can be managed with systemctl. It typically starts automatically after installation.
- Start:
sudo systemctl start apache2 - Enable:
sudo systemctl enable apache2 - Status:
sudo systemctl status apache2
Use stop or restart as needed.
sudo systemctl status apache2Test Apache: Default Page
To confirm Apache is running, visit your server's IP address in your web browser. You should see the default Apache Ubuntu Welcome Page.
If you enabled UFW, you might need to allow Apache traffic:
sudo ufw allow 'Apache'Where's the Web Content?
Both Nginx and Apache have default directories where they expect to find your website files:
- Nginx: Typically
/var/www/html - Apache: Also commonly
/var/www/html
The main configuration files are usually found in /etc/nginx/nginx.conf and /etc/apache2/apache2.conf respectively. We'll dive into configuring these files in later lessons!
Quick Check
You've successfully installed Nginx and Apache. Now, let's test your knowledge of service management.
Recap & Next Steps
Great job! You've successfully installed and performed initial checks for both Nginx and Apache web servers on your Linux instance.
- You learned how to use
aptfor installation. - You used
systemctlto manage web server services. - You verified installations by accessing default web pages.
Next, we'll learn how to configure these servers to host your own static websites!
Frequently asked questions
Is the “Installing Nginx/Apache” lesson free?
Yes — the full text of “Installing Nginx/Apache” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.
What will I learn in “Installing Nginx/Apache”?
Install and perform initial configuration of both Nginx and Apache web servers on a fresh Linux server instance. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Linux Server Deployment & SSH Mastery?
No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Installing Nginx/Apache” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?
Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Installing Nginx/Apache
- Hosting Static Websites
- Basic Virtual Host Configuration
- Enabling HTTPS with Let's Encrypt