Giter VIP home page Giter VIP logo

php5-fpm-nginx's Introduction

Introduction

This is Dockerfile to build a container for php5, nginx and php-fpm alone with some commonly used php5 exentsions. Many thanks to ngineered for their work on nginx-php-fpm

Usage

  • Pull the image from the docker hub:
docker pull yoanisgil/php5-fpm-nginx:latest
  • Launch your application within the container provided by the pulled image:
docker run -p 8000:80 --name appname -v /app/root:/srv/www -v /path/to/nginx/log:/var/log/nginx yoanisgil/php5-fpm-nginx 

This will expose port 8000 on the host already mapped to port 80 on the container. "/app/root" is your application root, which is usally where your index.php lives. We did not assume any particular application structure, so as long as the URL path is a valid one to your application pages should be properly served, as well as static resources (See the note on static files)

Nginx configuration

Upon launch the startup script will setup as many nginx workers as available in the host. For further details refer to file nginx.conf within this repository.

It is worth saying that the default nginx/php/fpm configuration is not production ready and I strongly encorauge you to optimize it.

Note on static files.

Nginx has been configured such that static files won't bre processed by php-fpm, nor log records will be created:

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           5d;
}

Silex example

  • Start by installing on a directory of your choice:
- mkdir silex-app
- composer require silex/silex:~1.2
  • With the editor of your choice, add the infamous hello world route to your index.php file
<?php
require_once __DIR__.'/../vendor/autoload.php'; 

$app = new Silex\Application(); 

$app->get('/hello/{name}', function($name) use($app) { 
        return 'Hello '.$app->escape($name); 
}); 

$app->run();
  • Launch the container :
docker run -p 8000:80 --name silex -v $(pwd):/srv/www -v /tmp:/var/log/nginx yoanisgil/php5-fpm-nginx

Wordpress example

  • Get a recent wordpress version (this image was tested with wordpress 4.2.2) from https://wordpress.org/download/

  • Extract file contents anywhere in your filesystem and cd (change dir) to the resulting directory.

  • Launch the container:

docker run -p 8000:80 --name silex -v $(pwd):/srv/www -v /tmp:/var/log/nginx yoanisgil/php5-fpm-nginx

Your wordpress instance is now accesible on http://localhost:8000

A note on OSX

If you are running docker on OSX then you need to run boot2docker ip to figure out which URL to enter in your browser. Also since dockers on OSX actually run within a VirtualBox VM you need to be aware of how volumes work see more here

List of preinstalled php extension.

  • mysql
  • imap
  • mcrypt
  • curl
  • gd
  • pgsql
  • sqlite
  • json
  • redis
  • memcache

php5-fpm-nginx's People

Contributors

yoanisgil avatar zeuben 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.