6.11. Web applications, Apache and PHP

6.11.1. Apache

表格 6.16. Variables for ports that use Apache
USE_APACHEThe port requires Apache. Possible values: yes (gets any version), 1.3, 2.0, 2.2, 2.0+, etc. Default dependency is on version 1.3.
WITH_APACHE2The port requires Apache 2.0. Without this variable, the port will depend on Apache 1.3. This variable is deprecated and should not be used anymore.
APXSFull path to the apxs binary. Can be overriden in your port.
HTTPDFull path to the httpd binary. Can be overriden in your 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: 13, 20, 22.
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.

表格 6.17. port Apache 模組時好用的變數
MODULENAME模組名稱。 預設值為 PORTNAME. 範例: mod_hello
SHORTMODNAME簡化的模組名稱。 自動地由變數 MODULENAME 產生,不過可以覆蓋它。 範例: hello
AP_FAST_BUILD使用 apxs 來編譯及安裝這個模組。
AP_GENPLIST同樣地,也是自動產生 pkg-plist
AP_INC在編譯時間加入一個目錄到標頭檔搜尋路徑。
AP_LIB在編譯時間加入一個目錄到函式庫搜尋路徑。
AP_EXTRAS傳給 apxs 額外的 flags。

6.11.2. Web 應用程式

Web 應用程式應該安裝到 PREFIX/www/appname 。 For your convenience, 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 you need to change the ownership of some files. The default values of both are www. If you want different values for your port, use WWWOWN?= myuser notation, to allow user to override it easily.

請別過於相依 Apache,除非這些程式有明確需要,而得相依 Apache 。也許有些使用者,會想在其他非 Apache 的 Web 伺服器上執行這些網頁程式。

6.11.3. PHP

表格 6.18. Variables for ports that use PHP
USE_PHPThe port requires PHP. The value yes adds a dependency on PHP. The list of required PHP extensions can be specified instead. Example: pcre xml gettext
DEFAULT_PHP_VERSelects which major version of PHP will be installed as a dependency when no PHP is installed yet. Default is 4. Possible values: 4, 5
IGNORE_WITH_PHPThe port does not work with PHP of the given version. Possible values: 4, 5
USE_PHPIZEThe port will be built as a PHP extension.
USE_PHPEXTThe port will be treated as a PHP extension, including installation and registration in the extension registry.
USE_PHP_BUILDSet PHP as a build dependency.
WANT_PHP_CLIWant the CLI (command line) version of PHP.
WANT_PHP_CGIWant the CGI version of PHP.
WANT_PHP_MODWant the Apache module version of PHP.
WANT_PHP_SCRWant the CLI or the CGI version of PHP.
WANT_PHP_WEBWant the Apache module or the CGI version of PHP.

6.11.4. PEAR modules

Porting PEAR modules is a very simple process.

Use the variables FILES, TESTS, DATA, SQLS, SCRIPTFILES, DOCS and EXAMPLES to list the files you want to install. All listed files will be automatically installed into the appropriate locations and added to pkg-plist.

Include ${PORTSDIR}/devel/pear/bsd.pear.mk on the last line of the Makefile.

範例 6.4. Example Makefile for PEAR class
PORTNAME=       Date
PORTVERSION=    1.4.3
CATEGORIES=     devel www pear

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

BUILD_DEPENDS=  ${PEARDIR}/PEAR.php:${PORTSDIR}/devel/pear-PEAR
RUN_DEPENDS=    ${BUILD_DEPENDS}

FILES=          Date.php Date/Calc.php Date/Human.php Date/Span.php     \
                Date/TimeZone.php
TESTS=          test_calc.php test_date_methods_span.php testunit.php   \
                testunit_date.php testunit_date_span.php wknotest.txt   \
                bug674.php bug727_1.php bug727_2.php bug727_3.php       \
                bug727_4.php bug967.php weeksinmonth_4_monday.txt       \
                weeksinmonth_4_sunday.txt weeksinmonth_rdm_monday.txt   \
                weeksinmonth_rdm_sunday.txt
DOCS=           TODO
_DOCSDIR=       .

.include <bsd.port.pre.mk>
.include "${PORTSDIR}/devel/pear/bsd.pear.mk"
.include <bsd.port.post.mk>

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/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>.