博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker安装Nginx1.11.10+php7+MySQL
阅读量:6992 次
发布时间:2019-06-27

本文共 3936 字,大约阅读时间需要 13 分钟。

Docker安装php-fpm

1.编辑Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FROM php:7.1.3-fpm
ADD sources.list /etc/apt/sources.list
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN apt-get update && apt-get install -y \<br>     vim \
        
libfreetype6-dev \
        
libjpeg62-turbo-dev \
        
libmcrypt-dev \
        
libpng12-dev \
    
libmagickwand-dev \
    
libmagickcore-dev \
    
imagemagick \
    
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
    
&& docker-php-ext-configure gd --with-freetype-dir=/usr/
include
/ --with-jpeg-dir=/usr/
include
/ \
    
&& docker-php-ext-install -j$(nproc) gd
RUN pecl install imagick-3.4.3 && docker-php-ext-enable imagick<br>RUN docker-php-ext-install pdo_mysql mysqli

2.同级目录下创建sources.list 使用163源

1
2
3
4
5
6
7
8
9
[root@git php7]# cat sources.list
deb http:
//mirrors.163.com/debian/ jessie main non-free contrib
deb http:
//mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http:
//mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http:
//mirrors.163.com/debian/ jessie main non-free contrib
deb-src http:
//mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http:
//mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http:
//mirrors.163.com/debian-security/ jessie/updates main non-free contrib
deb-src http:
//mirrors.163.com/debian-security/ jessie/updates main non-free contrib

3.构建本地镜像

1
docker build -t php:7.1.3-fpm-chao .

4.构建php-fpm容器

1
docker run --name some-php -v /srv/www:/
var
/www/html -v /srv/php/php.ini:/usr/local/etc/php/php.ini -d php:7.1.3-fpm-chao

5./srv/php/php.ini 目前仅设置了时区后期可以自己添加其他

1
2
######设置PHP的时区
date
.timezone = PRC

  

Docker安装Nginx

1.创建nginx的配置文件及映射路径

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
mkdir 
-p /srv/nginx
 
vim nginx.conf
 
 
user  nginx;
worker_processes  1;
 
error_log  
/
var
/log/nginx/error.log warn;
pid        /
var
/run/nginx.pid;
 
 
events {
    
worker_connections  1024;
}
 
 
http {
    
include       
/etc/nginx/mime.types;
    
default_type  application/octet-stream;
 
    
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;
 
    
sendfile        on;
    
#tcp_nopush     on;
 
    
keepalive_timeout  65;
 
    
#gzip  on;
 
    
include 
/etc/nginx/conf.d/*.conf;
}
 
mkdir 
conf.d && cd conf.d
vim 
default
.conf
server {
    
listen       80;
    
server_name  localhost;
 
    
#charset koi8-r;
    
#access_log  /
var
/log/nginx/log/host.access.log  main;
 
    
location / {
        
root   /
var
/www/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   /usr/share/nginx/html;
    
}
 
    
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
    
#
    
#location ~ \.php$ {
    
#    proxy_pass   http:
//127.0.0.1;
    
#}
 
    
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    
#
    
location ~ \.php$ {
        
root           /
var
/www/html;
        
fastcgi_pass   php-fpm:9000;
        
fastcgi_index  index.php;
        
fastcgi_param  SCRIPT_FILENAME  /
var
/www/html
$fastcgi_script_name
;
        
include        
fastcgi_params;
    
}
 
    
# deny access to .htaccess files, 
if 
Apache's document root
    
# concurs with nginx's one
    
#
    
#location ~ /\.ht {
    
#    deny  all;
    
#}
}

 

2.构建nginx容器

1
docker run --name some-nginx -p 80:80 --link some-php:php-fpm -v /etc/localtime:/etc/localtime:ro -v /srv/nginx/logs:/
var
/log/nginx -v /srv/nginx/nginx.conf:/etc/nginx/nginx.conf -v /srv/nginx/conf.d:/etc/nginx/conf.d --volumes-from some-php -d nginx

  

Docker安装MySQL

1
docker run --name some-mysql -v /etc/localtime:/etc/localtime:ro -v /etc/mysql/conf.d/mysql.cnf:/srv/mysql/mysql.cnf -v /etc/mysql/mysql.conf.d/mysqld.cnf:/srv/mysql/mysqld.cnf -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d mysql:5.7.17

  

转载于:https://www.cnblogs.com/huashengxue/p/9578523.html

你可能感兴趣的文章
我的友情链接
查看>>
电脑办公小技巧
查看>>
python2.7安装django报UnicodeEncodeError错误
查看>>
计算机应用专业的学生应该掌握的IT技能
查看>>
MyEclipse 编写java mail 时遇到 java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream...
查看>>
Mysqlslap性能测试
查看>>
SQLmap使用tamper绕过WAF防火墙过滤
查看>>
无法连接SQL SERVER 2008 的问题
查看>>
Hadoop常用命令
查看>>
CentOS环境中编译升级PHP至5.4版本记录
查看>>
Liferay 6.2 电子书 Liferay User interface Development
查看>>
mysql导入导出sql文件
查看>>
Core Text Tricks
查看>>
配置vsftp出现的一些问题
查看>>
开源 免费 java CMS - FreeCMS技术架构
查看>>
开源 免费 java CMS - FreeCMS1.4-信息管理
查看>>
git branch不显示本地分支的问题(二)
查看>>
Android拓展系列(2)--Git使用
查看>>
模拟银行叫号系统(c代码)
查看>>
Java并发编程系列-ReentrantLock原理分析
查看>>