← Back to all services
Web Servers

Apache2 HTTP Server Port & Configuration

apache2 systemctl: apache2

Most widely used web server. Process/thread-based, highly extensible with modules, .htaccess support.

🔌 Default Ports

80
tcp
HTTP
443
tcp
HTTPS

📦 Installation Command

apt install apache2 apache2-utils

⚙️ Configuration Files

  • /etc/apache2/apache2.conf
  • /etc/apache2/ports.conf
  • /etc/apache2/sites-available/000-default.conf
  • /etc/apache2/envvars

📂 Default Directories

  • config: /etc/apache2
  • data: /var/www/html
  • logs: /var/log/apache2
  • sites_available: /etc/apache2/sites-available
  • sites_enabled: /etc/apache2/sites-enabled
  • mods_available: /etc/apache2/mods-available
  • mods_enabled: /etc/apache2/mods-enabled

🔐 Default Credentials

Username:N/A
Password:N/A
💡 No authentication by default. Runs as www-data user.

📌 Dependencies

apache2-binapache2-datassl-cert

⚠️ Conflicts

nginx (port conflict if same ports) Port: nginxPort: lighttpdPort: caddyPort: any service on 80/443

✅ Works With

php-fpmmysqlmariadbcertbotmod_security

🛡️ Security Notes

Disable ServerSignature and ServerTokens, enable mod_security, disable directory listing (Options -Indexes), use mod_evasive for DDoS protection, restrict .htaccess override

❓ Frequently Asked Questions

What port does Apache use?
Apache uses port 80 for HTTP and port 443 for HTTPS by default.
Where is Apache config file?
Main config at /etc/apache2/apache2.conf. Sites in /etc/apache2/sites-available/.
Apache vs Nginx which is better?
Nginx excels at static content and reverse proxy. Apache is better for .htaccess and dynamic content.