Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
wwt142 committed Jun 14, 2018
1 parent 52db9d2 commit 1c484d7
Show file tree
Hide file tree
Showing 14 changed files with 1,194 additions and 96 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)

/.idea
/.idea

/logs/nginx/

/code/

/etc/nginx/vhosts/
8 changes: 8 additions & 0 deletions code/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

$redis = new Redis();

$client = $redis->connect('redis', '6379');

var_dump($client);

43 changes: 29 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
version: '3'
services:

web:
container_name: web
build: ./web
ports:
- "80:80"
- "443:443"
- "6379:6379"
volumes:
- ./logs:/var/log
- ./web/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./web/nginx/sites-enabled/:/etc/nginx/sites-enabled
volumes:
data-volume:
web:
image: nginx:alpine
volumes:
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
- "./etc/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "./web:/var/www/html"
- "./code:/var/www/code"
- "./logs/nginx:/etc/nginx/logs"
- "./etc/nginx/vhosts:/etc/nginx/vhosts"
ports:
- "80:80"
- "443:443"
command: /bin/sh -c "nginx -g 'daemon off;'"
restart: always
depends_on:
- php
- redis
php:
build: ./php
restart: always
volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./code:/var/www/code"
- "./web:/var/www/html"
redis:
build: ./redis
ports:
- "6379:6379"
restart: always
20 changes: 20 additions & 0 deletions etc/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;

index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/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;
}
}
54 changes: 54 additions & 0 deletions etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#user nobody;
worker_processes auto;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;
sendfile off;
#tcp_nopush on;
client_max_body_size 100m;
#keepalive_timeout 0;
keepalive_timeout 65;
# 开启gzip
gzip on;
# # 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
gzip_min_length 1k;
# # gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明
gzip_comp_level 2;
# # 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
# # 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_vary on;
# # 禁用IE 6 gzip
gzip_disable "MSIE [1-6]\.";
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

include ./vhosts/*.conf;
}
12 changes: 12 additions & 0 deletions etc/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; PHP Configuration

;[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

; Error handling
;display_errors = Off

; Xdebug
; See https://xdebug.org/docs/all_settings
4 changes: 4 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM php:7.0.30-fpm
RUN pecl install redis-4.0.1 \
&& docker-php-ext-enable redis \
&& docker-php-ext-install mysqli && docker-php-ext-enable mysqli
6 changes: 6 additions & 0 deletions redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM redis:3.2-alpine

COPY conf/redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

EXPOSE 6379
Loading

0 comments on commit 1c484d7

Please sign in to comment.