Coder Social home page Coder Social logo

heroku-buildpack-php's Introduction

Apache+PHP build pack

This is a build pack bundling PHP and Apache for Heroku apps.

Features:

  • PHP 5.5.11 (PHP-FPM)
  • Apache HTTP Server 2.4.9
  • Composer Support
  • Opcache Enabled
  • PECL Memcached
  • GD support
  • igbinary support
  • mcrypt support (to support Laravel 4)
  • PostgreSQL support
  • MongoDB support

Configuration

The config files are bundled with the buildpack itself:

  • conf/httpd.conf
  • conf/php.ini

Configure Heroku to use this buildpack repo AND branch

$ heroku config:set BUILDPACK_URL=git://github.com/winglian/heroku-buildpack-php.git#mpm-event-php55-fpm

This buildpack also supports custom Document Roots in your application. Simply add an environment variable. If your document root is public in the root of your repo, then run

$ heroku config:set WWWROOT=/public

Composer

Composer support is built in. Simpy drop your composer.json into the root of your repository the buildpack will automatically install the requirements and dependencies into the dyno. Because composer dependencies are saved in the dyno, when you scale up, all the dynos are ensured to be identical. Please be aware that if for example github is down when you push to heroku, that the composer install will fail and you will have a broken dyno and you should roll-back.

Composer Private Repository Support

This buildpack now supports private repositories. You should create a new ssh keypair, which you should tar and then AES encrypt and make publicly available. You can either store the encrypted bundle on S3 or a publicly available git repo that allows public access the raw contents. See http://getcomposer.org/doc/05-repositories.md#using-private-repositories for information on how to setup private repositories in your composer.json.

$ export SSH_BUNDLE_PASSWORD="Y0urSup3rS3cretP@ssw0rd"
$ heroku config:set SSH_BUNDLE_PASSWORD={$SSH_BUNDLE_PASSWORD}
$ cd /tmp
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa): /tmp/.ssh/id_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /tmp/.ssh/id_rsa.
Your public key has been saved in /tmp/.ssh/id_rsa.pub.
$ cat << 'EOF' > /tmp/.ssh/config
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF
$ tar -czv .ssh | openssl enc -out ssh_bundle_enc -e -k $SSH_BUNDLE_PASSWORD -aes-128-cbc

You will then need to upload ssh_bundle_enc to either S3 or save to a public git repo and allow authentication with /tmp/.ssh/id_rsa.pub to your private repository

$ cd -
$ heroku config:set SSH_BUNDLE_URL="http://s3.amazonaws.com/bucket/{path to folder containing ssh_bundle_enc}/ssh_bundle_enc"
$ heroku labs:enable user-env-compile

Hacking with shell scripts

This buildpack includes several hooks allowing you to add custom behavior when the dyno is compiled as well as when a dyno is spun up. By adding a .heroku/compile.sh script into the root of your repository (not the buildpack's repository), you can add additional hooks such as uploading static assets to your CDN, building the cache, etc. The .heroku/compile.sh file will be deleted before the dyno is saved and any other shell scripts in the .heroku directory will be executed when the dyno is spun up.

Pre-compiling binaries

After building the binary below, update the OPT_BUILDPACK_URL variable in bin/compile to point to the url of the vulcan binary from Heroku

$ vulcan build -v -s ./build -p /tmp/build -c "./vulcan.sh"

Hacking

To change this buildpack, fork it on Github. Push up changes to your fork, then create a test app with --buildpack and push to it.

Meta

Original buildpack by Pedro Belo. https://github.com/heroku/heroku-buildpack-php

heroku-buildpack-php's People

Contributors

winglian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-buildpack-php's Issues

Executing post-install-cmd commands from composer.json

The default composer.json provided by laravel has the following scripts:

"scripts": {
        "post-install-cmd": [
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },

However, php is not available, thus the push fails. I tried using $BUILD_DIR/bin/php, since that's what you use in the compile script to execute composer, however apparently $BUILD_DIR is empty when composer executes these functions because I receive the following error messages.

sh: /bin/php: not found
Script $BUILD_DIR/bin/php artisan optimize handling the post-install-cmd event returned with an error

How might I go about modifying the composer.json provided by Laravel so that it can successfully execute artisan commands via the json file?

MongoDB support

I recently installed this build pack and run Laravel 4 on Heroku. I added https://github.com/jenssegers/Laravel-MongoDB/ to my Laravel application and pushed changes to heroku. However I got Class 'MongoClient' not found error.
Is there some way to add MongoClient class to this build pack?

Thanks :)

PHP FTP support

It would be great if we could add in support for the PHP FTP extension

In order to use FTP functions with your PHP configuration, you should add the --enable-ftp option when installing PHP.

Permission denied

[core:error] pid 46:tid 139813576832768Permission denied: [client 172.17.42.1:44701] AH00035: access to /php-cgi/index.php denied (filesystem path '/app/apache/cgi-bin') because search permissions are missing on a component of the path

gzip: stdin: not in gzip format

Push is rejected:

-----> PHP app detected
Build dir is /tmp/build_ebbce85d-a645-44e4-82a2-f0046069479b
-----> Extracting Apache 2.4.9 PHP 5.5.11 build 2.0-rc2
-----> from http://vulcan-wlian.herokuapp.com/output/95ee1f8b-46fa-4ef7-a99f-92d6e03ed8d2

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Exiting with failure status due to previous errors

 !     Push rejected, failed to compile PHP app```

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.