Last active
May 10, 2018 05:15
-
-
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
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
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 |
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
//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"; | |
?> |
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
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