我正在使用Yocto创建一个包含apache2的构建,但是我很难添加php支持.我以前运行过它(阅读:去年),但是从那时起,对meta-openembedded中的meta-webserver层进行了更改.从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配方的一部分而构建.但是,由于 apache2是构建mod_php所必需的,并且apache2配方在此 meta-oe中的图层和配方无法依赖它,未构建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.
然后我意识到,仅将'php'添加到我的layer.conf中并不会像以前那样构建二进制文件.我必须明确指定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模块.但是,由于未定义PHP5环境变量,因此文件/etc/apache/modules.d/70_mod_php5.conf不会加载PHP模块(请参见下面的默认文件).我不知道在哪里指定环境变量,因此我最终在自己的层中覆盖了该文件,而在我的版本中,我只是删除了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
发布评论