Building a Personal Blog with Typecho (Manually Building LNMP)#
Preparations#
- Centos7 Server
- xshell Connection Tool
1. Manually Building LNMP Environment#
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;
PHP72 and Related Components#
- 
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.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- 
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
- 
Execute the following command to start the PHP-FPM service. systemctl start php-fpm
- 
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.
