使用typecho安装搭建个人博客

安装

安装 mysql (这里是 mariadb ), nginx, php, php-mysql, php-fpm
yum install mysql nginx php php-mysql php-fpm  
启动 php-fpm
systemctl start php-fpm
systemctl enable php-fpm
安装和配置mysql

.....省略mysql安装配置

创建数据库
systemctl start mariadb
systemctl enable mariadb
mysql -uroot -p
 
 > create database typecho;
下载 typecho,并安装到指定目录
cd /root
wget http://typecho.org/downloads/1.1-17.10.30-release.tar.gz
tar -xzvf 1.1-17.10.30-release.tar.gz
mkdir -p /usr/share/nginx/html
cp -r /root/build/* /usr/share/nginx/html/
修改 nginx的配置文件
vi /etc/nginx/nginx.conf
  • nginx.conf 示例:
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
    worker_connections 1024;
}
http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log /var/log/nginx/access.log main;
    sendfile on;
    #tcp_nopush on;
    keepalive_timeout 120;
    client_max_body_size 20m;
    #gzip on;
    server {
        listen 80;
        server_name www.flysium.xyz;
        # do not change the dir, it's also for trojan.
        root /usr/share/nginx/html;
        index index.php index.html index.htm;

        location / {

 }

        location ~* \.php {
            # start php-fpm.service and listen this port.
            fastcgi_pass 127.0.0.1:9000;  
            include fastcgi_params;  
            fastcgi_index index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }

    }
}
启动nginx
systemctl start nginx
systemctl enable nginx
访问

访问你的域名网站,就可以开始配置了,参考typecho的官方指导

Typecho 博客本身不带主题/插件商店,因此主题和插件需要自己到论坛、网上去找,下载后上传到网站目录的相应文件夹中,再到网站后台启用即可。

  • 插件位置:网站目录/usr/plugins
  • 主题位置:网站目录/usr/themes
  • 附件位置:网站目录/usr/uploads

配置 SSL(可跳过)

登录Typecho后台 -> 设置 -> 基本设置 -> 站点地址改成https的域名是必须的。

1.png

编辑Typecho站点根目录下的文件config.inc.php加入下面一行配置,否则网站后台还是会调用HTTP资源。

/** 开启HTTPS */
define('__TYPECHO_SECURE__',true);

ssl-open.png

主题推荐

把下载的主题文件解压上传到 网站根目录/usr/themes/ 即可。
这里推荐的是Material: https://github.com/idawnlight/typecho-theme-material
其他推荐:https://zhuanlan.zhihu.com/p/34292066

wget https://github.com/idawnlight/typecho-theme-material/releases/download/3.3.5/Material-3.5.5.zip
unzip Material-3.5.5.zip
cp  Material /usr/share/nginx/html/usr/themes/

控制台》外观,启用外观即可:
2.png

DNS和服务器方面