2016-07-07 137 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}" 

希望,這有利於制定出:)