简介

Typecho 的前身是一个款叫做Magike的开源博客程序,是由 Typecho 项目的发起人70开发的。Typecho 团队的最初形成,是在第一次 wordcamp china的活动上,后来有更多志同道合的成员加入了这个充满朝气的项目,才有了现在的 Typecho。 详见 百度百科

部署

  1. 下载源码( Typecho官网 )【注意:需自行解决环境架构问题
  2. 上传源码到服务器(这里以 nginx/html 为例)

    [root@local] tar -xvf typcho.xx.tar.gz   // 解压源码文件,文件名以实际为准
    [root@local] mkdir /usr/local/nginx/html/typecho  // 在 nginx/html 下创建目录 typecho
    [root@local] mv typecho-x-x/* /usr/local/nginx/html/typecho  // 将解压的typecho目录下的全部内容 移动到 nginx/html/typecho 下
    [root@local] chown -Rf www:www /usr/local/nginx/html/typecho // 变更所属组,否则会出现无法访问现象
    
  3. Typecho 配置文件 config.inc.php

    /** 开启HTTPS ,这行没有,需要自行添加 */
    define('__TYPECHO_SECURE__',true);
    /** 程序初始化 */
    Typecho_Common::init();
    
    /** 定义数据库参数 */
    $db = new Typecho_Db('Pdo_Mysql', 'typecho_');
    $db->addServer(array (
    'host' => 'localhost',    // 地址
    'user' => 'typecho',      //访问数据库用户
    'password' => 'typecho888',  // 密码
    'charset' => 'utf8',
    'port' => '3306',         // 数据库端口
    'database' => 'typecho',   // 库名
    ), Typecho_Db::READ | Typecho_Db::WRITE);
  4. Typecho 虚拟机配置 typecho.conf,nginx 注释用 #

    server {
       listen       443  ssl;
       server_name  deyun.fun;
       charset utf-8;
       #access_log  logs/host.access.log  main;
       ssl_certificate       1_deyun.fun_bundle.crt;  # SSL 证书相关,需要写全路径,按需修改
       ssl_certificate_key   2_deyun.fun.key;    # SSL 证书相关,需要写全路径,按需修改
       ssl_session_timeout 5m;
       ssl_protocols  TLSv1.2 TLSv1.3;
       add_header Strict-Transport-Security "max-age=63072000" always;
       ssl_ciphers AES128+EECDH:AES128+EDH;
       ssl_prefer_server_ciphers on;
       location / {
           root   html/typecho;  # typecho 目录
           #下列是重写配置
           index  index.html index.htm index.php;
    
           if (-f $request_filename/index.html){
               rewrite (.*) $1/index.html break;
           }
           if (-f $request_filename/index.php){
               rewrite (.*) $1/index.php;
           }
           if (!-f $request_filename){
               rewrite (.*) /index.php;
           }
    
       }
    
       # php 解析配置
       location ~ \.php$ {
              root   html/typecho;
              fastcgi_pass    unix:/var/run/php-fpm.sock;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_index   index.php;
              include         fastcgi_params;
       }
    }
    server {      // 80 转 443 端口
     listen      80;
     server_name  deyun.fun;
     return 301 https://$host$request_uri;
    }
  5. 优化 SSL 配置

    // 将typecho 目录下所有 `http://` 的链接替换为 `https://`
     [root@deyun typecho] sed -i "s/http:\/\//htts:\/\//g" `grep "http:\/\/" -rl ./`
    
    // 修改主题目录下的 `comments.php` 配置文件
     [root@deyun typecho] find ./ -name "comments.php"  // 不清楚文件目录,可用用这个命令查找
     [root@deyun typecho] vim usr/themes/GreenGrapes/comments.php
     
    // 将数据库中记录的 `http://` 替换为 `https://`,网址请替换成自己的
     [root@deyun typecho]# mysql -u root -p
     Enter password:
     MariaDB [(none)]> use typecho;
     MariaDB [typecho]> UPDATE `typecho_contents` SET `text` = replace (`text`, 'http://deyun.fun', 'https://deyun.fun');
    
    // 如果按以上步骤全部配置完成,浏览器还提示不安全
    // 请按 F12 进行资源加载检查,大部分都是媒体资源链接导致
    // 替换那些 http 链接的媒体资源,再访问网站就不会提示不安全了
    // 现在博主虽然替换完成,但是 mysll检测还是 有个“PCI DSS 不合规”,现在还没找到有效解决办法;
    // 在使用百度云CDN时候,无法做到合规,切到 又拍云 就可以;

又拍云(CDN)的时候
A+.webp

百度云(CDN)的时候

n.webp

美化、技巧

  • 引用视频
!!!
<h2 style="text-align:center">视 频 参 考,高 清 视 频 请 亲 前 往 B站 观 看</h2>
<embed type="video/webm" src="video_url" height="600" width="740" allowfullscreen="true"></embed>
!!!
  • 插入 html 代码
!!!
html 代码块
!!!
// html 代码部分
// html 代码插入在主题 post.php 文件中;
// 一般插入到 “<?php $this->content(); ?>” 或 “<?php parseContent($this); ?>” 代码的下一行;

<!-- 赞赏部分 begin -->
<div class="entry-shang text-center">
    <p>「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」</p>
    <button class="zs show-zs btn btn-bred">赞赏</button>
</div>
<div class="zs-modal-bg"></div>
<div class="zs-modal-box">
    <div class="zs-modal-head">
        <button type="button" class="close">×</button>
        <p class="author">
            <a href="https://www.zuozuovera.com">
                <img src="https://secure.gravatar.com/avatar/29016c0d931044b1660a872ced6c06ef?s=80&r=G&d=mm"/>
            薇拉航线</a>
        </p>
        <p class="tip"><i></i><span> (๑>ڡ<)☆谢谢老板~</span></p>
    </div>
    <div class="zs-modal-body">
        <div class="zs-modal-btns">
            <button class="btn btn-blink" data-num="2">2元</button>
            <button class="btn btn-blink" data-num="5">5元</button>
            <button class="btn btn-blink" data-num="10">10元</button>
            <button class="btn btn-blink" data-num="50">50元</button>
            <button class="btn btn-blink" data-num="100">100元</button>
            <button class="btn btn-blink" data-num="any">任意金额</button>
        </div>
        <div class="zs-modal-pay">
            <button class="btn btn-bred" id="pay-text">2元</button>
            <p>使用<span id="pay-type">微信</span>扫描二维码完成支付</p>
            <img src="./images/alipay-2.jpg" id="pay-image"/>
        </div>
    </div>
    <div class="zs-modal-footer">
        <label style="float: left;width: 130px;">
            <input type="radio" name="zs-type" value="alipay" class="zs-type" checked="checked" style="float: left;">
            <span class="zs-alipay">
                <img src="./images/alipay-btn.png"/>
            </span>
        </label>
        <label style="float: left;width: 130px;">
            <input type="radio" name="zs-type" value="wechat" class="zs-type" style="float: left;">
            <span class="zs-wechat">
                <img src="./images/wechat-btn.png"/>
            </span>
        </label>
    </div>
</div>
<!-- 引用 js 代码,博主使用了绝对路径,用 ./ 下方式无法调用 -->
<script type="text/javascript" src="./js/jquery.min.js"></script> 
<script type="text/javascript" src="./js/zanshang.js"></script> 
<!-- 赞赏部分end -->

// js 部分

  1. 代码原用大神代码,不做修改;
  2. 由于大神挂在 GitHub 上,国内访问速度比较惊人,所以博主挂在了 百度盘:提取码 qkh1,需要自行下载;
  3. 将下载的 jquery.min.js 和 zanshang.js 丢到你主题目录下的js文件夹里去,然后根目录下的donate.css丢到和你的post.php同级的目录下,注意文件权限问题;
  4. 一开始出问题的,请配合 F12 来修复问题;

     - 博主使用的分享代码(感谢 [PHP自学网][9])
    
    <div>分享到:</div> 
    <div onclick="shareTo('qzone')">     
     <img src="https://zixuephp.net/static/images/qqzoneshare.png" width="32"> 
    </div> 
    <div onclick="shareTo('qq')">     
     <img src="https://zixuephp.net/static/images/qqshare.png" width="32"> 
    </div> 
    <div onclick="shareTo('sina')">     
     <img src="https://zixuephp.net/static/images/sinaweiboshare.png" width="32"> 
    </div> 
    <div onclick="shareTo('wechat')">     
     <img src="https://zixuephp.net/static/images/wechatshare.png" width="32"> 
    </div>
    
    function shareTo(types){
     
     var title,imageUrl,url,description,keywords;
     
     //获取文章标题
     title = document.title;
     //获取当前网页url
     url = document.location.href;
     //获取网页描述
     description = document.querySelector('meta[name="description"]').getAttribute('content');
     //获取网页关键字
     keywords = document.querySelector('meta[name="keywords"]').getAttribute('content');
     //qq空间接口的传参
     if(types=='qzone'){
         window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+url+'&sharesource=qzone&title='+title+'&pics='+imageUrl+'&summary='+description);
     }
     //新浪微博接口的传参
     if(types=='sina'){
         window.open('http://service.weibo.com/share/share.php?url='+url+'&sharesource=weibo&title='+title+'&pic='+imageUrl+'&appkey=2706825840');
     }
     //qq好友接口的传参
     if(types == 'qq'){
         window.open('http://connect.qq.com/widget/shareqq/index.html?url='+url+'&sharesource=qzone&title='+title+'&pics='+imageUrl+'&summary='+description+'&desc='+keywords);
     }
     //生成二维码给微信扫描分享
     if(types == 'wechat'){
         //在线二维码生成只支持小批量调用,过多访问会限制403.
         // https://zixuephp.net/inc/qrcode_img.php接口参数:url:二维码内容,size:二维码图片大小值1-10
         window.open('https://zixuephp.net/inc/qrcode_img.php?url='+url);
     }
     
    }

备份


FAQ

  1. 上传附件失败:
    a. PHP 配置,默认是 2M,如果附件大于2M,请修改:upload_max_filesize = 2M
    b. Nginx 默认只允许上传 1M 附件,如果附件大于 1M 请在 http{} 内增加代码:client_max_body_size 5m;
  1. 链接在新窗口打开(全局设置)

    <base target="_blank" />

「 希望熬过一切,星光璀璨 」

流年小站,感谢有您的支持

「 道路坎坷,感谢有您 ---来自 anYun 的感谢 」

使用微信扫描二维码完成支付

2020-04-21
已阅:14676 人/次

 
 
 
分享是一种美德 x
打开微信,右上角的"+"选择"扫一扫"
使用“扫一扫”将博文分享至朋友圈吧

本文由 anYun 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。
我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=3oibnoh9lo6cs

还不快抢沙发

添加新评论

Myssl安全认证