将 PHP 安装为 CGI 和 CLI

将 PHP 安装为 CGI 和 CLI

我正在尝试为 PHP 5.1.4 中的一些旧项目设置开发环境。它需要在 apache 下作为 CGI(或 fastcgi)运行,并且我希望有 cli 二进制文件。我的配置选项是:

./configure \
--prefix=/usr/local/php-dev \
--with-config-file-path=/usr/local/php-dev/etc \
--enable-bcmath \
--enable-calendar \
--enable-dbase \
--enable-exif \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-ftp \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-memory-limit \
--enable-soap \
--enable-track-vars \
--enable-trans-sid \
--enable-versioning \
--enable-xslt \
--with-curl=/usr/local/php-libs/curl-7.12.2 \
--with-freetype \
--with-freetype-dir \
--with-gd \
--with-iconv \
--with-jpeg-dir \
--with-mhash \
--with-mime-magic \
--with-mssql=/usr/local/php-libs/freetds-0.64 \
--with-mysql=/usr/local/mysql5 \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-openssl \
--with-pdo-mysql=/usr/local/mysql5 \
--with-pear \
--with-ttf \
--with-xslt-sablot=/usr/local/sablot-1.0.3 \
--with-zlib

安装后,我只有这些文件/usr/local/php-dev/bin

pear
peardev
pecl
php
php-config
phpize

我也期望php-cgi或。从命令行php-cli运行时它显示:./php -v

PHP 5.1.4 (cgi-fcgi) (built: Sep 23 2010 09:46:33)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
 with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

所以我只有 CGI 版本,当我尝试运行 CLI 特定的脚本时,变量$argv$argcNULL

有没有办法同时拥有 CLI 和 CGI​​ 版本?(系统:slackware 13.0)

答案1

http://www.php.net/manual/en/features.commandline.introduction.php

CLI/CGI 二进制文件的名称、位置和存在方式将根据 PHP 在系统上的安装方式而有所不同。默认情况下,执行 make 时,CGI 和 CLI 都将被构建并分别作为 sapi/cgi/php-cgi 和 sapi/cli/php 放置在 PHP 源目录中。您会注意到,两者都名为 php。make install 期间发生的情况取决于您的配置行。如果在配置期间选择了模块 SAPI(例如 apxs)或使用了 --disable-cgi 选项,则在 make install 期间 CLI 将被复制到 {PREFIX}/bin/php,否则 CGI 将被放置在那里。因此,例如,如果配置行中有 --with--apxs,则在 make install 期间 CLI 将被复制到 {PREFIX}/bin/php。如果要覆盖 CGI 二进制文件的安装,请在 make install 之后使用 make install-cli。或者,您可以在配置行中指定 --disable-cgi。

那么,你试过了吗make install-cli?你有sapi这两个目录吗?

相关内容