Reputation: 341
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:
"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."
I have added the following line to php in my own layer:
PACKAGECONFIG_append = " apache2"
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):
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.
Has anyone managed to compile apache2 with php support lately and can give some assistance on how to do it? Thanks!
Upvotes: 0
Views: 6412
Reputation: 1
To add PHP support with apache in yocto , make the following changes in the bitbake recipe file.
Below is the diff output of the php.inc file
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}"
Hope , this helps to work out :)
Upvotes: 0
Reputation: 341
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)}”
I don’t know if the DEPENDS and RDEPENDS are necessary any longer but they don’t seem to hurt.
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"
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.
Upvotes: 5