월. 8월 4th, 2025

Introduction
Apache (officially called Apache HTTP Server) is the world’s most popular open-source web server software. Whether you’re hosting a personal blog, a business website, or a web application, Apache provides a reliable foundation. In this guide, I’ll walk you through installing Apache on major Linux distributions with clear explanations.


✅ Prerequisites

  1. A Linux system (Ubuntu/Debian or RHEL/CentOS/Fedora)
  2. Terminal access with sudo privileges
  3. Internet connection

🛠️ Installation Steps

For Debian/Ubuntu Systems

# Update package lists  
sudo apt update  

# Install Apache  
sudo apt install apache2 -y  

# Verify installation  
sudo systemctl status apache2  

For RHEL/CentOS/Fedora Systems

# Update packages  
sudo dnf update -y  

# Install Apache  
sudo dnf install httpd -y  

# Start Apache and enable auto-launch on boot  
sudo systemctl start httpd  
sudo systemctl enable httpd  

# Check status  
sudo systemctl status httpd  

🔧 Basic Configuration

  1. Firewall Setup
    Allow HTTP/HTTPS traffic:

    sudo ufw allow 80/tcp     # HTTP  
    sudo ufw allow 443/tcp    # HTTPS  

    For RHEL/CentOS: Use firewall-cmd --permanent --add-service={http,https}

  2. Test Apache
    Open your browser and visit:

    http://your-server-ip  

    You’ll see Apache’s default welcome page.

  3. Key Directories

    • Ubuntu/Debian:
      • Config files: /etc/apache2/
      • Website root: /var/www/html/
    • RHEL/CentOS:
      • Config files: /etc/httpd/
      • Website root: /var/www/html/

⚙️ Create a Test Web Page

  1. Navigate to the web root:
    cd /var/www/html/  
  2. Create a test file:
    sudo nano index.html  
  3. Add basic HTML:

Apache Works! 🚀

4. Save the file and refresh your browser.  

---

### 🔄 Managing Apache Service  
- **Start/Stop/Restart**:  
  ```bash  
  sudo systemctl start apache2    # Ubuntu/Debian  
  sudo systemctl restart httpd    # RHEL/CentOS  
  • Enable Auto-Start:
    sudo systemctl enable apache2  
  • Check Errors:
    sudo journalctl -u apache2 -f   # Real-time logs  

⚠️ Troubleshooting Tips

  • Port 80 in use? Run: sudo netstat -tulpn | grep :80
  • Permission issues? Ensure ownership:
    sudo chown -R www-data:www-data /var/www/html/  # Ubuntu  
    sudo chown -R apache:apache /var/www/html/       # CentOS  
  • Test config syntax: sudo apachectl configtest

📌 What’s Next?

  1. Secure with SSL: Use Let’s Encrypt (certbot) for free HTTPS.
  2. Host Multiple Sites: Set up virtual hosts.
  3. Optimize Performance: Adjust KeepAlive, MaxClients, and caching.

Apache is your gateway to web hosting on Linux. Experiment, break things, and learn! Got questions? Drop them in the comments below. 💬

> Pro Tip: Bookmark Apache’s official docs: https://httpd.apache.org/docs/

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다