Created
February 23, 2014 18:50
-
-
Save mrryanjohnston/9175499 to your computer and use it in GitHub Desktop.
nginx with php5-fpm on Ubuntu 13.10 Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sources I used to figure this stuff out (thanks!):
https://www.digitalocean.com/community/articles/docker-explained-how-to-containerize-and-use-nginx-as-a-proxy
https://github.com/eugeneware/docker-wordpress-nginx
http://failshell.io/docker/running-nginx-inside-a-docker-container/
http://fatfreeframework.com/routing-engine#sample-nginx-configuration
http://docs.docker.io/en/latest/reference/commandline/
https://help.ubuntu.com/community/Nginx