LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

apache2

Apache HTTP Server daemon

TLDR

Start Apache server
$ sudo apache2
copy
Start in foreground for debugging
$ sudo apache2 -X
copy
Test configuration syntax
$ apache2 -t
copy
Show loaded modules
$ apache2 -M
copy
Show version and build options
$ apache2 -V
copy
Show parsed virtual host settings
$ apache2 -S
copy
Start with specific config
$ sudo apache2 -f [/path/to/httpd.conf]
copy

SYNOPSIS

apache2 [-d serverroot] [-f config] [-D parameter] [options]

DESCRIPTION

apache2 is the Apache HTTP Server daemon, one of the most widely used web servers. It handles HTTP requests, serves static content, runs CGI scripts, and integrates with application servers through various modules.On Debian/Ubuntu systems, apache2 is typically managed through systemctl or apache2ctl rather than direct invocation.

PARAMETERS

-t

Test configuration file syntax
-X
Run in single-process debugging mode
-M
List loaded modules (compiled-in and shared)
-V
Show version and compile settings
-f file
Specify configuration file
-d directory
Server root directory
-D name
Define parameter for <IfDefine>
-e level
Startup error log level.
-k command
Signal command: start, stop, restart, graceful, graceful-stop.
-S
Show parsed virtual host settings.
-l
List compiled-in modules.
-L
List available configuration directives.
-C directive
Process directive before reading config files.
-c directive
Process directive after reading config files.
-h
Display short summary of command-line options.

CONFIGURATION

/etc/apache2/apache2.conf

Main configuration file on Debian/Ubuntu systems.
/etc/apache2/sites-available/
Virtual host configuration files, enabled via a2ensite.
/etc/apache2/mods-available/
Module configuration files, enabled via a2enmod.
/etc/apache2/envvars
Environment variables for the Apache process (user, group, pid file).
/etc/apache2/ports.conf
Listen directives specifying which ports Apache binds to.

CAVEATS

Direct invocation is rarely needed; use apache2ctl or systemctl. Configuration testing (-t) should be run before restarts. Running as root is required for ports below 1024.

HISTORY

Apache HTTP Server originated from NCSA HTTPd patches in 1995, with "Apache" reportedly meaning "A Patchy Server." It has dominated the web server market for decades.

SEE ALSO

Copied to clipboard
Kai