Skip to content

Instantly share code, notes, and snippets.

@taragurung
Last active May 10, 2018 05:15
Show Gist options
  • Save taragurung/a37f4d588c0e374404cbe417906e5af2 to your computer and use it in GitHub Desktop.
Save taragurung/a37f4d588c0e374404cbe417906e5af2 to your computer and use it in GitHub Desktop.
PHP-fpm and nginx in docker container . A nginx webserver and php-fpm used running a sample index.php file and running inside docker container
version: "3.4"
services:
web:
image: nginx:latest
ports:
- "9080:80"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
php:
image: php:7-fpm
volumes:
- ./code:/code
//create a sample index.php and place it inside code directory
<?php
echo "this is a php file running in ngixn server inside docker container";
?>
server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment