前言

本笔记基于命令行实现。开始前已有nginx、mysql、php环境。有一定的nginx配置知识。

Typecho

typecho主题:typechx.comGitHub

joe主题:https://github.com/HaoOuBa/Joe.git

仿掘金主题:https://mulingyuer.github.io/Typecho_Theme_JJ/start/install-theme.html

开始安装

1、创建数据库

登录mysql

mysql -u root -p
use mysql;

创建一个名为blog_db(名称随意)的数据库

CREATE DATABASE blog_db;

创建名为blog_user(名称随意)的用户,并设置密码:123@123(自行修改)

CREATE USER 'blog_user'@'localhost' IDENTIFIED BY '123@123';

修改用户权限

GRANT ALL privileges ON blog_db.* TO 'blog_user'@'localhost';

刷新,退出

flush privileges;
quit;

2、创建博客根目录

在某个你喜欢的地方新建一个博客根目录,比如/var/www/blog, 并进入

mkdir -p /var/www/blog && cd /var/www/blog

下载源码(可以在typecho官网找到),并解压

wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip && unzip typecho.zip

修改根目录用户和群组为nginx的用户和群组,比如

chown -R www-data:www-data /var/www/blog

3、nginx配置

以博客域名blog.isgo.win为例,按实际修改

#强制https
server {
    listen 80;
    listen [::]:80;
    server_name blog.isgo.win;
    return 301 https://$host$request_uri;
}

server {
    # SSL configuration
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    include /etc/nginx/cert/ssl.conf;
    #上面创建的根目录
    root /var/www/blog;
    
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.php;

    server_name blog.isgo.win;

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

    # pass PHP scripts to FastCGI server
    # 根据实际修改
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}

修改完成后

#先测试
nginx -t
#如果没报错则:
nginx -s reload

4、安装Typecho

浏览器访问上面配置的域名。点击我准备好了,开始下一步

根据刚才的信息配置数据库

配置完成后,就可以进入博客了。

分类: 教程 标签: typecho教程

评论

暂无评论数据

暂无评论数据

目录