GithubHelp home page GithubHelp logo

davecarlson / beanstalk-nginx-php-fpm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ricktbaker/beanstalk-nginx-php-fpm

0.0 1.0 0.0 41 KB

How to replace apache with nginx and php-fpm on AWS beanstalk

License: MIT License

Shell 73.32% Roff 25.24% PHP 1.45%

beanstalk-nginx-php-fpm's Introduction

Replace Apache with Nginx and PHP-FPM on AWS Beanstalk

If you find yourself wanting to use Nginx and PHP-FPM instead of apache for your AWS Beanstalk PHP App, well good for you!

This is a sample deployment with all of the .ebextensions to do so without having to make a custom AMI

What's accomplished here?

  1. Install nginx
  2. Stop apache and keep it from starting up again
  3. Make sure nginx and phpfpm start on reboot
  4. Make sure environment variables are updated on both a configuration and app deployment

How do I use it?

You can pull down this repo, zip up the contents, making sure you include the .ebextensions directory and deploy to your beanlstalk application. Once the deployment has finished you should be able to hit your beanstalk ip and get the hello world response.

Environment variables

Environment variables are set in the /etc/nginx/fastcgi_params_env file and you can include them in your server block. You'll see an example of this in the default. This file will get updated with any environment variable changes on both application and config deployments.

You can get environment variables in your php script with:

getenv('ENV_VARIABLE_NAME)

Nginx and PHPFPM config changes

You'll find the base config files within the .ebextensions directory. You can modify as needed and they will take effect when you deploy.

Why not create a custom AMI?

You can go this route, but then in a few months when you want to use the latest version of amazon linux you'll need to completely recreate your custom AMI all over again. That gets to be a pain over the course of time. So, why not just stick with the default AMI and handle all of your setup via .ebextensions?

I don't understand what's happening when I deploy?

Take a look at the .ebextensions/01_setup.config file. I've commented each step. Things in the "commands" section happen early in the deployment process before your actual code is setup.

Why not just get rid of apache completely?

This ends up being a complete pain. Beanstalk has many commands baked in with apache, so it just gets troublesome to get them all. So instead we keep apache in place but just tell Elasticbeanstalk to disable it.

beanstalk-nginx-php-fpm's People

Contributors

gr8karma avatar ricktbaker avatar

Watchers

 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.