WordPress use to build personal blog

Chapter One: preparatory work

Now more popular blog community has a garden blog, Open Source China, think not, Nuggets, CSDN, Jane books and so on, who are able to share the exchange of relevant expertise in their favorite communities. If you want to have an own blog, just below me look, we need to prepare for what? After all, the blog is more personal feel at home.

There are many options to build personal blog, I am not a person if you are engaged in software development industry recommends using GitHub page to build a static blog used to meet. As a software developer, I would choose to use WordPress to build personal blog, but also the way of consolidating knowledge, and the cost is not a lot of need, after all, in their own home repair, why not a little on the tall repair it.

A rent cloud servers and domain name

I chose Ali cloud server and cloud domain name registered on Ali.

Server : Service providers often have some activity, I rent at the end of 18 years, had to buy a nuclear 2G, 3-year price is $ 299, (recommended a one-time buy a few years, or if the latter is more expensive renewals ). It has now been on hold for more than a year time.

Domain Name : domain name is relatively cheaper, the same, or renewals will be time to buy a little more expensive than the first. I registered the domain name is the end .website, took five dollars.

Second, the record

Access https://beian.aliyun.com/ for the record, the record will be used during Ali cloud app uploads personal identification information (here to Tucao about Ali cloud app simply shoot clear identity information), filing of information filled in caught quite strict (or a series of words related to the industry to promote the blog, to share, exchange can not occur), in general, if there is to fill in the content does not meet the requirements, Ali cloud filing day or so members will contact you to modify. Transportation Authority will put the record after editing. General filing often is 9-30 days. I spent a record 11 days time.

Link Authority after completion of the record and a police record. It is said that after the opening of the site, receive a phone call to let go for the record. But now I have not received similar calls.

Third, DNS

DNS is relatively simple, a few pictures can be said clearly.

  • Log Ali cloud into the console, find the domain name, and then click resolved

  • 点击新手指引

  • 网站解析,记录值填写你的服务器公网IP地址

  • 邮箱解析,选择一个邮箱进行解析。

这样域名就解析完成了,等几分钟,来验证一下,是否解析成功了。windows系统cmd打开命令行,然后ping 域名地址,如果解析成功,会返回IP地址。

第二章:安装wordPress

上一章中,我们已经将域名解析至服务器了。这一章我们直接来搭建我们的博客,我们将使用docker来安装wordpress。如果不知道怎么使用docker的小伙伴,可以看看前面写的这两篇文章。windows使用docker运行mysql等工具(一)windows安装dockerwindows使用docker运行mysql等工具(二)安装运行mysql

本次我们服务器采用的系统是centos7.4。

一、安装docker

请连接服务器并切换至root用户。

1.查看centos系统内核

uname -r //查看内核版本。

Centos版本的Docker 是对Centos 系统有要求的,CentOS 系统的内核版本必须高于 3.10 否则Centos 是不能支持docker的。 如果内核版本较低,请先升级内核。

2.下载docker

yum install -y docker // 下载docker   

3.启动docker

service docker start // 启动docker

4.查看docker运行状态

systemctl status docker //查看docker运行状态 

出现running则说明docker已经启动成功了。

二、运行mysql

拉取镜像及可能出现的问题在这里就不讲了,已经写过一篇较为具体的文章,有疑惑的小伙伴请查看windows使用docker运行mysql等工具(二)安装运行mysql

在这里需要注意的是,请开通映射出来的端口号,不然无法连接到数据库。当然为了安全起见,最好还是不要开通数据库公网端口哈。

连接到数据库后创建一个名为wordpress的数据库。

三、运行wordpress

1.拉去wordpress镜像

docker pull wordpress:latest // 拉去wordpress镜像

2.启动wordpress容器

// 启动wordpress并连接mysql8.0,并给mysql8.0起个别名db
docker run --name mywordpress --link mysql8.0:db -p 80:80 -d wordpress:latest

ok,到这里基本就已经完成了。

3.访问域名,会出现如下下面。

选择语言后,点击继续,出现如下页面,填写数据库信息。

继续下一步:

wordPress中文网: https://zh-cn.wordpress.com/

tar.gz压缩格式用于unix的操作系统,而zip用于windows的操作系统,但在windows系统中WinRar工具同样可以解压缩tar.gz格式的。这下好了,不用再对下载那个文件而迟疑了。 我们下载tar.gz

Centos版本的Docker 是对Centos 系统有要求的,CentOS 系统的内核版本必须高于 3.10 否则Centos 是不能支持docker的。

uname -r // 查看内核版本

yum install -y docker  // 安装docker

service docker start  // 启动docker

第三章:装饰博客

上一章中博客基本搭建完成了,这一章我们来看看如何做一些优化。

一、主题选择

大家可以登录wordpress后台选择主题,然后去找自己喜欢的主题来安装,这里建议大家在百度中去搜一些自己喜欢的主题,下载后直接导入即可。我这里选择的主题是VT Blogging,因为我还是比较喜欢比较精简的博客主题,这一款正好符合我。

二、添加备案号

在申请备案的时候大家一定记得,阿里云发送邮件说在建站后需添加备案号。一般官方主题在后台“常规”选项卡中有添加ICP备案号的地方。但是我用的这款VT Blogging主题并没有。因此就开始了寻找之旅。这个备案号到底在哪可以改。下面是具体步骤:

  1. 进入docker 容器内部

    sudo docker exec -it 容器id /bin/bash

  2. 然后ls查看一下有哪些目录

    cd wp-content/themes/vt-blogging

当我们使用vi打开某个文件时,如果出现 bash:vi:command not found。这是因为没有下载vi编辑器。

解决办法为

ubuntu系统使用

apt-get update

apt-get install -y vim

centos系统使用

yum update

yum install -y vim

最终,我们发现在目录/inc/template-tags.php下面有这个备案信息。我们模仿着写一段php,这样就备案信息就改好了。

三、常用插件推荐

  1. Enlighter —— 程序员必备,可自定义的语法高亮显示插件。
  2. WP Super Cache —— WordPress的快速缓存插件,页面静态化。 一方面能够提高SEO排名,另一方面可以提高博客的访问速度,缓解服务器压力。
  3. WP-PageNavi —— 为您的WordPress博客添加更高级的分页导航。
  4. Yoast SEO —— 第一个真正意义上的 WordPress 全能SEO解决方案!包含了页面内容分析、XML站点地图和更多功能。
  5. Wordfence —— 安全性插件,安全的重要程度不言而喻哦。

目前我的博客还在持续优化中,欢迎大家访问指教。博客地址:http://abin.website

如果文章对您有帮助,请记得点赞关注哟~
欢迎大家关注我的公众号:字节传说,每日推送技术文章供大家学习参考。

Guess you like

Origin www.cnblogs.com/zhixie/p/12154692.html