Skip to content

Instantly share code, notes, and snippets.

@mrryanjohnston
Created February 23, 2014 18:50
Show Gist options
  • Save mrryanjohnston/9175499 to your computer and use it in GitHub Desktop.
Save mrryanjohnston/9175499 to your computer and use it in GitHub Desktop.
nginx with php5-fpm on Ubuntu 13.10 Dockerfile
# Change this file to suit your needs.
# This config is taken and slightly modified from the F3 website
# (http://fatfreeframework.com/routing-engine#sample-nginx-configuration)
server {
server_name localhost;
root /var/www/html;
location / {
index index.php index.html index.htm;
try_files $uri /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
FROM ubuntu:13.10
RUN apt-get update
# nginx
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install nginx
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# php5-fpm
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install php5-fpm
# One of the last things should be adding a config file.
# This will allow the image to be rebuilt faster upon config change.
ADD default.conf /etc/nginx/sites-enabled/default
EXPOSE 80
CMD service php5-fpm start && service nginx start
# Save the two files in a directory together, cd to it,
# then run:
sudo docker build -t ubuntu-nginx .
# where ubuntu-nginx is the name you want the image to have
# Next (and last), run a container from that image:
sudo docker run -v /home/yourusername/my_awesome_php_project:/var/www -p 80:80 -name my_awesome_php_project -d ubuntu-nginx
# Now you have a nifty little dev environment to write your php application!