zl程序教程

您现在的位置是:首页 >  Java

当前栏目

docker应用练习

2023-02-18 16:46:00 时间

docker搭建与typecho部署练习

目标:部署typecho博客系统

1 git拉取代码(dnmp:docker编排,要点开按照文档一通操作)

github地址https://github.com/yeszao/dnmp

如果没有git则先安装即可。拉取指定tag版代码,这里以v1.1-17.10.30 为例

git clone --branch [tags标签] [git远程仓库地址]
git clone --branch v2.0.5 git@github.com:yeszao/dnmp.git          

2 环境安装(mac不需要这一步,直接docker-desktop)

安装docker引擎

https://docs.docker.com/engine/install/centos/#install-using-the-repository

3 安装docker-compose

https://docs.docker.com/compose/install/

https://docs.docker.com/compose/install/compose-plugin/#installing-compose-on-linux-systems

4 docker编排(注意mysql版本,dnmp这个比较高,typecho不支持8.0)

https://github.com/yeszao/dnmp

mac环境怎么体验?

mac环境无需上述两步,直接下载docker desktop即可:ps:自动支持docker engine 与 docker-compose

https://docs.docker.com/desktop/mac/install/

5 typecho 代码拉取(最好拉取稳定版本)

git clone --branch [tags标签] [git远程仓库地址]
git clone --branch v1.1-17.10.30-release git@github.com:typecho/typecho.git         

6 typecho常见问题

先预创建一个typecho库

数据库连接参数:host:mysql5 user:root pwd:123456

http://docs.typecho.org/faq

7 nginx配置目录到typecho对应目录

 server {
    listen       80;
    server_name  localhost;
    root   /www/build/;
    index  index.html index.htm index.php;

    access_log /dev/null;
    #access_log  /var/log/nginx/nginx.localhost.access.log  main;
    error_log  /var/log/nginx/nginx.localhost.error.log  warn;


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php$1 last;
    }


    location ~ .*\.php(\/.*)*$ {
        fastcgi_pass   php:9000;
        #include        fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

server {
    listen 443  default ssl http2;
    server_name  localhost;
    root   /www/build/;
    index  index.php index.html index.htm;

    access_log /dev/null;
    error_log  /var/log/nginx/nginx.localhost.error.log  warn;

    ssl_certificate /ssl/localhost/localhost.crt;
    ssl_certificate_key /ssl/localhost/localhost.key;

    
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php$1 last;
    }
    location ~ .*\.php(\/.*)*$ {
        fastcgi_pass   php:9000;
        #include        fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

8 开启你的博客之旅(我直接用的ip访问)

9 相关参考git仓库

typecho:

https://github.com/typecho/typecho

dnmp:

https://github.com/yeszao/dnmp