Archival Notice
This guide was written for legacy FreeBSD administration using source compilation inside /usr/ports/www/apache24. Please ensure compilation dependencies are verified or consider utilizing precompiled binary software package structures (pkg install).
When deploying highly performant web application stacks across bare-metal server hardware (such as custom data center hosting nodes in east-dc1 or west-dc1), compiling Apache HTTP server and PHP processing engines directly from source yields maximum execution efficiency.
In this systems architecture guide, I examine how to navigate local FreeBSD port boundaries, compile optimized Apache 2.4 server daemons, resolve source compilation dependencies for PHP runtime interpreters, and start daemon processes using system configuration tables (rc.conf).
Step 1: Compiling Apache 2.4 from Source Ports
Access your local FreeBSD source ports tree directory and launch compile rules for the Apache HTTP engine.
# Navigate to Apache web server source directory
cd /usr/ports/www/apache24
# Launch build and install rules
make install clean
Step 2: Enabling Auto-Startup and Running Initialization
To guarantee persistent background operation across server reboot cycles, define initialization directives inside /etc/rc.conf.
# Append enablement directive to system initialization maps
sysrc apache24_enable="YES"
Initialize your compiled web server daemon and verify active listener sockets on port 80:
# Start HTTP service processes
service apache24 start
# Output running process status
service apache24 status
Step 3: Compiling PHP Modules and Integration Maps
Navigate to the PHP source ports directory and compile core language runtime interpreters with explicit dynamic Apache module integration wrappers.
# Navigate to PHP compile directory
cd /usr/ports/lang/php
# Compile source binaries specifying Apache shared object support
make install clean
Configuring Apache Module Mapping (httpd.conf)
Ensure Apache loads compiled shared object processing extensions by modifying the primary server configuration file /usr/local/etc/apache24/httpd.conf:
vi /usr/local/etc/apache24/httpd.conf
Insert the following module configuration block into your HTTP configuration header:
LoadModule php_module libexec/apache24/libphp.so
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
Restart your active Apache web server to apply configuration changes and parse incoming dynamic files:
service apache24 restart
Stack Operational
Your bare-metal FreeBSD web server is successfully compiled and answering incoming dynamic client request pipelines optimally!
References
- FreeBSD Official Documentation: Setting up Apache Web Servers
- Apache Core 2.4 Engine Configuration Guide