We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Installing Phalcon on Amazon's Elastic Beanstalk

I'm trying to get Phalcon installed on Amazon's Elastic Beanstalk service, for easy scaling and their cheap free-for-one-year tier, but since they don't appear to give direct access to the commandline, I'm having some difficulties.

I found a blog post explaining how to run a bash script at startup but I can't seem to quite wrap my head around it, particularly for implementing it for Phalcon.

Anyone have any experience with this?

You definitely can get command line access with AWS EC2 via SSH, or Putty on Windows, but I don't think they have an integrated command line in the AWS console. Not sure this is the only way but how I've always accessed AWS is to generate a security key in the AWS console then save that locally.

I use ssh -i /path/to/file/locally [email protected] on Linux or OSX.

Yeah, I got it setup no problem with EC2, you've basically got full shell access to a VM of your choice, the issue is with Elastic Beanstalk, which automatically scales with usage, therefore it requires that you make a special configuarion file to setup new containers when they're needed.

I've decided to go with a single server on EC2 for now for simplicity's sake, but definitely would like a walkthrough on setting it up in Elastic Beanstalk.



135
Accepted
answer

Based on an article about installing phpredis on Elastic Beanstalk, I got it working using the following configuration file (place it in the ".ebextensions" folder of your app, for example as "01run.config"):

commands:
    01_phalcon_install:
        # run this command from /tmp directory
        cwd: /tmp
        # don't run the command if phalcon is already installed (file /etc/php.d/phalcon.ini exists)
        test: '[ ! -f /etc/php.d/phalcon.ini ] && echo "phalcon not installed"'
        # executed only if test command succeeds
        command: |
            git clone --depth=1 git://github.com/phalcon/cphalcon.git \
            && cd cphalcon/build \
            && ./install \
            && echo extension=phalcon.so > /etc/php.d/phalcon.ini \
            && rm -rf ./cphalcon

This will automatically install the phalcon extension while deploying your application.

You sir, deserve a cookie. Thank you! This is definitely a great bit of information to have, sort of thing that should be on the homepage, really. Great job!

Based on an article about installing phpredis on Elastic Beanstalk, I got it working using the following configuration file (place it in the ".ebextensions" folder of your app, for example as "01run.config"):

commands:
   01_phalcon_install:
       # run this command from /tmp directory
       cwd: /tmp
       # don't run the command if phalcon is already installed (file /etc/php.d/phalcon.ini exists)
       test: '[ ! -f /etc/php.d/phalcon.ini ] && echo "phalcon not installed"'
       # executed only if test command succeeds
       command: |
           git clone --depth=1 git://github.com/phalcon/cphalcon.git \
           && cd cphalcon/build \
           && ./install \
           && echo extension=phalcon.so > /etc/php.d/phalcon.ini \
           && rm -rf ./cphalcon

This will automatically install the phalcon extension while deploying your application.

Many thanks man! Saved a lot of time. Peace!

Based on an article about installing phpredis on Elastic Beanstalk, I got it working using the following configuration file (place it in the ".ebextensions" folder of your app, for example as "01run.config"):

commands:
   01_phalcon_install:
       # run this command from /tmp directory
       cwd: /tmp
       # don't run the command if phalcon is already installed (file /etc/php.d/phalcon.ini exists)
       test: '[ ! -f /etc/php.d/phalcon.ini ] && echo "phalcon not installed"'
       # executed only if test command succeeds
       command: |
           git clone --depth=1 git://github.com/phalcon/cphalcon.git \
           && cd cphalcon/build \
           && ./install \
           && echo extension=phalcon.so > /etc/php.d/phalcon.ini \
           && rm -rf ./cphalcon

This will automatically install the phalcon extension while deploying your application.

Another solution using remi repository here.

ryomo/ebextensions-phalcon