6.16. Web Applications, Apache and PHP

6.16.1. Apache

Table 6.23. Variables for Ports That Use Apache
USE_APACHEThe port requires Apache. Possible values: yes (gets any version), 22, 24, 22-24, 22+, etc. The default APACHE version is 22. More details are available in ports/Mk/bsd.apache.mk and at wiki.freebsd.org/Apache/.
APXSFull path to the apxs binary. Can be overridden in the port.
HTTPDFull path to the httpd binary. Can be overridden in the port.
APACHE_VERSIONThe version of present Apache installation (read-only variable). This variable is only available after inclusion of bsd.port.pre.mk. Possible values: 22, 24.
APACHEMODDIRDirectory for Apache modules. This variable is automatically expanded in pkg-plist.
APACHEINCLUDEDIRDirectory for Apache headers. This variable is automatically expanded in pkg-plist.
APACHEETCDIRDirectory for Apache configuration files. This variable is automatically expanded in pkg-plist.

Table 6.24. Useful Variables for Porting Apache Modules
MODULENAMEName of the module. Default value is PORTNAME. Example: mod_hello
SHORTMODNAMEShort name of the module. Automatically derived from MODULENAME, but can be overridden. Example: hello
AP_FAST_BUILDUse apxs to compile and install the module.
AP_GENPLISTAlso automatically creates a pkg-plist.
AP_INCAdds a directory to a header search path during compilation.
AP_LIBAdds a directory to a library search path during compilation.
AP_EXTRASAdditional flags to pass to apxs.

6.16.2. Web Applications

Web applications must be installed into PREFIX/www/appname. This path is available both in Makefile and in pkg-plist as WWWDIR, and the path relative to PREFIX is available in Makefile as WWWDIR_REL.

The user and group of web server process are available as WWWOWN and WWWGRP, in case the ownership of some files needs to be changed. The default values of both are www. Use WWWOWN?= myuser and WWWGRP?= mygroup if the port needs different values. This allows the user to override them easily.

Important:

Use WWWOWN and WWWGRP sparingly. Remember that every file the web server can write to is a security risk waiting to happen.

Do not depend on Apache unless the web app explicitly needs Apache. Respect that users may wish to run a web application on a web server other than Apache.

6.16.3. PHP

PHP web applications declare their dependency on it with USES=php. See Section 17.69, “php for more information.

6.16.4. PEAR Modules

Porting PEAR modules is a very simple process.

Add USES=pear to the port's Makefile. The framework will install the relevant files in the right places and automatically generate the plist at install time.

Example 6.23. Example Makefile for PEAR Class
PORTNAME=       Date
DISTVERSION=	1.4.3
CATEGORIES=	devel www pear

MAINTAINER=	example@domain.com
COMMENT=	PEAR Date and Time Zone Classes

USES=	pear

.include <bsd.port.mk>

Tip:

PEAR modules will automatically be flavorized using PHP flavors.

Note:

If a non default PEAR_CHANNEL is used, the build and run-time dependencies will automatically be added.

Important:

PEAR modules do not need to defined PKGNAMESUFFIX it is automatically filled in using PEAR_PKGNAMEPREFIX. If a port needs to add to PKGNAMEPREFIX, it must also use PEAR_PKGNAMEPREFIX to differentiate between different flavors.

6.16.4.1. Horde Modules

In the same way, porting Horde modules is a simple process.

Add USES=horde to the port's Makefile. The framework will install the relevant files in the right places and automatically generate the plist at install time.

The USE_HORDE_BUILD and USE_HORDE_RUN variables can be used to add buildtime and runtime dependencies on other Horde modules. See Mk/Uses/horde.mk for a complete list of available modules.

Example 6.24. Example Makefile for Horde Module
PORTNAME=	Horde_Core
DISTVERSION=	2.14.0
CATEGORIES=	devel www pear

MAINTAINER=	horde@FreeBSD.org
COMMENT=	Horde Core Framework libraries

OPTIONS_DEFINE=	KOLAB SOCKETS
KOLAB_DESC=	Enable Kolab server support
SOCKETS_DESC=	Depend on sockets PHP extension

USES=	horde
USE_PHP=	session

USE_HORDE_BUILD=	Horde_Role
USE_HORDE_RUN=	Horde_Role Horde_History Horde_Pack \
		Horde_Text_Filter Horde_View

KOLAB_USE=	HORDE_RUN=Horde_Kolab_Server,Horde_Kolab_Session
SOCKETS_USE=	PHP=sockets

.include <bsd.port.mk>

Tip:

As Horde modules are also PEAR modules they will also automatically be flavorized using PHP flavors.

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.