docker安装KodExplorer

一、创建基于某个系统镜像的docker容器(centos6.9)

docker rm -f `docker ps -a -q`    还原环境
docker run -it --name kodexplorer centos:6.9 /bin/bash  创建docker容器
docker images    查看所有镜像
docker image rm kodexplorer:v1  删除已有镜像

二、安装nginx和php安装包

劫持教师机ip:
echo  '192.168.12.201  mirrors.aliyun.com' >>/etc/hosts
修改yum源:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
下载包组件:
yum install nginx php-fpm -y
yum install php-gd php-mbstring.x86_64 -y

三、配置nginx和php

grep -Ev '^$|#' /etc/nginx/nginx.conf.default  >/etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
            root   /code;
            index  index.php index.html index.htm;
        location / {
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /code$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
[root@c7e033a2dc68 /]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

vi /etc/php-fpm.d/www.conf
39 user = nginx
40 ; RPM: Keep a group allowed to write in log dir.
41 group = nginx

[root@c7e033a2dc68 /]# find / -name "nginx"
[root@c7e033a2dc68 /]# find / -name "php-fpm"

vi   start.sh
/etc/init.d/nginx   restart
/etc/init.d/php-fpm  restart
tail -f /var/log/nginx/access.log
mkdir /code

四、下载KodExplorer安装包并cp到docker里,赋权限为nginx

cd /code
wget http://192.168.12.201/docker_image/kodexplorer4.40.zip
unzip  kodexplorer4.40.zip
docker container cp . c7e033a2dc68:/code
docker start c7e033a2dc68
docker exec -it c7e033a2dc68  /bin/bash
[root@c7e033a2dc68 /]# cd /code/
[root@c7e033a2dc68 code]# chown -R nginx.nginx .
[root@c7e033a2dc68 code]# ll
total 13680
drwxr-xr-x 10 nginx nginx      115 Mar 21 06:31 app
-rwxr-xr-x  1 nginx nginx    91248 Mar 21 06:31 ChangeLog.md
drwxr-xr-x  3 nginx nginx       74 Mar 21 06:31 config
drwxr-xr-x  7 nginx nginx       72 Mar 21 06:31 data
-rwxr-xr-x  1 nginx nginx      118 Mar 21 06:31 index.php
-rwxr-xr-x  1 nginx nginx       22 Jul 23 04:20 info.php
-rwxr-xr-x  1 nginx nginx 13894810 May 23 07:49 kodexplorer4.40.zip
drwxr-xr-x 15 nginx nginx      218 Mar 21 06:31 plugins
-rwxr-xr-x  1 nginx nginx     7718 Mar 21 06:31 README.MD
drwxr-xr-x  6 nginx nginx       57 Mar 21 06:31 static

五、打包提交为一个镜像,并创建端口映射与启动服务让docker夯住。

[root@docker01 code]# docker commit c7e033a2dc68 kodexplorer:v1
sha256:9f2c439568158fbb2271d276f9aa843b89fdadb4ecaeac9b0ecd16aecaf03fd1
[root@docker01 code]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
kodexplorer           v1                  9f2c43956815        10 seconds ago      486MB
centos                6.9                 adf829198a7f        11 months ago       195MB
[root@docker01 code]# docker run -d -p 82:80 kodexplorer:v1 /bin/bash /start.sh
9b9da7fce6c5b832989cd2be099eacaa232c8f720009ee8b2bade46c452ee4d0
[root@docker01 code]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
c7e033a2dc68        centos:6.9          "/bin/bash"         33 minutes ago      Up 10 minutes                           kodexplorer

六、在浏览器端访问测试:ip:port/index.php

image.png
image.png

docker安装KodExplorer优化版

一、编写dockerfile

vim dockerfile
FROM centos:6.9
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo && \
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo && \
yum install nginx php-fpm php-gd php-mbstring.x86_64 -y &&\
yum clean all
ADD nginx.conf /etc/nginx/nginx.conf
ADD www.conf /etc/php-fpm.d/www.conf
WORKDIR kodexplorer.tar.gz /code
RUN chown -R nginx.nginx . &&\
init.sh /init.sh
EXPOSE 80
ENTRYPOINT ["/bin/bash","init.sh"]
vim init.sh
#!/bin/bash
/etc/init.d/nginx restart
/etc/init.d/php-fpm restart
tail -f /var/log/nginx/access.log

二、构建容器

docker build --network=host  -t centos6.9_kod:v2 .

三、端口映射

docker run -d -p 81:80 centos6.9_kod:v2 

四、测试

docker ps -a -l
浏览器输入:ip:81/index.php
image.png

你可能感兴趣的:(docker安装KodExplorer)