使用 PHP Farm 激活 php 扩展的问题

2021-12-29 00:00:00 ubuntu php zend-framework phpfarm

我正在实施一个需要 PHP 5.4 和 ZendGuard 6 (ZendGuard).

I am implementing a software (Getsy) that requires PHP 5.4 and ZendGuard 6 (ZendGuard).

在这种情况下,我使用的是 Ubuntu 14.04 的 AWS 实例.由于 Ubuntu 14.04 默认附带 PHP 5.5+,我需要安装 PHP 5.4.为此,我安装了 PHP Farm.

For the occasion I am using an AWS Instance of Ubuntu 14.04. As Ubuntu 14.04 comes with PHP 5.5+ by default, I needed to install PHP 5.4. To do that I installed PHP Farm.

要在站点之间更改 PHP 版本,我有这个 cgi-bin 脚本:

To change PHP versions among sites I have this cgi-bin script:

#!/bin/sh
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/phpfarm/inst/bin/php-cgi-5.4.30

对于我的特定站点(站点更改为 ****),我在 /etc/apache2/sites-enabled/****.conf 中有此配置:

For my specific site (site changed for ****), I have this configuration in /etc/apache2/sites-enabled/****.conf:

<VirtualHost *:80>
        ServerAdmin                 ...@...
        ServerName                  ****
        ServerAlias                 ****
        DocumentRoot                /var/www/****/public_html/
        ErrorLog                    /var/www/****/logs/error.log
        LogLevel                    warn
        CustomLog                   /var/www/****/logs/access.log combined
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                AddHandler php-cgi .php
                Action php-cgi /cgi-bin-php/php-cgi-5.4.30
        </Directory>
</VirtualHost>

因此,当我运行我网站的 phpinfo() 时,一切都很好,并且该网站使用 PHP 5.4.30 运行.

So, when I run my site's phpinfo() everything is fine and the site is running with PHP 5.4.30.

现在,我需要启用 ZendGuard Loader 扩展.我从 此处 使用以下命令:

Now, I need to enable the ZendGuard Loader extension. I download the 64-bit linux version from here using the following commands:

cd ~
wget http://downloads.zend.com/guard/6.0.0/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
tar -xvf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
cd ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
cd php-5.4.x
mv ZendGuardLoader.so /usr/lib/php5/ZendGuardLoader.so

所以,之后,为了安装 PHP 5.4.30,我创建了文件 custom-options-5.4.sh:

So, afterwards, in order to install PHP 5.4.30 I create the file custom-options-5.4.sh:

#!/bin/bash

#gcov='--enable-gcov'
configoptions="--disable-debug 
--enable-short-tags 
--with-pear 
--enable-bcmath 
--enable-calendar 
--enable-exif 
--enable-ftp 
--enable-mbstring 
--enable-pcntl 
--enable-soap 
--enable-sockets 
--enable-wddx 
--enable-zip 
--with-zlib 
--with-gettext 
--enable-pdo 
--with-pdo-mysql 
--enable-cgi 
--enable-json 
--with-curl 
--with-gd 
--enable-gd 
--with-openssl 
--enable-openssl 
--with-mysql 
--enable-mysql 
$gcov"

我也使用自定义的 php ini 文件作为 custom-php.ini:

I also use a custom php ini file as custom-php.ini:

include_path=".:/opt/phpfarm/inst/php-$version/pear/php/"
[Zend]
zend_extension="/usr/lib/php5/ZendGuardLoader.so"

之后,为了编译 PHP 版本,我使用以下命令:

Afterwards, in order to compile the PHP version I use this command:

cd /opt/phpfarm/src/
./compile 5.4.30

所以,紧接着我得到了所有的输出并且正确安装了 php,但是当我在 /opt/phpfarm/inst/bin/php-5.4.30 -v 中检查 PHP 版本时我得到这个输出:

So, immediately afterwards I get all the output and php gets installed correctly, but when I check the PHP version in the /opt/phpfarm/inst/bin/php-5.4.30 -v I get this output:

PHP 5.4.30 (cli) (built: Sep  3 2014 23:41:33)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

出于某种原因,它没有加载 ZendGuard 扩展.当我检查 phpinfo() 时,ZendGuard 根本没有出现.当我检查 /opt/phpfarm/inst/php-5.4.30/lib/php.ini 时,zend_extension="/usr/lib/php5/ZendGuardLoader.so" 线在那里.

For some reason it's not loading the ZendGuard extension. When I check the phpinfo() the ZendGuard doesn't appear at all. When I check the /opt/phpfarm/inst/php-5.4.30/lib/php.ini the zend_extension="/usr/lib/php5/ZendGuardLoader.so" line is there.

知道为什么没有加载扩展程序或如何启用它吗?

Any ideas why it's not loading the extension or how I could enable it?

推荐答案

显然一切正常,但出于某种原因,PHP 没有读取 php.ini 文件,并且没有反映任何更改.我所做的是删除了 inst/php-5.4.30 文件夹和 src/php-5.4.30 文件夹,我修改了我的 custom-options-5.4.sh 文件,我添加了以下行:

apparently everything was working fine but for some reason PHP wasn't reading the php.ini file and none of the changes were reflected. What I did was I deleted the inst/php-5.4.30 folder and also the src/php-5.4.30 folder, I revised my custom-options-5.4.sh file and I added the following line:

--with-config-file-path=/opt/phpfarm/inst/php-5.4.30/lib/ 

之后我再次编译,重新启动apache2,一切正常.我希望这对其他人有用:)

Afterwards I compiled again, restarted apache2 and everything worked correctly. I hope this can be useful to someone else :).

啊,而且,现在 php -v 的输出看起来像这样:

Ah, and also, now the output of php -v looks like this:

PHP 5.4.30 (cli) (built: Sep 26 2014 16:13:45)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

相关文章