«   2019/03   »
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Archives
Today
7
Total
1,202,724
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

Docker - nginx + php-fpm 본문

가상화/Docker

Docker - nginx + php-fpm

푸른바람 C/H 2019.01.01 22:54

Required

  • Docker (+docker-compose, docker-machine, docker-nightly)

file strunture

.
..
code/
	index.html
	index.php
code2/
	index.html
	index.php
docker-compose.yml
log.conf
site.conf
site.1.conf

docker-compose.yml

web:
    image: nginx:latest
    ports:
        - "80:80" # local port : docker port
    volumes:
        - ./code:/code # local dir : docker dir
        # - .:/usr/share/nginx/html[www] ubuntu default folder
        - ./site.conf:/etc/nginx/conf.d/site.conf # local nginx conf : docker nginx conf
    links:
        - php
php:
    image: php:7-fpm
    volumes:
        - ./code:/code # local dir : docker dir

nginx 만 설정했을 경우

version: '2'

services:
    web:
        image: nginx:latest
        ports:
            - "80:80"
        volumes:
            - ./code:/code
            - ./net.gag1.test:/net.gag1.test
            - ./site.conf:/etc/nginx/conf.d/default.conf
            - ./site.1.conf:/etc/nginx/conf.d/net.gag1.test.conf
        networks:
            - code-network
    php:
        image: php:fpm
        volumes:
            - ./code:/code
            - ./net.gag1.test:/net.gag1.test
            - ./log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
        networks:
            - code-network

networks:
    code-network:
        driver: bridge

Nginx Conf

server {
	index index.php index.html;
	server_name localhost domain.com;
	error_log  /var/log/nginx/error.log;
	access_log /var/log/nginx/access.log;
	root /code;

	location / {
		try_files $uri $uri/index.php;
	}

	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;
	}
}
server {
	index index.php index.html;
	server_name localhost test.domain.com;
	error_log  /var/log/nginx/error.log;
	access_log /var/log/nginx/access.log;
	root /code2

	location / {
		try_files $uri $uri/index.php;
	}

	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;
	}
}

hosts

127.0.0.1 domain.com test.domain.com

Run docker

./docker-compose up

Broswer Check

  • http://domain.com
  • http://test.domain.com



Dockerfile

Maybe wanted github.cm/chronon/ext.txt - List of docker-php-ext-install extension names

FROM php:7-fpm

RUN docker-php-ext-install bcmath
RUN docker-php-ext-install bz2
RUN docker-php-ext-install calendar
RUN docker-php-ext-install ctype
RUN docker-php-ext-install curl
RUN docker-php-ext-install dba
RUN docker-php-ext-install dom
RUN docker-php-ext-install enchant
RUN docker-php-ext-install exif
RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install filter
RUN docker-php-ext-install ftp
RUN docker-php-ext-install gd
RUN docker-php-ext-install gettext
RUN docker-php-ext-install gmp
RUN docker-php-ext-install hash
RUN docker-php-ext-install iconv
RUN docker-php-ext-install imap
RUN docker-php-ext-install interbase
RUN docker-php-ext-install intl
RUN docker-php-ext-install json
RUN docker-php-ext-install ldap
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install oci8
RUN docker-php-ext-install odbc
RUN docker-php-ext-install opcache
RUN docker-php-ext-install pcntl
RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_dblib
RUN docker-php-ext-install pdo_firebird
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install pdo_oci
RUN docker-php-ext-install pdo_odbc
RUN docker-php-ext-install pdo_pgsql
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install pgsql
RUN docker-php-ext-install phar
RUN docker-php-ext-install posix
RUN docker-php-ext-install pspell
RUN docker-php-ext-install readline
RUN docker-php-ext-install recode
RUN docker-php-ext-install reflection
RUN docker-php-ext-install session
RUN docker-php-ext-install shmop
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install snmp
RUN docker-php-ext-install soap
RUN docker-php-ext-install sockets
RUN docker-php-ext-install spl
RUN docker-php-ext-install standard
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-install tidy
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install wddx
RUN docker-php-ext-install xml
RUN docker-php-ext-install xmlreader
RUN docker-php-ext-install xmlrpc
RUN docker-php-ext-install xmlwriter
RUN docker-php-ext-install xsl
RUN docker-php-ext-install zip

'가상화 > Docker' 카테고리의 다른 글

Docker - nginx + php-fpm  (0) 2019.01.01
Docker for Linux 일반계정 사용  (0) 2017.08.01
Docker for CentOS7  (0) 2017.07.31
Docker for Ubuntu  (0) 2017.07.29
Docker 치트 시트  (0) 2016.08.10
Docker Kitematic / ToolBox  (0) 2016.08.10
0 Comments
댓글쓰기 폼