Today I will introduce how to run PHP in the BlueMix.
What you need to prepare before building and runing the app ?
a)A BlueMix account
b)Familiarity with the Cloud Foundry cf command-line interface, which you can download directly from the BlueMix site
c)Elementary knowledge of the PHP programming language
1.Write the php code
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
2.Choose the php buildpack,actually there are many php buildpack provided.The most popular php buildpack is heroku-buildpack-php.You can also try others as well.
3. Use cf command to login into the bluemix,it will let you enter the email and password
cf login -a https://api.ng.bluemix.net
4.After log in to your BlueMix account and run this command from the root folder of your application, where appname represents a unique name for your BlueMix-hosted app.I have tested below three buildpack,they both support php,you can pick anyone of three to test it.
cf push myphptest -b https://github.com/dmikusa-pivotal/cf-php-build-pack.git --no-manifest --no-start
cf push myphptest -b https://github.com/cyberdelia/heroku-buildpack-php.git --no-manifest --no-start
cf push myphptest -bhttps://github.com/zendtech/zend-server-php-buildpack.git --no-manifest --no-start
Note:you can also write a manifest.yml to include the BlueMix deploy information.For example:
---
applications:
- name: myphptest
memory: 256M
instances: 1
host: myphptest
buildpack: https://github.com/zendtech/zend-server-php-buildpack.git
So you can use only cf push command to do that.
5.When you deploy sucessfully,you can launch the url myphptest.bluemix.net/hello.php,when you see the hello world page,it means your deployment is sucessfully.
No comments:
Post a Comment