Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 69d97ab

Browse files
committed
Init source
1 parent 1114e12 commit 69d97ab

File tree

10 files changed

+165
-1
lines changed

10 files changed

+165
-1
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# php-docker-env
2-
Setup nginx, mysql & php env by docker
2+
Setup nginx, mysql, memcached & php env by docker

‎bin/down.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker rm -f $(docker ps -aq)

‎bin/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
docker-compose up -d;
3+
docker-compose ps;

‎docker-compose.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: '3'
2+
3+
services:
4+
nginx:
5+
container_name: nginx
6+
build:
7+
context: nginx
8+
image: nginx
9+
ports:
10+
- "8080:8080" # site1
11+
- "8081:8081" # site2
12+
volumes:
13+
- "./etc/nginx_conf:/etc/nginx/conf.d"
14+
- "./www:/www"
15+
- "./logs/www:/var/log/nginx"
16+
links:
17+
- mysql
18+
- php
19+
- memcached
20+
21+
php:
22+
container_name: php
23+
build:
24+
context: php
25+
volumes:
26+
- "./www:/www"
27+
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
28+
links:
29+
- memcached
30+
31+
mysql:
32+
container_name: mysql
33+
build:
34+
context: mysql
35+
environment:
36+
- MYSQL_ROOT_PASSWORD=root
37+
- MYSQL_DATABASE=root
38+
command: mysqld --sql-mode=""
39+
ports:
40+
- "3306:3306"
41+
volumes:
42+
- ./etc/dbScripts:/docker-entrypoint-initdb.d/
43+
44+
memcached:
45+
container_name: memcached
46+
image: memcached

‎etc/nginx_conf/site1.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
listen 8080;
3+
listen [::]:8080;
4+
server_name localhost;
5+
6+
index index.php index.html;
7+
error_log /var/log/nginx/error.log;
8+
access_log /var/log/nginx/access.log;
9+
root /www/site1;
10+
11+
location / {
12+
# try to serve file directly, fallback to index.php
13+
try_files $uri /index.php$is_args$args;
14+
}
15+
16+
location ~ ^/index\.php(/|$) {
17+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
18+
fastcgi_pass php:9000;
19+
include fastcgi_params;
20+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
21+
fastcgi_param DOCUMENT_ROOT $realpath_root;
22+
internal;
23+
}
24+
25+
location ~ \.php$ {
26+
return 404;
27+
}
28+
}

‎etc/nginx_conf/site2.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
listen 8081;
3+
listen [::]:8081;
4+
server_name localhost;
5+
6+
index index.php index.html;
7+
error_log /var/log/nginx/error.log;
8+
access_log /var/log/nginx/access.log;
9+
root /www/site2/;
10+
11+
location / {
12+
# try to serve file directly, fallback to index.php
13+
try_files $uri /index.php$is_args$args;
14+
}
15+
16+
location ~ ^/index\.php(/|$) {
17+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
18+
fastcgi_pass php:9000;
19+
include fastcgi_params;
20+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
21+
fastcgi_param DOCUMENT_ROOT $realpath_root;
22+
internal;
23+
}
24+
25+
location ~ \.php$ {
26+
return 404;
27+
}
28+
}

‎etc/php/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
zend_extension=xdebug.so
2+
[xdebug]
3+
xdebug.remote_enable=1

‎mysql/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mysql:5.7.23

‎nginx/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM nginx:latest
2+
3+
WORKDIR /www
4+
5+
RUN apt-get update
6+
RUN apt-get install vim

‎php/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM php:7.1-fpm
2+
3+
4+
WORKDIR /root
5+
6+
RUN apt-get update --fix-missing && apt-get install -y \
7+
vim \
8+
libmemcached-dev \
9+
zlib1g-dev \
10+
libmcrypt-dev \
11+
libjpeg-dev \
12+
libpng-dev \
13+
libicu-dev \
14+
libcurl3-dev \
15+
libxml2-dev \
16+
libc-client-dev \
17+
libkrb5-dev
18+
19+
RUN docker-php-ext-configure intl
20+
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
21+
22+
# Addition
23+
RUN docker-php-ext-install pdo pdo_mysql zip mbstring gd intl curl xml imap mysqli
24+
25+
# Install the php memcached extension
26+
RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \
27+
&& mkdir -p memcached \
28+
&& tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \
29+
&& ( \
30+
cd memcached \
31+
&& phpize \
32+
&& ./configure \
33+
&& make -j$(nproc) \
34+
&& make install \
35+
) \
36+
&& rm -r memcached \
37+
&& rm /tmp/memcached.tar.gz \
38+
&& docker-php-ext-enable memcached
39+
40+
# Xdebug
41+
RUN curl -L http://xdebug.org/files/xdebug-2.5.5.tgz > xdebug-2.5.5.tgz \
42+
&& tar -xf xdebug-2.5.5.tgz \
43+
&& cd xdebug-2.5.5 \
44+
&& phpize \
45+
&& ./configure \
46+
&& make && make install

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /