2016-07-07 138 views
0

我使用Yocto创建包括apache2的构建,但是我很难添加php支持。我曾经运行过它(去年),但从那以后,meta-openembedded中的meta-webserver层发生了变化。从元网络服务器的README文件:Apache2在Yocto中支持PHP

"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:

PACKAGECONFIG_append = " apache2"

,但我得到的编译错误,当它不能找到什么似乎被阿帕奇包括文件时,编译mod_php的(包括我下面只有一个错误,我得到一个类似的错误ap_config.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和如何做到这一点可以提供一些帮助?谢谢!

回答

2

在Armin Kuster的重视帮助下,我设法解决了我的问题。 Armin注意到PACKAGECONFIG_append =“apache2”覆盖了现有的PACKAGECONFIG并仅设置了“apache2”。根据他的建议,我改变了我的bbappend文件,包括以下内容:

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

我不知道,如果depends和RDEPENDS任何必要的时间较长,但他们似乎没有受到伤害。

然后我意识到只要在我的layer.conf中添加'php'就不会像过去那样构建二进制文件。我不得不明确指定php-cli和php-modphp。我的layer.conf现在包括:

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

使用此PHP配方可以构建并包含php二进制文件和php apache模块。但是,由于未定义PHP5环境变量,因此文件/etc/apache/modules.d/70_mod_php5.conf不加载PHP模块(请参见下面的默认文件)。我不知道在哪里指定环境变量,所以我最终在我自己的层中重写了这个文件,而在我的版本中,我只是删除了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> 

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

0

要在yocto中使用apache添加PHP支持,请在bitbake配方文件中进行以下更改。

下面是php.inc文件的diff的输出

10c10 
<   openssl libmcrypt" 
--- 
>   openssl libmcrypt apache2-native apache2" 
52c54,55 
< EXTRA_OECONF = "--enable-mbstring \ 
--- 
> EXTRA_OECONF = "--with-apxs2=${STAGING_BINDIR_CROSS}/apxs \ 
>    --enable-mbstring \ 
129c132 
<  if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then 
--- 
>  if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'true', d)}; then 
200c203 
< PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-phar ${MODPHP_PACKAGE} ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}" 
--- 
> PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-phar ${MODPHP_PACKAGE} ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN} ${PN}-modphp" 
236a240 
> #FILES_${PN} += "${sysconfdir}" 

希望,这有利于制定出:)