Table of Contents
InstallationConfiguration
PHP method #1: Apache module
PHP method #2: FastCGI
PHP method #3: PHP-FPM
Virtual host template
SSL Support (HTTPS)
Installation
Choosing an MPM
Apache Multi-Processing Modules (MPMs) are responsible for binding to network ports on the machine, accepting requests, and dispatching children to handle the requests.
Prefork MPM
This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server. Each server process may answer incoming requests, and a parent process manages the size of the server pool. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.
Worker MPM
This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with fewer system resources than a process-based server. However, it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.
Event MPM
The event Multi-Processing Module (MPM) is designed to allow more requests to be served simultaneously by passing off some processing work to supporting threads, freeing up the main threads to work on new requests. It is based on the worker MPM, which implements a hybrid multi-process multi-threaded server. Run-time configuration directives are identical to those provided by worker.
Enabling SUEXEC
SUEXEC allows you to run each virtual host as a different user:group not the default www:www. In order to use this feature you will have to use FastCGI method of running PHP.
If you want to use SUEXEC add the following to /etc/make.conf before compiling Apache:
.if ${.CURDIR:M*/www/apache24} # SUEXEC will refuse to run CGI scripts if they are not in SUEXEC_DOCROOT. # Set the following variable to the directory where your sites are. # Or just set it "/" if to disable this security feature SUEXEC_DOCROOT=/home .endif
Installation
If you are upgrading from version 2.2 you should not only remove the old apache installation but also all the apache modules:
# pkg remove -g apache\* \*mod_\*
Select the MPM, optionally enable SUEXEC or other options and install Apache:
# /usr/ports/www/apache24 # make config # make install clean