Skip to content

Commit

Permalink
Switch to Nginx and PHP-FPM 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Apr 2, 2015
1 parent 328a5e6 commit 035fdc7
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 60 deletions.
35 changes: 10 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
FROM ubuntu:14.10
FROM ubuntu:14.04

MAINTAINER outer/edge <hello@outeredgeuk.com>

ENV DEBIAN_FRONTEND noninteractive
ENV HOME /root
COPY build.sh /build.sh
RUN /build.sh

# Install Default Packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl nano wget software-properties-common \
ruby nodejs-legacy npm git-core apache2 libapache2-mod-php5 \
php5-cli php5-mysql php5-sqlite php5-curl php5-intl && \
apt-get clean && \
rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/*
COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx-default /etc/nginx/conf.d/default
COPY php-fpm.conf /usr/local/etc/php-fpm.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install bower
RUN npm install -g bower && npm cache clean

# Setup apache
RUN a2enmod rewrite
ADD apache.conf /etc/apache2/sites-enabled/000-default.conf
ADD apache.sh /apache.sh
RUN chmod +x /apache.sh

# Cache
VOLUME ["/root/.composer"]
EXPOSE 80

WORKDIR /var/www

EXPOSE 80
CMD ["/apache.sh"]
CMD ["/usr/bin/supervisord"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 outer/edge
Copyright (c) 2015 outer/edge

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
edge-docker-php
===============
# edge-docker-php
Ubuntu 14.04 running Nginx 1.7 with Pagespeed and PHP 5.6

Base docker image for running PHP web applications.

Included packages
-----------------

* Apache 2.4
* PHP (mysql, sqlite, curl, intl)
* Ruby
* Node.js
* Git

#### Package managers

* Composer
* Rubygems
* Npm
* Bower
## Adding PHP extensions
11 changes: 0 additions & 11 deletions apache.conf

This file was deleted.

4 changes: 0 additions & 4 deletions apache.sh

This file was deleted.

71 changes: 71 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
set -e

NGINX_VERSION=1.7.10
NPS_VERSION=1.9.32.3
PHP_VERSION=5.6.7

DEBIAN_FRONTEND=noninteractive

# build apt cache
apt-get update

# install basic tools
apt-get install -y --no-install-recommends build-essential curl nano wget git-core ca-certificates supervisor

# download ngx_pagespeed
apt-get install -y --no-install-recommends zlib1g-dev libpcre3-dev libssl-dev
mkdir /tmp/ngx_pagespeed
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.tar.gz -O - | tar -zxf - --strip=1 -C /tmp/ngx_pagespeed
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz -O - | tar -zxf - -C /tmp/ngx_pagespeed

# download and install nginx
mkdir /tmp/nginx
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -O - | tar -zxf - -C /tmp/nginx --strip=1
cd /tmp/nginx
./configure \
--prefix=/etc/nginx/ \
--conf-path=/etc/nginx/nginx.conf \
--sbin-path=/usr/sbin/nginx \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-http_spdy_module \
--add-module=/tmp/ngx_pagespeed
make -j"$(nproc)"
make install
mkdir -p /etc/nginx/conf.d
mkdir -p -m 755 /var/cache/pagespeed
chown -R www-data:www-data /var/cache/pagespeed

# download and install php
apt-get install -y --no-install-recommends libcurl4-openssl-dev libreadline6-dev libmcrypt-dev libxml2-dev libpng-dev libicu-dev
mkdir /tmp/php
wget http://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror -O - | tar -jxf - -C /tmp/php --strip=1
cd /tmp/php
./configure \
--with-config-file-path="/usr/local/etc/php" \
--with-libdir=/lib/x86_64-linux-gnu \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--disable-cgi \
--enable-fpm \
--enable-intl \
--enable-mbstring \
--enable-mysqlnd \
--enable-opcache \
--enable-zip \
--with-curl \
--with-openssl \
--with-readline \
--with-pdo-mysql \
--with-mcrypt \
--with-gd=shared
make -j"$(nproc)"
make install

# cleanup
apt-get purge -y build-essential g++
apt-get autoremove -y
apt-get clean
rm -rf /tmp/* /var/lib/apt/lists/*
25 changes: 25 additions & 0 deletions nginx-default
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;
root /var/www/public/;

charset utf-8;

#https://developers.google.com/speed/pagespeed/module/configuration
#pagespeed on;

location / {
try_files $uri =404;

fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
include fastcgi.conf;
}

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }

# Deny .htaccess file access
location ~ /\.ht {
deny all;
}
}
27 changes: 27 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
worker_processes auto;
daemon off;
error_log stderr warn;

events {
worker_connections 1024;
}

http {
server_tokens off;
access_log off;

include mime.types;
default_type application/octet-stream;

keepalive_timeout 65;

gzip on;
gzip_vary on;

index index.php;

pagespeed off;
pagespeed FileCachePath /var/cache/pagespeed; # Use tmpfs for best results

include /etc/nginx/conf.d/*;
}
21 changes: 21 additions & 0 deletions php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[global]

daemonize = no
error_log = stderr

[www]

user = www-data
group = www-data

listen = 127.0.0.1:9000

pm = dynamic
pm.max_children = 20
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 5000

clear_env = no

catch_workers_output = yes
14 changes: 14 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[supervisord]
nodaemon=true

[program:nginx]
command=nginx
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

0 comments on commit 035fdc7

Please sign in to comment.