本博客搭建和定制方法

搭建环境

硬件

  • 阿里云服务器

软件

  • LNMP 环境(Linux + PHP + Nginx + Mysql)
  • WordPress

定制本博客的Wordpress 功能

博客主题

Twenty Eleven, 简约风格

博客文本编辑器

使用了WP-Markdown 插件,可惜不支持GitHub 扩展的特性

HTML h3 标题又小又不明显 怎么办?

在主题目录 wp-content/themes/twentyeleven/style.css 中,h3 元素样式添加 font-weight: bold;更改front-size为12px。

h3 {
    font-weight: bold;
    front-size: 12px;
}

添加缓存,提高博客响应速度

WP Super Cache 插件

让列表页只显示文章标题,而不把文章标题页显示出来

修改主题中文件,在 content.php 中,把调用the_content函数的语句注释掉

在文章末尾添加文章签名,如果文章被别的网站扒去,也可以把来源显示出来。

修改主题中文件,content-single.php,

在content-entry 里添加如下代码

转载请注明来源,原地址保持永久更新。
博客首页:作程的技术博客
文章标题:>《
本文链接:>

访问 http://it.zuocheng.net/sitemap.xml 提示错误

把xml 注释去掉,修改aioseop_sitemap.php

//$this->comment_string = __( Sitemap %s generated by All in One SEO Pack %s by Michael Torbert of Semper Fi Web Design on %s, 'all_in_one_seo_pack' );

添加链接 (书签、友情链接等)

在数据库中,把wp_options.link_manager_enabled项设置为1

支持HTTPS

使用了 let’s encrypt 的证书

所使用的插件列表

  • All In One SEO Pack //用于SEO
  • Disable Google Fonts //禁止调用google字体,国内请求慢,不然会降低网站响应速度
  • Google XML Sitemaps //生成xml,SEO
  • Query Monitor //监控,一般情况下禁用
  • Table of Contents Plus //显示文章结构
  • Wordfence Security
  • WP Clean Up
  • WP Super Cache
  • WP-Markdown
  • WP-PostViews
  • WPtouch Mobile Plugin //让博客对移动端友好
  • 多说 //社会化登陆
  • 百度sitemap //百度搜索SEO
  • WP-Statistics //统计,包括来访、IP、展示数等等

更新、安装 直接下载,不使用FTP

修改wp-config.php,添加命令:

define("FS_METHOD","direct"); 
define("FS_CHMOD_DIR", 0777); 
define("FS_CHMOD_FILE", 0777); 

系统优化

使用 Unix domain socket,减小 LAMP 通信代价

Nginx 和 PHP ,PHP 和 Mysql 通信都使用Unix domain socket,并且把套接字文件放到内存文件系统/dev/shm下面

mysqld 有大量sleep进程,占用过多内存。

添加mysqld配置

[mysqld] wait_timeout=120 interactive_timeout=120

统计过滤机器人列表

服务器迁移

数据迁移

把数据表导出
[admin@src]mysqldump -uroot -password BLOG > /tmp/DB.sql
scp 到目标机 scp /tmp/DB.sql target:/tmp
在目标机导入数据库
mysql>use DB; souce /tmp/DB.sql;
配置权限
grant all privileges on DB to user@'%' identified by 'password';
grant all privileges on DB.* to user@'%' identified by 'password';
flush privileges;

msyql 8之后版本
CREATE USER 'user_name'@'%' IDENTIFIED BY 'pass';
grant all privileges on *.* to 'user_name'@'%';
flush privileges;

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注