Yocto 中支持 PHP 的 Apache2 [英] Apache2 with PHP support in Yocto

查看:30
本文介绍了Yocto 中支持 PHP 的 Apache2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Yocto 创建一个包含 apache2 的构建,但我很难添加 php 支持.我以前运行过它(阅读:去年),但从那时起,meta-openembedded 中的元网络服务器层发生了变化.来自 meta-webserver 中的 README 文件:

I am using Yocto to create a build including apache2 but I have a hard time adding php support. I had it running previously (read: last year) but since then there have been changes to the meta-webserver layer in meta-openembedded. From the README file in meta-webserver:

"这一层用于提供构建 mod_php 的 modphp 配方,但是这现在作为meta-oe中php配方的一部分构建.然而,由于构建mod_php需要apache2,apache2配方在这个meta-oe 中的 layer 和 recipes 不能依赖它,mod_php 没有构建默认情况下.如果您确实希望使用 mod_php,则需要添加apache2"添加到 php 配方的 PACKAGECONFIG 值以启用它."

"This layer used to provide a modphp recipe that built mod_php, but this is now built as part of the php recipe in meta-oe. However, since apache2 is required to build mod_php, and apache2 recipe is in this layer and recipes in meta-oe can't depend on it, mod_php is not built by default. If you do wish to use mod_php, you need to add "apache2" to the PACKAGECONFIG value for the php recipe in order to enable it."

我在自己的层中向 php 添加了以下行:

I have added the following line to php in my own layer:

PACKAGECONFIG_append = "apache2"

PACKAGECONFIG_append = " apache2"

但是当我在编译 mod_php 时找不到似乎是 apache 包含文件的内容时,我得到了编译错误(我在下面只包含了一个错误,我对 ap_config.h 也有类似的错误):

But I get compilations error when it can't find what appears to be apache include files when compiling mod_php (I include only one error below, I get a similar error for ap_config.h as well):

在/home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/mod_php5.c 包含的文件中:26:0:|/home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/php_apache.h:24:19: 致命错误:httpd.h:没有那个文件或目录|编译终止.

In file included from /home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/mod_php5.c:26:0: | /home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/php_apache.h:24:19: fatal error: httpd.h: No such file or directory | compilation terminated.

最近有没有人设法用 php 支持编译 apache2 并且可以提供一些关于如何做的帮助?谢谢!

Has anyone managed to compile apache2 with php support lately and can give some assistance on how to do it? Thanks!

推荐答案

在 Armin Kuster 的宝贵帮助下,我设法解决了我的问题.Armin 注意到 PACKAGECONFIG_append = "apache2" 覆盖了现有的 PACKAGECONFIG 并且只设置了 "apache2".根据他的建议,我更改了我的 bbappend 文件以包含以下内容:

With valued help from Armin Kuster I managed to solve my issue. Armin noticed that PACKAGECONFIG_append = " apache2" overrides the existing PACKAGECONFIG and sets "apache2" only. Based on his suggestion I changed my bbappend file to include the following:

DEPENDS = "apache2"
RDEPENDS_${PN} = "apache2"
PACKAGECONFIG = "sqlite3 apache2 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}"

我不知道 DEPENDS 和 RDEPENDS 是否不再需要,但它们似乎没有伤害.

I don’t know if the DEPENDS and RDEPENDS are necessary any longer but they don’t seem to hurt.

然后我意识到仅仅在我的 layer.conf 中添加 'php' 并不能像过去那样构建二进制文件.我必须明确指定 php-cli 和 php-modphp.我的 layer.conf 现在包括这个:

I then realised that just adding 'php' to my layer.conf doesn't build the binaries like they did in the past. I had to explicitly specify php-cli and php-modphp. My layer.conf now includes this:

IMAGE_INSTALL_append = " apache2 php php-cli php-modphp"

使用此 PHP 配方构建并包含 php 二进制文件和 php apache 模块.但是,文件/etc/apache/modules.d/70_mod_php5.conf 不会加载 PHP 模块,因为 PHP5 环境变量未定义(请参阅下面的默认文件).我不知道在哪里指定环境变量,所以我最终在我自己的层中覆盖了这个文件,在我的版本中我只是删除了 IfDefine.

With this the PHP recipe builds and includes both the php binary and the php apache module. However, the file /etc/apache/modules.d/70_mod_php5.conf does not load the PHP module since the PHP5 environment variable is not defined (see default file below). I didn't know where to specify the environment variable so instead I ended up overriding this file in my own layer and in my version I simply removed the IfDefine.

# vim: ft=apache sw=4 ts=4
<IfDefine PHP5>
        # Load the module first
        <IfModule !sapi_apache2.c>
                LoadModule php5_module    /usr/lib/apache2/modules/libphp5.so
        </IfModule>

        # Set it to handle the files
        AddHandler php5-script .php .phtml .php3 .php4 .php5
        AddType application/x-httpd-php-source .phps
        DirectoryIndex index.html index.html.var index.php index.phtml
</IfDefine>

我希望这可以帮助其他有同样问题的人.

I hope that this can be of help to others with the same issue.

这篇关于Yocto 中支持 PHP 的 Apache2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆