GithubHelp home page GithubHelp logo

gildus / cf-ex-phpmyadmin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudfoundry-samples/cf-ex-phpmyadmin

0.0 2.0 0.0 9.21 MB

CloudFoundry PHP example application: phpmyadmin

Python 20.84% PHP 79.16%

cf-ex-phpmyadmin's Introduction

CloudFoundry PHP Example Application: PHPMyAdmin

This is an example application which can be run on CloudFoundry using the PHP Build Pack.

This is an out-of-the-box implementation of PHPMyAdmin 4.2.2. It's an example how common PHP applications can easily be run on CloudFoundry.

Usage

  1. Clone the app (i.e. this repo).
git clone https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin
cd cf-ex-phpmyadmin
  1. If you don't have one already, create a MySQL service. With Pivotal Web Services, the following command will create a free MySQL database through ClearDb.
cf create-service cleardb spark my-test-mysql-db
  1. Edit the manifest.yml file. Change the 'host' attribute to something unique. Then under "services:" change "mysql-db" to the name of your MySQL service. This is the name of the service that will be bound to your application and thus available to PHPMyAdmin.

  2. Push it to CloudFoundry.

cf push

Access your application URL in the browser. Login with the credentials for your service. If you need to find these, just run this command and look for the VCAP_SERVICES environment variable under the System Provided section.

cf env <app-name>

How It Works

When you push the application here's what happens.

  1. The local bits are pushed to your target. This is small, six files around 30k. It includes the changes we made and a build pack extension for PHPMyAdmin.
  2. The server downloads the PHP Build Pack and runs it. This installs HTTPD and PHP.
  3. The build pack sees the extension that we pushed and runs it. The extension downloads the stock PHPMyAdmin file from their server, unzips it and installs it into the htdocs directory. It then copies the rest of the files that we pushed and replaces the default PHPMyAdmin files with them. In this case, it's just the config.inc.php file.
  4. At this point, the build pack is done and CF runs our droplet.

Changes

These changes were made to prepare it to run on CloudFoundry:

  1. Configure the database in config.inc.php. This was done by reading the environment variable VCAP_SERVICES, which is populated by CloudFoundry and contains the connection information for our services, and configuring the host, port from it. See this link for the details.
  2. Remove the setup directory, which is not needed.
  3. Override the configuration file httpd-directories.conf and prevent access to the libraries directory. See this link for the details.
  4. Set the 'PmaAbsoluteUri' configuration option. This is needed because the application is using the detected host and port, which are internal to CF, to generate in the URLs. The links generated with the internal ip / port do not work and so we configure around that by grabbing the application's URL and port. Note that this would not work if multiple URL's were bound to the application. Link
  5. Increased the timeout of the session by setting 'LoginCookieValidity' and 'session.gc_maxlifetime' to 1800. Link to change #1 and change #2.

cf-ex-phpmyadmin's People

Contributors

rohanpadhye avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.