banner
蛾

正在探索这个世界
bilibili
github
email
instagram

Build a personal blog using Typeco.

Building a Personal Blog with Typecho (Manually Building LNMP)#

image

Preparations#

  • Centos7 Server
  • xshell Connection Tool

1. Manually Building LNMP Environment#

Manually Building LNMP Environment on Cloud Server (CentOS 7) - Best Practices - Documentation Center - Tencent Cloud (tencent.com)

Nginx#

yum install -y nginx
vi /etc/nginx/nginx.conf
server {
    listen       80;
    root   /usr/share/nginx/myblog;
    server_name  zxcbz.top;
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;
    #
    location / {
          index index.php index.html index.htm;
          if (-f $request_filename/index.html) {
               rewrite (.*) $1/index.html break;
          }
          if (-f $request_filename/index.php) {
               rewrite (.*) $1/index.php;
          }
          if (!-e $request_filename) {
               rewrite (.*) /index.php;
          }
    }
    #error_page  404              /404.html;
    #redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }
    #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
     location ~ .\.php(\ /.)*$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
}

nginx -t

systemctl start nginx

systemctl enable nginx

Mariadb#

yum install -y mariadb-server mariadb

systemctl start mariadb
systemctl enable mariadb

mysql_secure_installation


Create Database

create database typecho_mydb;

create user 'dbuser'@'localhost' identified by 'password';

grant all on typecho_mydb.* to 'dbuser'@'localhost';

flush privileges;
  1. Execute the following commands in order to update the PHP software source in yum.

    rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    
  2. Execute the following command to install the packages required for PHP 7.2.

    yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64 php72w-mbstring.x86_64
    
  3. Execute the following command to start the PHP-FPM service.

    systemctl start php-fpm
    
  4. Execute the following command to set the PHP-FPM service to start automatically on boot.

    systemctl enable php-fpm
    

2. Download Typecho#

sudo mkdir /var/www/mywebsite
cd /var/www/mywebsite/
sudo wget https://codeload.github.com/typecho/typecho/tar.gz/refs/tags/v1.2.0
sudo tar zxvf v1.2.0
cd /usr/share/nginx/
cp -ra /var/www/mywebsite/typecho-1.2.0 myblog #Create the myblog directory under /usr/share/nginx/ and copy the files from /var/www/mywebsite/typecho-1.2.0 to it

3. Install Typecho#

Follow the prompts on the website to install step by step.

image-20230304220608158

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.