-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05ed29d
Showing
17 changed files
with
4,401 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# dockerfiles-lnmp 说明 | ||
Docker搭建php5.6,php7.2,nginx1.12,redis4.0,mysql5.7,memcached1.5,swoole,一键搞定!本人第一次使用docker,开发中需要使用PHP5.6与PHP7.2两个版本,如有配置不对请指正。QQ:5552123 | ||
|
||
相关软件版本: | ||
- PHP 7.2 | ||
- PHP 5.6 | ||
- MySQL 5.7 (root账号:root;密码123456!,成员账号:admin;密码:adminadmin) | ||
- Nginx 1.12 | ||
- | ||
用到的PHP扩展 | ||
- redis,swoole,memcached,GD,curl... | ||
|
||
#### 目录说明 | ||
目录 | 说明 | ||
---|--- | ||
--- data | 数据目录 | ||
--- --- www | web目录 | ||
--- --- db | 数据库目录 | ||
--- --- logs | 日志目录 | ||
--- dockerfiles | docker镜像配置 | ||
--- --- mysql | mysql配置及安装文件 | ||
--- --- nginx | nginx配置及安装文件 | ||
--- --- php56 | php5.6配置及安装文件 | ||
--- --- php72 | php7.2配置及安装文件 | ||
--- --- docker-composer.yml | docker配置执行文件 | ||
|
||
## 使用 | ||
|
||
#### 下载dockerfiles-lnmp | ||
直接clone: | ||
``` | ||
git clone [email protected]:duzhenxun/dockerfiles-lnmp.git | ||
chmod -R 777 ./dockerfiles-lnmp/data/logs | ||
cd dockerfiles-lnmp/dockerfiles | ||
``` | ||
进行docker-compose.yml所在文件夹执行命令: | ||
``` | ||
docker-compose up | ||
``` | ||
## dokcer 常用命令 | ||
|
||
所有容器将后台运行: | ||
``` | ||
docker-compose up -d | ||
``` | ||
可以这样关闭容器并删除服务: | ||
``` | ||
docker-compose down | ||
``` | ||
下载镜像 | ||
``` | ||
docker pull nginx | ||
``` | ||
后台启动容器 | ||
``` | ||
docker run -p 8080:80 -d nginx | ||
``` | ||
进入进入容器 | ||
``` | ||
docker exec -it d6d933711bc2 /bin/bash | ||
``` | ||
进入容器 | ||
``` | ||
docker-compose exec [images] bash # 例如 docker-compose exec php-fpm bash | ||
``` | ||
退出,保持运行 | ||
``` | ||
ctrl+p ctrl+q | ||
``` | ||
查看运行的容器 | ||
``` | ||
docker ps | ||
``` | ||
查看所有容器 | ||
``` | ||
docker ps -a | ||
``` | ||
|
||
停指定容器 | ||
``` | ||
docker stop d6d933711bc2 | ||
``` | ||
删指定容器 | ||
``` | ||
docker rm d6d933711bc2 | ||
``` | ||
停止所有容器 | ||
``` | ||
docker stop $(docker ps -q) | ||
``` | ||
删除所有容器 | ||
``` | ||
docker rm $(docker ps -a -q) | ||
``` | ||
|
||
查看所有镜像 | ||
``` | ||
docker image | ||
``` | ||
删镜像 | ||
``` | ||
docker rmi c82521676580 | ||
``` | ||
查看占用空间 | ||
``` | ||
docker system df | ||
``` | ||
|
||
使用显示所有容器IP地址 | ||
``` | ||
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq) | ||
``` | ||
重命名一个容器 | ||
``` | ||
docker rename old_name new_name | ||
``` | ||
进入容器 | ||
``` | ||
docker-compose exec [images] bash # 例如 docker-compose exec php-fpm bash | ||
``` | ||
创建并启动一个容器,在run后面加上-d参数,则会创建一个守护式容器在后台运行 | ||
``` | ||
docker run | ||
``` | ||
查看已经创建的容器 | ||
|
||
``` | ||
docker ps -a | ||
``` | ||
查看已经启动的容器 | ||
|
||
``` | ||
docker ps -s | ||
``` | ||
启动容器名为con_name的容器 | ||
``` | ||
docker start con_name | ||
``` | ||
停止容器名为con_name的容器 | ||
``` | ||
docker stop con_name | ||
``` | ||
删除容器名为con_name的容器 | ||
``` | ||
docker rm con_name | ||
``` | ||
重命名一个容器 | ||
``` | ||
docker rename old_name new_name | ||
``` | ||
将终端附着到正在运行的容器名为con_name的容器的终端上面去,前提是创建该容器时指定了相应的sh | ||
``` | ||
docker attach con_name | ||
``` | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
html |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
phpinfo(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
version: '1.0' | ||
services: | ||
php56-fpm: | ||
build: ./php56/ | ||
ports: | ||
- "9056:9000" | ||
links: | ||
- mysql57-db:mysql57-db | ||
volumes: | ||
- ../data/www:/data/www:rw | ||
- ../data/logs/php56-fpm:/var/log/php-fpm:rw | ||
- ./php56/php.ini:/usr/local/etc/php/php.ini:ro # 当前php配置文件;可以拷贝修改php-dev.ini为想要的配置 | ||
- ./php56/php-fpm.conf:/usr/local/etc/php-fpm.conf:ro | ||
|
||
restart: always | ||
command: php-fpm | ||
|
||
php72-fpm: | ||
build: ./php72/ | ||
ports: | ||
- "9072:9000" | ||
links: | ||
- mysql57-db:mysql57-db | ||
volumes: | ||
- ../data/www:/data/www:rw | ||
- ../data/logs/php72-fpm:/var/log/php-fpm:rw | ||
- ./php72/php.ini:/usr/local/etc/php/php.ini:ro # 当前php配置文件;可以拷贝修改php-dev.ini为想要的配置 | ||
- ./php72/php-fpm.conf:/usr/local/etc/php-fpm.conf:ro | ||
|
||
restart: always | ||
command: php-fpm | ||
|
||
nginx: | ||
build: ./nginx | ||
depends_on: | ||
- php56-fpm | ||
- php72-fpm | ||
links: | ||
- php56-fpm:php56-fpm | ||
- php72-fpm:php72-fpm | ||
volumes: | ||
- ../data/www:/data/www:rw | ||
- ./nginx/conf.d:/etc/nginx/conf.d:ro | ||
- ./nginx/certs/:/etc/nginx/certs | ||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro | ||
- ../data/logs/nginx:/var/log/nginx | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
restart: always | ||
command: nginx -g 'daemon off;' | ||
|
||
mysql57-db: | ||
build: ./mysql57 | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- ../data/db/mysql57:/var/lib/mysql:rw | ||
- ../data/logs/mysql57:/var/lib/mysql-logs:rw | ||
- ./mysql57/conf.d:/etc/mysql/conf.d:ro | ||
environment: | ||
MYSQL_ROOT_PASSWORD: 123456! # root密码 自行修改 | ||
MYSQL_DATABASE: zx # 数据库名 | ||
MYSQL_USER: admin | ||
MYSQL_PASSWORD: adminadmin | ||
restart: always | ||
command: "--character-set-server=utf8" | ||
|
||
networks: | ||
front-tier: | ||
driver: bridge | ||
back-tier: | ||
driver: bridge |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM mysql:5.7 | ||
MAINTAINER duzhenxun "[email protected]" | ||
# set timezome | ||
ENV TZ=Asia/Shanghai | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[client] | ||
port=3306 | ||
|
||
[mysql] | ||
|
||
[mysqld] | ||
default-storage-engine=INNODB | ||
skip-host-cache | ||
skip-name-resolve | ||
query_cache_size = 64M | ||
max_allowed_packet = 4M | ||
|
||
server_id=1 | ||
log-bin=mysql-bin | ||
|
||
slow_query_log = 1 | ||
slow_query_log_file =/var/lib/mysql-logs/slow.log | ||
long_query_time = 1 | ||
log-queries-not-using-indexes | ||
max_connections = 1024 | ||
back_log = 128 | ||
wait_timeout = 100 | ||
interactive_timeout = 200 | ||
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM nginx:1.12 | ||
MAINTAINER duzhenxun "[email protected]" | ||
# set timezome | ||
ENV TZ=Asia/Shanghai | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen 80; | ||
server_name test.php56; | ||
|
||
root /data/www/test; | ||
index index.php index.html index.htm; | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location ~ \.php { | ||
include fastcgi_params; | ||
fastcgi_pass php56-fpm:9056; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME /data/www/$fastcgi_script_name; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen 80; | ||
server_name test.php72; | ||
|
||
root /data/www/test; | ||
index index.php index.html index.htm; | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location ~ \.php { | ||
include fastcgi_params; | ||
fastcgi_pass php72-fpm:9072; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME /data/www/$fastcgi_script_name; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
user www-data; | ||
pid /run/nginx.pid; | ||
|
||
worker_processes 4; | ||
worker_cpu_affinity 01 10 01 10; | ||
worker_rlimit_nofile 51200; | ||
|
||
events { | ||
worker_connections 10240; | ||
multi_accept on; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
charset UTF-8; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
server_tokens off; | ||
keepalive_timeout 10; | ||
|
||
send_timeout 10; | ||
server_name_in_redirect off; | ||
server_names_hash_bucket_size 64; | ||
types_hash_max_size 2048; | ||
client_header_timeout 10; | ||
client_header_buffer_size 32k; | ||
large_client_header_buffers 4 32k; | ||
client_max_body_size 100m; | ||
client_body_timeout 10; | ||
client_body_buffer_size 10m; | ||
reset_timedout_connection on; | ||
|
||
|
||
# log setting | ||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
# access_log /var/log/nginx/access.log main; | ||
access_log off; | ||
error_log /var/log/nginx/error.log warn; | ||
|
||
|
||
fastcgi_buffers 256 16k; | ||
fastcgi_buffer_size 128k; | ||
fastcgi_connect_timeout 3s; | ||
fastcgi_send_timeout 120s; | ||
fastcgi_read_timeout 120s; | ||
fastcgi_busy_buffers_size 256k; | ||
fastcgi_temp_file_write_size 256k; | ||
fastcgi_hide_header X-Powered-By; | ||
|
||
|
||
# Gzip Compression | ||
gzip on; | ||
gzip_disable "MSIE [1-6]\.(?!.*SV1)"; | ||
gzip_proxied any; | ||
gzip_min_length 1000; | ||
gzip_comp_level 6; | ||
gzip_buffers 16 8k; | ||
gzip_http_version 1.0; | ||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
gzip_vary on; | ||
|
||
|
||
open_file_cache max=10000 inactive=20s; | ||
open_file_cache_valid 30s; | ||
open_file_cache_min_uses 2; | ||
open_file_cache_errors on; | ||
|
||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
Oops, something went wrong.