CloudFoundry PHP Build Pack

953 views
Skip to first unread message

Daniel Mikusa

unread,
Mar 10, 2014, 3:35:49 PM3/10/14
to vcap...@cloudfoundry.org
Hello,

I would like to announce the availability of a new PHP Build Pack for CloudFoundry.

https://github.com/dmikusa-pivotal/cf-php-build-pack

This is a community contributed build pack and it is a complete rewrite of my previous efforts, CF PHP & Apache Build Pack.

https://github.com/dmikusa-pivotal/cf-php-apache-buildpack

The result is a huge improvement, with all the functionality of the old CF PHP & Apache Build Pack and lots of new features including...

- Executes quickly. Run detect, compile and release scripts with minimal effort, downloading as little as possible.
- support for the latest versions of Apache HTTPD 2.4 and Nginx 1.5
- support for the latest versions of PHP 5.4 and 5.5
- support for a large set of PHP extensions, including amqp, apc, bz2, curl, dba, gd, gettext, gmp, imap, ldap, mcrypt, mongo, openssl, pdo_pgsql, pgsql, pspell, redis, xdebug and zlib
- versions of HTTPD, Nginx and PHP are automatically upgraded to the latest release just by re-staging an application
- allows for application developers to control which PHP extensions are installed
- allows for application developers to custom configure HTTPD, Nginx and / or PHP
- download location is configurable, allowing users to host binaries on the same network (i.e. run without an Internet connection)
- support for an extension mechanism that allows the build pack to provided additional functionality
allows for application developers to provide custom extensions
- support for NewRelic with both bound services and when manually specifying a license key
- easy troubleshooting with the BP_DEBUG environment variable
- all logging output is routed through stderr & stdout which is sent to loggregator

If you’re interested in developing PHP applications or running a packaged PHP application on CloudFoundry, please take a look at our “30 Second Tutorial” or one of the build pack samples like PHPMyAdmin, Wordpress or the CodeIgniter Tutorial.

https://github.com/dmikusa-pivotal/cf-php-build-pack#30-second-tutorial
https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin
https://github.com/dmikusa-pivotal/cf-ex-worpress
https://github.com/dmikusa-pivotal/cf-ex-code-igniter

Enjoy, and as always, feed back and PR’s are welcome!

Dan

Dr Nic Williams

unread,
Mar 10, 2014, 4:17:40 PM3/10/14
to vcap...@cloudfoundry.org, vcap...@cloudfoundry.org
Congrats!!

Sent from Mailbox for iPad


To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.


David Laing

unread,
Mar 13, 2014, 1:36:57 AM3/13/14
to vcap-dev
Dan,

Very cool.

Out of interest; have you considered including hiphop-php [1] as a PHP "version"?

It is *dramatically* faster; and nearly 100% PHP compatible these days ( enough to run WordPress with a single modification for example )

D

--
David Laing
Trading API @ City Index
da...@davidlaing.com
http://davidlaing.com
Twitter: @davidlaing

Daniel Mikusa

unread,
Mar 13, 2014, 7:27:33 AM3/13/14
to vcap...@cloudfoundry.org
Interesting. I took a quick look and it looks like it should be possible to add support for this. The big challenge with adding new binaries is compiling and configuring them, but there are instructions for compiling on Ubuntu 10.04 and it supports FastCGI so I don’t see any immediate issues.

I like to have support for new and experimental things in the build pack as I see CloudFoundry as a good way to test and play with them. I’ll definitely add this to the TODO list.

Dan

Jeff Sloyer

unread,
Mar 13, 2014, 9:21:09 AM3/13/14
to vcap...@cloudfoundry.org, vcap...@cloudfoundry.org
This is really awesome. Since the basic MySQL connectors are being deprecated in php 5.5 are there plans to include mysqli?

I would be happy to submit a pull request for it as well!

Sent from my iPhone

> On Mar 13, 2014, at 7:27 AM, Daniel Mikusa <dmi...@gopivotal.com> wrote:
>
> Interesting. I took a quick look and it looks like it should be possible to add support for this. The big challenge with adding new binaries is compiling and configuring them, but there are instructions for compiling on Ubuntu 10.04 and it supports FastCGI so I don't see any immediate issues.
>
> I like to have support for new and experimental things in the build pack as I see CloudFoundry as a good way to test and play with them. I'll definitely add this to the TODO list.
>
> Dan
>
>
>> On Mar 13, 2014, at 1:36 AM, David Laing <mrdavi...@gmail.com> wrote:
>>
>> Dan,
>>
>> Very cool.
>>
>> Out of interest; have you considered including hiphop-php [1] as a PHP "version"?
>>
>> It is *dramatically* faster; and nearly 100% PHP compatible these days ( enough to run WordPress with a single modification for example )
>>
>> D
>>
>> [1] http://www.hhvm.com/blog/
>>
>>
>> On 10 March 2014 20:17, Dr Nic Williams <drnicw...@gmail.com> wrote:
>> Congrats!!
>> --

Daniel Mikusa

unread,
Mar 13, 2014, 9:48:55 AM3/13/14
to vcap...@cloudfoundry.org
On Mar 13, 2014, at 9:21 AM, Jeff Sloyer <jsl...@gmail.com> wrote:

> This is really awesome. Since the basic MySQL connectors are being deprecated in php 5.5 are there plans to include mysqli?

I currently build using mysqlnd.

https://github.com/dmikusa-pivotal/cf-php-buildpack-binary-build-scripts/blob/master/php-5.5/build.sh#L61-L63

In general, I don’t mind adding new extensions. Preference is to compile them as shared libraries so they can be disabled by default and enabled when needed. PR’s are certainly appreciated!

Dan

Stephen Kinder

unread,
Mar 13, 2014, 12:54:34 PM3/13/14
to vcap...@cloudfoundry.org
Dan,

Great update.  Are there a specific set of PHP development tools you'd recommend to go along with the build packs, allowing a push of incremental updates?  I am aware of Java tools for eclipse, just wondering if there are similar tools for PHP?

Steve
Steve

Daniel Mikusa

unread,
Mar 13, 2014, 1:51:17 PM3/13/14
to vcap...@cloudfoundry.org
Steve,

I wouldn’t recommend changing build tools. Whatever you normally use for PHP development should work fine. Then just use the cf command line utility to deploy to CF. Being a shell command it's pretty flexible, any tool that can run something in a shell can integrate with CF (ex: editors, ci tools, build tools, etc..).

Dan

Aristoteles Neto

unread,
Mar 13, 2014, 10:31:46 PM3/13/14
to vcap...@cloudfoundry.org

I wonder if it would be possible to push incremental updates by leveraging the Git buildpack [1], and have it track a remote repository which is where you push actual code to.

Awesome work on the PHP buildpack, by the way.

[1] - https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/9eC_wNg2DPc

-- Neto

Daniel Mikusa

unread,
Mar 15, 2014, 9:03:26 AM3/15/14
to vcap...@cloudfoundry.org
Thanks! Glad to hear it’s working out. I haven’t tried using it with the Git build pack, but I assume it should work. It is on my list of things to try out when I get some free time though.

Dan

rob9ni...@googlemail.com

unread,
May 12, 2014, 3:12:03 AM5/12/14
to vcap...@cloudfoundry.org
Dan,


I have been trying to figure out if the buildpack supports the bundling of a non standard php extension with a pushed app.  The documentation seems to hint this might be possible but I have not been able to make it work.
I have an extension that I have built locally as a .so. The extension is not one of the standard PHP extensions, nor is it available in PECL (at the moment). Is there a way to include this with the pushed app?

Thanks
Rob.


Daniel Mikusa

unread,
May 12, 2014, 7:38:34 AM5/12/14
to vcap...@cloudfoundry.org
Rob,

There’s nothing that does this directly out-of-the-box (although it’s on my todo list), but there is a general extension mechanism that you can use.

https://github.com/dmikusa-pivotal/cf-php-build-pack/blob/master/docs/development.md#extensions

With that you could do something like this…

1.) Build your extension (make sure it’s compatible with the PHP build that you’re using, generally 64-bit, Ubuntu 10.04).

2.) Package it with your app, perhaps in a folder called “.php-extensions”, but it can be called anything you like.

3.) Create an extension. See link above or see this simple example extension.

https://github.com/dmikusa-pivotal/cf-ex-worpress/blob/master/.extensions/wordpress/extension.py

4.) In the “compile” method of the extension, copy the files from the application to the extension directory.

5.) Either use the extension to edit the php.ini file and add your extension automatically, or include a php.ini file with your application and override the default.

https://github.com/dmikusa-pivotal/cf-php-build-pack/blob/master/docs/config.md#httpd-nginx-and-php-configuration

That should be it.

Dan

rob9ni...@googlemail.com

unread,
May 12, 2014, 7:55:21 AM5/12/14
to vcap...@cloudfoundry.org
Dan,

Thank you for this. I'll give that a go and tell you how I get on.

By the way, is it also on the todo list to be able to pull in an extension by name from PECL?

Thanks,
Rob,

Daniel Mikusa

unread,
May 12, 2014, 8:32:56 AM5/12/14
to vcap...@cloudfoundry.org
Rob,

If it is sufficiently requested it might be possible to add, but I’d like to try and avoid it for three reasons.

1.) I’d like to keep the compile process of the build pack as quick as possible. Downloading and compiling modules from PECL is slow.

2.) Some users don’t have Internet access and can’t download from PECL

3.) Some PECL modules require libraries and dev files that may not be installed in the staging environment.

What I’m working on at this point is an easier way to build and compile the components of the build pack. Right now I build them in a Ubuntu 10.04 VM using these scripts.

https://github.com/dmikusa-pivotal/cf-php-buildpack-binary-build-scripts

I’m working to add some documentation to this process as well as some additional automation. Essentially I’d like it to be easier for users to build their own binaries for the build pack, including custom or non-standard PHP extensions.

Any feedback in this area would be appreciated.

Dan

rob9ni...@googlemail.com

unread,
May 15, 2014, 8:28:41 AM5/15/14
to vcap...@cloudfoundry.org, rob9ni...@googlemail.com
Hi Dan,

I tried this but I ran into a problem. I'm wondering if you will be able to suggest an approach.
The PHP extension that I am trying to use happens to depend on some shared libraries. I tried including (moving in the way you suggested) these dependent libraries in the extension directory alongside the extension but they were not loaded. It seems that the LD_LIBRARY_PATH is not set to allow extensions to be able to load dependent libraries from the extensions directory. Is there anywhere in the pushed PHP application I could put the dependent libraries?

I should say at this point that I am using the buildpack in a CF environment where I do not have control of the underlying CF install (IBM Bluemix).

Thanks,
Rob.

Daniel Mikusa

unread,
May 15, 2014, 8:57:08 AM5/15/14
to vcap...@cloudfoundry.org
On May 15, 2014, at 8:28 AM, rob9ni...@googlemail.com wrote:

> Hi Dan,
>
> I tried this but I ran into a problem. I'm wondering if you will be able to suggest an approach.
> The PHP extension that I am trying to use happens to depend on some shared libraries. I tried including (moving in the way you suggested) these dependent libraries in the extension directory alongside the extension but they were not loaded. It seems that the LD_LIBRARY_PATH is not set to allow extensions to be able to load dependent libraries from the extensions directory. Is there anywhere in the pushed PHP application I could put the dependent libraries?

Yes. LD_LIBRARY_PATH includes the “$HOME/php/lib” directory. This is where the build pack puts third party libraries required by PHP extensions that are not included by the base OS. Examples of this are the mcrypt and amqp extensions, but there are others too.

Dan

walt...@gmail.com

unread,
May 19, 2014, 2:40:27 PM5/19/14
to vcap...@cloudfoundry.org

I created a MySQL service instance in IBM Bluemix, then I installed the PHPMYADMIN sample into IBM Bluemix, specifying the domain and mysql service name (mysql-sww), and all the messages look good, but when I bring up the phpmyadmin UI, it displays this message 'Invalid hostname for server 1. Please review your configuration.'.  Is there a way to reconfigure things to fix this problem?

Scott

Patrick Mueller

unread,
May 19, 2014, 4:58:12 PM5/19/14
to vcap-dev
Scott, this sounds like it's not a general Cloud Foundry issue, so you might want to post your question on the BlueMix Q+A site instead:


There is already (at least) one answered question about PHPMYADMIN:




On Mon, May 19, 2014 at 2:40 PM, <walt...@gmail.com> wrote:

I created a MySQL service instance in IBM Bluemix, then I installed the PHPMYADMIN sample into IBM Bluemix, specifying the domain and mysql service name (mysql-sww), and all the messages look good, but when I bring up the phpmyadmin UI, it displays this message 'Invalid hostname for server 1. Please review your configuration.'.  Is there a way to reconfigure things to fix this problem?

Scott

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/da61e673-8d3c-47e4-8096-2405b7c52f12%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Patrick Mueller
http://muellerware.org

Daniel Mikusa

unread,
May 20, 2014, 7:34:27 AM5/20/14
to vcap...@cloudfoundry.org
Scott,

Meant to reply to this yesterday, sorry. I believe that “Invalid hostname for server 1”, means that the PHPMyAdmin configuration for the database is wrong.

If you look at this part of the config file…

https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin/blob/master/htdocs/config.inc.php#L27

You’ll see where the example loads the VCAP_SERVICES environment variable, parses the JSON and picks the bound MySQL service. It then sets the hostname for the server on this line.

https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin/blob/master/htdocs/config.inc.php#L37

I haven’t used Bluemix so I can’t say for sure, but it seems like this might need to be adjusted in your environment.

Dan


On May 19, 2014, at 2:40 PM, walt...@gmail.com wrote:

>
> I created a MySQL service instance in IBM Bluemix, then I installed the PHPMYADMIN sample into IBM Bluemix, specifying the domain and mysql service name (mysql-sww), and all the messages look good, but when I bring up the phpmyadmin UI, it displays this message 'Invalid hostname for server 1. Please review your configuration.'. Is there a way to reconfigure things to fix this problem?
>
> Scott
>

Scott

unread,
May 21, 2014, 9:53:47 AM5/21/14
to vcap...@cloudfoundry.org
Right, that was the problem, the VCAP_SERVICES is parsed out differently for Bluemix.  Thanks!
Scott


On Tue, May 20, 2014 at 7:34 AM, Daniel Mikusa <dmi...@gopivotal.com> wrote:
Scott,

Meant to reply to this yesterday, sorry.  I believe that "Invalid hostname for server 1", means that the PHPMyAdmin configuration for the database is wrong.

If you look at this part of the config file...


  https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin/blob/master/htdocs/config.inc.php#L27

You'll see where the example loads the VCAP_SERVICES environment variable, parses the JSON and picks the bound MySQL service.  It then sets the hostname for the server on this line.

  https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin/blob/master/htdocs/config.inc.php#L37

I haven't used Bluemix so I can't say for sure, but it seems like this might need to be adjusted in your environment.

Dan


On May 19, 2014, at 2:40 PM, walt...@gmail.com wrote:

>
> I created a MySQL service instance in IBM Bluemix, then I installed the PHPMYADMIN sample into IBM Bluemix, specifying the domain and mysql service name (mysql-sww), and all the messages look good, but when I bring up the phpmyadmin UI, it displays this message 'Invalid hostname for server 1. Please review your configuration.'.  Is there a way to reconfigure things to fix this problem?
>
> Scott
>
> --
> You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

--
You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/42D85CD9-30A3-46E8-97E6-EC08B0BB0FD3%40gopivotal.com.

rob9ni...@googlemail.com

unread,
Jun 2, 2014, 4:50:24 AM6/2/14
to vcap...@cloudfoundry.org

On Thursday, 15 May 2014 13:57:08 UTC+1, Daniel Mikusa wrote:
On May 15, 2014, at 8:28 AM, rob9ni...@googlemail.com wrote:

> I tried this but I ran into a problem. I'm wondering if you will be able to suggest an approach.
> The PHP extension that I am trying to use happens to depend on some shared libraries. I tried including (moving in the way you suggested) these dependent libraries in the extension directory alongside the extension but they were not loaded. It seems that the LD_LIBRARY_PATH is not set to allow extensions to be able to load dependent libraries from the extensions directory. Is there anywhere in the pushed PHP application I could put the dependent libraries?

Yes.  LD_LIBRARY_PATH includes the “$HOME/php/lib” directory.  This is where the build pack puts third party libraries required by PHP extensions that are not included by the base OS.  Examples of this are the mcrypt and amqp extensions, but there are others too.

Dan

This worked for me, thanks Dan.
One thing I had trouble with was the versions of shared objects against which my extension is built. For example, initially I had compiled against a version of libssl.so that didnt seem to be present. I was eventually successful by compiling against libssl0.9.8. I'm struggling to figure out what it is that defines the version and availability of common shared libraries. Is this defined by the PHP buildpack or by the underlying cloudfoundry installation? (in my case IBM's bluemix). Thanks.

Daniel Mikusa

unread,
Jun 2, 2014, 8:30:56 AM6/2/14
to vcap...@cloudfoundry.org
This would be the "stack" that you are using.  


If you're going build an extension, you'll want to match the OS of the VM where you're building the extension to the OS of your stack.  For example, Pivotal Web Services runs Ubuntu 10.04 at the moment, so when I build for it, I build in a local 10.04 VM.  This allows me to match versions of the libraries provided by the stack.

If you need to build against a specific version of a library or a libraray that is not included with the stack, you can package it with the build pack and use LD_LIBRARY_PATH to specify it's location, like I suggested above.

Dan
 

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
Message has been deleted

mcm...@gmail.com

unread,
Aug 22, 2014, 2:52:42 PM8/22/14
to vcap...@cloudfoundry.org
How hard would it be to add in mbstring support? I'm trying to get pimcore up and running without rolling my own buildpack..

Jason McMunn
 

Daniel Mikusa

unread,
Aug 22, 2014, 3:55:58 PM8/22/14
to vcap...@cloudfoundry.org
On Fri, Aug 22, 2014 at 2:52 PM, <mcm...@gmail.com> wrote:
How hard would it be to add in mbstring support? I'm trying to get pimcore up and running without rolling my own buildpack..

It's already there.  You just need to enable the extension for it.  See instructions here for how to enable extensions.  


See the main README for a list of supported extensions, but wait about 10 minutes cause I just realized it out of date.

Dan
 

Jason McMunn
 

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.

Jason McMunn

unread,
Aug 22, 2014, 4:08:38 PM8/22/14
to vcap...@cloudfoundry.org
Yeah. I should have RTFM. Sorry about that. Trying this now:

{
    "PHP_EXTENSIONS": [ "bz2", "zlib", "curl", "mcrypt", "mbstring", "gd", "zip", "dom", "openssl", "memcache", "imagick", "simplexml", "iconv"]
}

You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CAAqVxAw8O6Y9XN482nPyWgWRyfMTU1X6XxQ98GEr-mViTSb6wg%40mail.gmail.com.

Jason McMunn

unread,
Aug 22, 2014, 4:29:07 PM8/22/14
to vcap...@cloudfoundry.org
I’m not sure what i’m wrong..

2014-08-22T16:26:11.06-0400 [RTR]     OUT pimcore.mybluemix.net - [22/08/2014:20:26:10 +0000] "GET / HTTP/1.1" 500 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36" 75.126.70.43:14669 vcap_request_id:c74a9747-8d06-4c89-5209-18174bd8b6c4 response_time:0.080329014 app_id:c9fb30b7-81de-4154-8ce9-be8b05351807
2014-08-22T16:26:11.71-0400 [App/0]   ERR 75.126.37.75 - - [22/Aug/2014:20:26:10 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
2014-08-22T16:26:11.71-0400 [App/0]   ERR [Fri Aug 22 20:26:11.041513 2014] [proxy_fcgi:error] [pid 105:tid 140552687933184] [client 75.126.37.75:41140] AH01071: Got error 'PHP message: PHP Fatal error:  Call to undefined function mb_internal_encoding() in /home/vcap/app/pimcore/lib/Pimcore.php on line 451\n'
2014-08-22T16:26:11.71-0400 [App/0]   ERR [22-Aug-2014 20:26:11] WARNING: [pool www] child 100 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Call to undefined function mb_internal_encoding() in /home/vcap/app/pimcore/lib/Pimcore.php on line 451"

Caveat:pimcore-latest mcmunn$ ls -lart
total 24
-rw-r--r--@    1 mcmunn  staff   2510 Mar  7 11:53 .htaccess
-rw-r--r--@    1 mcmunn  staff    639 May 14 13:30 index.php
drwxr-xr-x@    3 mcmunn  staff    102 Jul  2 15:19 plugins
drwxr-xr-x@    9 mcmunn  staff    306 Jul  2 15:19 pimcore
drwxr-xr-x@    7 mcmunn  staff    238 Jul  2 15:20 website
drwx------+ 1511 mcmunn  staff  51374 Aug 22 14:26 ..
-rw-r--r--     1 mcmunn  staff     22 Aug 22 16:11 test.php
drwx------@    9 mcmunn  staff    306 Aug 22 16:11 .
drwxr-xr-x     3 mcmunn  staff    102 Aug 22 16:19 .bp-config

Caveat:pimcore-latest mcmunn$ find .bp-config/
.bp-config/
.bp-config//options.json
Caveat:pimcore-latest mcmunn$ cat .bp-config/options.json 
{
    "PHP_EXTENSIONS": [ "bz2", "zlib", "curl", "mcrypt", "mbstring", "gd", "zip", "openssl", "memcache"],
}




On Aug 22, 2014, at 3:55 PM, Daniel Mikusa <dmi...@pivotal.io> wrote:

You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CAAqVxAw8O6Y9XN482nPyWgWRyfMTU1X6XxQ98GEr-mViTSb6wg%40mail.gmail.com.

Daniel Mikusa

unread,
Aug 22, 2014, 4:32:54 PM8/22/14
to vcap...@cloudfoundry.org
Try look at the output from the build pack.  


You'll want to confirm that it's loading the extension you need.  You can also look at "cf files <app> app/php/etc/php.ini" and check the php.ini file it generates.

Dan



Jason McMunn

unread,
Aug 22, 2014, 6:06:27 PM8/22/14
to vcap...@cloudfoundry.org
Thanks for all the support! Down to some issues with it not liking where the php binary is installed, but i’ll work through them!  

Thank you!

Appreciate you!

Reply all
Reply to author
Forward
0 new messages