TypechoJoeTheme

运维茶馆

统计
登录
用户名
密码

typecho博客安装和使用

少延博主
2022-01-17
/
0 评论
/
252 阅读
/
230 个字
/
百度已收录
01/17
本文最后更新于2022年01月26日,已超过111天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

前言

下载typecho正式版
注意:要下载正式版,bug少。后面安装、启用主题和插件,都需要注意是否兼容。掌柜就试过由于启用了低版本的插件,导致访问所有页面,包括后台都变成空白了,都不知道怎么解决。
typecho需要nginx、mysql、php这3套件。这里mysql使用docker起。nginx、php安装到系统上。

安装依赖套件

# 安装nginx
[root@tsh:~]$ yum install nginx -y
# 安装php7.3
[root@tsh:~]$ yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-pecl-swoole php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll

[root@tsh:~]$ echo "output_buffering =on" >> /etc/opt/remi/php73/php.ini
[root@tsh:~]$ systemctl start php73-php-fpm
[root@tsh:~]$ systemctl enable php73-php-fpm

# 安装mysql
[root@tsh:~]$ docker run --name mysql57 -v /data/db/mysql57:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=1234567890987 -p 3306:3306 -d mysql:5.7

# 创建一个mysql库给博客用:
[root@tsh:~]$ docker exec -it mysql57 bash
mysql> create database myblog;
Query OK, 1 row affected (0.00 sec)

mysql> 

添加nginx配置

[root@tsh:/etc/nginx/conf.d]$ cat myblog.conf 

server {
    listen 443 ssl; 
    server_name blog.opstea.com; 
    root /data/app/myblog;
    index index.php index.html index.htm;

    ssl_certificate ssl/1_blog.opstea.com_bundle.crt;
    ssl_certificate_key ssl/2_blog.opstea.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
    ssl_prefer_server_ciphers on;

    if ($host != 'blog.opstea.com')
    {
        rewrite ^/(.*)$ https://ww.opstea.com/$1 permanent;
    }


    location ~ .*\.php(\/.*)*$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        try_files $uri /index.php =404;
        #fastcgi_pass unix:/var/run/php7-fpm.sock;
        fastcgi_pass 127.0.0.1:9001;
        # Mitigate https://httpoxy.org/ vulnerabilities
        fastcgi_param HTTP_PROXY "";
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_connect_timeout 300;
        fastcgi_read_timeout 600;
        fastcgi_send_timeout 300;
        fastcgi_buffer_size 128k;
        fastcgi_buffers   4 128k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

        #unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^(.*)$ /index.php$1 last;
        break;
    }

    location / {
        index  index.php
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|ttf|ttc|otf|eot|woff)$ {
        try_files $uri /index.php?$query_string;
        expires max;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    location ~* \.(?:css|js)$ {
        try_files $uri /index.php?$query_string;
        expires 1y;
        add_header Cache-Control "public";
    }

    # deny access to . files, for security
    location ~* (?:^|/)\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    location ~* (?:\.(?:bak|config|db|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    access_log  /data/logs/blog.opstea.com.access.log;
    error_log  /data/logs/blog.opstea.com.error.log;
}

server {
    listen 80;
    server_name blog.opstea.com;

        if ($host != 'blog.opstea.com')
        {
            rewrite ^/(.*)$ https://blog.opstea.com/$1 permanent;
        }

    location / {
        rewrite ^/(.*)$ https://blog.opstea.com/$1 permanent;
    }

}

添加完记得重载一下:

[root@tsh:/etc/nginx/conf.d]$  nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@tsh:/etc/nginx/conf.d]$  nginx -s reload

安装typecho博客

[root@tsh:/data/app/myblog]$ wget https://typecho.org/downloads/1.1-17.10.30-release.tar.gz
[root@tsh:/data/app/myblog]$ tar -zxf 1.1-17.10.30-release.tar.gz 
[root@tsh:/data/app/myblog]$ ls
1.1-17.10.30-release.tar.gz  build
[root@tsh:/data/app/myblog]$ rm -f 1.1-17.10.30-release.tar.gz 
[root@tsh:/data/app/myblog]$ mv build/* .
[root@tsh:/data/app/myblog]$ ls
admin  build  index.php  install  install.php  LICENSE.txt  usr  var
[root@tsh:/data/app/myblog]$ rm -rf build/
[root@tsh:/data/app]$ chown -R nginx.nginx myblog/

访问安装:

填写信息,数据库前面已经创建。


注意这里网站地址用了https,如果你先用http安装完成,后面又换用https,那需要在/data/app/myblog/config.inc.php添加下面一行,以便支持https

define('__TYPECHO_SECURE__',true);

gravatar头像源,设置使用国内源:

# 向文件 /data/app/myblog/config.inc.php 添加:
define('__TYPECHO_GRAVATAR_PREFIX__', 'https://cdn.v2ex.com/gravatar/');

博客设置

基本设置:

启用链接重写:

设置评论邮件通知:

测试邮件发送:


赞(0)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

运维茶馆

本文链接:

https://www.opstea.com/archives/ins_typecho.html(转载时请注明本文出处及文章链接)

评论 (0)
本篇文章评论功能已关闭