docker搭建与typecho部署练习
目标:部署typecho博客系统
1 docker编排(dnmp(本示例使用github上的项目):docker编排,要点开按照文档一通操作)
github地址: https://github.com/yeszao/dnmp
如果没有git则先安装即可。拉取指定tag版代码,这里以v1.1-17.10.30 为例
代码语言:javascript复制git clone --branch [tags标签] [git远程仓库地址]
git clone --branch v2.0.5 git@github.com:yeszao/dnmp.git
2 环境安装(mac不需要这一步,直接安装docker-desktop,仅需参考如下第4点即可)
安装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 mac环境怎么体验?
下载docker desktop(如下链接)并安装即可:ps:自动支持docker engine 与 docker-compose(如果没找到命令,就关闭terminal重新打开就有了)
https://docs.docker.com/desktop/mac/install/
5 typecho 代码拉取(最好拉取稳定版本)
代码语言:javascript复制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
③:注意dnmp docker-compose默认使用的mysql版本比较高,可以自行降低mysql版本,typecho不支持8.0)
http://docs.typecho.org/faq
7 nginx配置目录到typecho对应目录
代码语言:javascript复制 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