Apache – HTTP Server
Last Updated on 2025-01-30 16:50 by Sture
Description:
The Apache HTTP Server Project aims to develop and maintain an open-source HTTP server for various modern desktop and server operating systems, such as UNIX and Windows NT. This project aims to provide a secure, efficient, and extensible server that provides HTTP services in sync with the current HTTP standards.
Apache HTTP Server version 2.4.43 or newer is required in order to operate a TLS 1.3 web server with OpenSSL 1.1.1.
WWW: http://httpd.apache.org/.
You must have a valid domain name for public access to your website.
Requirements
The following software must be installed before the Apache HTTP Server:
Installation
Search for “apache2” in the remote package repositories with:
user@freebsdsrv:~ $ pkg search apache | egrep '^apache[0-9]+-[0-9]' [enter]
apache24-2.4.62 Version 2.4.x of Apache web server
user@freebsdsrv:~ $
In this example, apache24-2.4 will be installed.
Install Apache HTTP Server 2.4 with;
user@freebsdsrv:~ $ sudo pkg install -y apache24 [enter]
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 14 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
apache24: 2.4.62
apr: 1.7.5.1.6.3_3
brotli: 1.1.0,1
curl: 8.11.1_1
expat: 2.6.4
gdbm: 1.24
jansson: 2.14
libidn2: 2.3.7
liblz4: 1.10.0,1
libnghttp2: 1.64.0
libpsl: 0.21.5_1
libssh2: 1.11.1,3
libunistring: 1.2
zstd: 1.5.6
Number of packages to be installed: 14
The process will require 46 MiB more space.
10 MiB to be downloaded.
[1/14] Fetching libidn2-2.3.7.pkg: 100% 155 KiB 158.7kB/s 00:01
[2/14] Fetching liblz4-1.10.0,1.pkg: 100% 163 KiB 167.3kB/s 00:01
[3/14] Fetching zstd-1.5.6.pkg: 100% 503 KiB 515.3kB/s 00:01
[4/14] Fetching libunistring-1.2.pkg: 100% 683 KiB 699.4kB/s 00:01
[5/14] Fetching brotli-1.1.0,1.pkg: 100% 372 KiB 381.2kB/s 00:01
[6/14] Fetching curl-8.11.1_1.pkg: 100% 2 MiB 1.7MB/s 00:01
[7/14] Fetching jansson-2.14.pkg: 100% 50 KiB 51.7kB/s 00:01
[8/14] Fetching libnghttp2-1.64.0.pkg: 100% 142 KiB 145.5kB/s 00:01
[9/14] Fetching apr-1.7.5.1.6.3_3.pkg: 100% 500 KiB 512.4kB/s 00:01
[10/14] Fetching apache24-2.4.62.pkg: 100% 5 MiB 5.5MB/s 00:01
[11/14] Fetching libssh2-1.11.1,3.pkg: 100% 244 KiB 249.6kB/s 00:01
[12/14] Fetching libpsl-0.21.5_1.pkg: 100% 65 KiB 66.1kB/s 00:01
[13/14] Fetching expat-2.6.4.pkg: 100% 120 KiB 122.4kB/s 00:01
[14/14] Fetching gdbm-1.24.pkg: 100% 244 KiB 250.0kB/s 00:01
Checking integrity... done (0 conflicting)
[1/14] Installing libunistring-1.2...
[1/14] Extracting libunistring-1.2: 100%
[2/14] Installing libidn2-2.3.7...
[2/14] Extracting libidn2-2.3.7: 100%
[3/14] Installing liblz4-1.10.0,1...
[3/14] Extracting liblz4-1.10.0,1: 100%
[4/14] Installing zstd-1.5.6...
[4/14] Extracting zstd-1.5.6: 100%
[5/14] Installing brotli-1.1.0,1...
[5/14] Extracting brotli-1.1.0,1: 100%
[6/14] Installing libnghttp2-1.64.0...
[6/14] Extracting libnghttp2-1.64.0: 100%
[7/14] Installing libssh2-1.11.1,3...
[7/14] Extracting libssh2-1.11.1,3: 100%
[8/14] Installing libpsl-0.21.5_1...
[8/14] Extracting libpsl-0.21.5_1: 100%
[9/14] Installing expat-2.6.4...
[9/14] Extracting expat-2.6.4: 100%
[10/14] Installing gdbm-1.24...
[10/14] Extracting gdbm-1.24: 100%
[11/14] Installing curl-8.11.1_1...
[11/14] Extracting curl-8.11.1_1: 100%
[12/14] Installing jansson-2.14...
[12/14] Extracting jansson-2.14: 100%
[13/14] Installing apr-1.7.5.1.6.3_3...
[13/14] Extracting apr-1.7.5.1.6.3_3: 100%
[14/14] Installing apache24-2.4.62...
===> Creating groups
Using existing group 'www'
===> Creating users
Using existing user 'www'
[14/14] Extracting apache24-2.4.62: 100%
=====
Message from apr-1.7.5.1.6.3_3:
--
The Apache Portable Runtime project removed support for FreeTDS with
version 1.6. Users requiring MS-SQL connectivity must migrate
configurations to use the added ODBC driver and FreeTDS' ODBC features.
=====
Message from apache24-2.4.62:
--
To run apache www server from startup, add apache24_enable="yes"
in your /etc/rc.conf. Extra options can be found in startup script.
Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch.conf typically DNS or /etc/hosts or apache might
have issues starting depending on the modules you are using.
- apache24 default build changed from static MPM to modular MPM
- more modules are now enabled per default in the port
- icons and error pages moved from WWWDIR to DATADIR
If build with modular MPM and no MPM is activated in
httpd.conf, then mpm_prefork will be activated as default
MPM in etc/apache24/modules.d to keep compatibility with
existing php/perl/python modules!
Please compare the existing httpd.conf with httpd.conf.sample
and merge missing modules/instructions into httpd.conf!
user@freebsdsrv:~ $
To start the Apache HTTP Server on system boot:
user@freebsdsrv:~ $ sudo sysrc apache24_enable="YES" [enter]
apache24_enable: -> YES
user@freebsdsrv:~ $
Open file /usr/local/etc/apache24/httpd.conf with:
user@freebsdsrv:~ $ sudo ee +217 /usr/local/etc/apache24/httpd.conf [enter]
Line 217: Change admin email address
ServerAdmin admin@local.lan
Line 226: Change to server name
ServerName freebsdsrv.local.lan:80
Make sure the Apache HTTP configuration is correct by running the following command to test:
user@freebsdsrv:~ $ sudo apachectl configtest [enter]
Performing sanity check on apache24 configuration:
Syntax OK
user@freebsdsrv:~ $
Start the httpd service
Manually start apache24 with:
user@freebsdsrv:~ $ sudo service apache24 start [enter]
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
user@freebsdsrv:~ $
Display the apache24 service status with:
user@freebsdsrv:~ $ sudo service apache24 status [enter]
apache24 is running as pid 10207.
user@freebsdsrv:~ $
Display the /var/log/httpd-error.log file with:
user@freebsdsrv:~ $ cat /var/log/httpd-error.log [enter]
[Tue Jan 28 17:24:52.324956 2025] [mpm_prefork:notice] [pid 36445] AH00163: Apache/2.4.62 (FreeBSD) configured -- resuming normal operations
[Tue Jan 28 17:24:52.325105 2025] [core:notice] [pid 36445] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
user@freebsdsrv:~ $
Try to access the Apache HTTP server from a computer on the same network with:
Display the /var/log/httpd-access.log file with:
user@freebsdsrv:~ $ cat /var/log/httpd-access.log [enter]
192.168.1.195 - - [30/Jan/2025:16:49:22 +0100] "GET / HTTP/1.1" 200 45
user@freebsdsrv:~ $