Skip to content

Instantly share code, notes, and snippets.

@smahi
Forked from md5/00_README.md
Created September 29, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smahi/f93044caa9e7e79433f5996e611e793c to your computer and use it in GitHub Desktop.
Save smahi/f93044caa9e7e79433f5996e611e793c to your computer and use it in GitHub Desktop.
Demonstration Docker config for Wordpress on PHP-FPM behind Nginx

Proof of concept setup for Wordpress running under PHP-FPM with an Nginx frontend

Usage

Build a copy of this image:

git clone git://github.com/d9206eacb5a0ff5d6be0.git docker-nginx-fpm
cd docker-nginx-fpm
docker build -t nginx-fpm .

Launch an instance of wordpress:fpm just as you'd launch wordpress:

docker run -d --link some-mysql:mysql --name wordpress-fpm wordpress:fpm

Launch an instance of this image to front wordpress:fpm and serve static assets:

docker run -d --link wordpress-fpm:fpm --volumes-from wordpress-fpm -p 80:80 nginx-fpm
FROM nginx:1.7
COPY wordpress-fpm.conf /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass fpm:9000;
fastcgi_index index.php;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment