Linux Web Servers - ryzendew/Linux-Tips-and-Tricks GitHub Wiki

Linux Web Servers Guide

Complete beginner-friendly guide to web servers on Linux, covering Arch Linux, CachyOS, and other distributions including Apache, Nginx, and web server configuration.


Table of Contents

  1. Apache
  2. Nginx
  3. Web Server Configuration
  4. Troubleshooting

Apache

Install Apache

Install Apache:

# Arch/CachyOS
sudo pacman -S apache

# Enable service
sudo systemctl enable --now httpd.service

# Check status
systemctl status httpd

Debian/Ubuntu:

sudo apt install apache2

Fedora:

sudo dnf install httpd

Apache Configuration

Configure Apache:

# Edit config
sudo vim /etc/httpd/conf/httpd.conf

# Edit virtual hosts
sudo vim /etc/httpd/conf/extra/httpd-vhosts.conf

Test Apache

Test server:

# Check if running
curl http://localhost

# Or open browser
# http://localhost

Nginx

Install Nginx

Install Nginx:

# Arch/CachyOS
sudo pacman -S nginx

# Enable service
sudo systemctl enable --now nginx.service

# Check status
systemctl status nginx

Debian/Ubuntu:

sudo apt install nginx

Fedora:

sudo dnf install nginx

Nginx Configuration

Configure Nginx:

# Edit config
sudo vim /etc/nginx/nginx.conf

# Edit sites
sudo vim /etc/nginx/sites-available/default

Web Server Configuration

Virtual Hosts

Apache:

# Create virtual host
sudo vim /etc/httpd/conf/extra/httpd-vhosts.conf

Nginx:

# Create server block
sudo vim /etc/nginx/sites-available/example.com

Troubleshooting

Server Not Starting

Check logs:

# Apache logs
journalctl -u httpd

# Nginx logs
journalctl -u nginx

Summary

This guide covered web servers for Arch Linux, CachyOS, and other distributions, including Apache and Nginx.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.