我只是设置了一个新的服务器,它将托pipe一个solr守护进程。 现在,solr索引是空的,但是我有一个php脚本可以从MySQL存储中提取数据,并填充solr索引以方便我的全文search需求。
所以我想知道,是否有可能将PHP编译为命令行? 为了让PHP正常工作,安装apache似乎是一种浪费。
– 编辑 –
多一点澄清。 当我在CentOS上运行make install时,make尝试将PHP脚本添加到/ etc / httpd / conf。 可以忽略这个吗? 还是有一个标志,我可以通过忽略阿帕奇?
如果您必须在Red Hat,CentOS或其他Red Hat衍生产品上进行编译,我build议您使用rpmbuild -bb(我将在下文中解释)使用由php提供的.spec.in或由Red Hat或上游开发人员(PHP)。 这里是来自上游的一个样本:
%define version @VERSION@ %define so_version 5 %define release 0 Name: php Summary: PHP: Hypertext Preprocessor Group: Development/Languages Version: %{version} Release: %{release} Copyright: The PHP license (see "LICENSE" file included in distribution) Source: http://www.php.net/get/php-%{version}.tar.gz/from/a/mirror Icon: php.gif URL: http://www.php.net/ Packager: PHP Group <[email protected]> BuildRoot: /var/tmp/php-%{version} %description PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. %prep %setup %build set -x ./buildconf ./configure --prefix=/usr --with-apxs \ --disable-debug \ --with-xml=shared \ # figure out configure options options based on what packages are installed # to override, use the OVERRIDE_OPTIONS environment variable. To add # extra options, use the OPTIONS environment variable. #test rpm -q MySQL-devel >&/dev/null && OPTIONS="$OPTIONS --with-mysql=shared" #test rpm -q solid-devel >&/dev/null && OPTIONS="$OPTIONS --with-solid=shared,/home/solid" #test rpm -q postgresql-devel >&/dev/null && OPTIONS="$OPTIONS --with-pgsql=shared" test rpm -q expat >&/dev/null && OPTIONS="$OPTIONS --with-xml=shared" if test "x$OVERRIDE_OPTIONS" = "x"; then ./configure --prefix=/usr --with-apxs=$APXS $OPTIONS else ./configure $OVERRIDE_OPTIONS fi
看看它说“–with-apxs”? 这是Apache HTTP服务器的开发接口的一部分。 如果没有安装,你会得到运行configuration(我相信这是你所看到的):
Configuring SAPI modules checking for AOLserver support... no checking for Apache 1.x module support via DSO through APXS... Sorry, I was not able to successfully run APXS. Possible reasons: 1. Perl is not installed; 2. Apache was not compiled with DSO support (--enable-module=so); 3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs The output of apxs follows ./configure: line 4092: apxs: command not found configure: error: Aborting
要编译没有apxs支持(从而避免需要apache),你可以改变:
--without-apxs
这将通过这一点。
现在回到构build一个spec文件。 如果您使用spec文件构build它,rpmbuild会告诉您需要哪些依赖项来允许您进行安装。 从那里,它将为您build立一个包,你可以安装它:
yum localinstall php.rpm
这将允许您安装以及满足其他要求。 通过使用包装系统正确pipe理您的系统,而不是尝试手动构build和安装,这将为您节省大量的麻烦。
(或者你可以按照embobo的build议,只安装php-cli;))。
你为什么手动编译PHP? 安装php-cli而不是php (这是apache模块)用yum 。