搭建 Wordpress 博客系统

1.首先,请参考Linux 搭建 LNMP 环境,构建好博客所需的基本环境。

2.新建一个虚拟主机

	root@centos:~# lnmp vhost add
	+-------------------------------------------+
	|    Manager for LNMP, Written by Licess    |
	+-------------------------------------------+
	|              https://lnmp.org             |
	+-------------------------------------------+
	Please enter domain(example: www.lnmp.org): www.v5linux.com # 填写你的域名
	 Your domain: www.v5linux.com
	Enter more domain name(example: lnmp.org *.lnmp.org):
	Please enter the directory for the domain: www.v5linux.com
	Default directory: /home/wwwroot/www.v5linux.com:
	Virtual Host Directory: /home/wwwroot/www.v5linux.com # 默认站点的位置
	Allow Rewrite rule? (y/n) y # 是否配置 rewrite 规则,如果选择是,可以输入 wordPress
	Please enter the rewrite of programme,
	wordpress,discuz,typecho,sablog,typecho rewrite was exist.
	(Default rewrite: other): wordpress
	You choose rewrite: wordpress
	Allow access log? (y/n) y # 允许保存日志
	Enter access log filename(Default:www.v5linux.com.log): # 日志保存的位置
	You access log filename: www.v5linux.com.log
	Create database and MySQL user with same name (y/n) n # 是否创建mysql
	Add SSL Certificate (y/n) n # 是否创建 ssl 证书

	Press any key to start create virtul host...
	Create Virtul Host directory......
	set permissions of Virtual Host directory......
	You select the exist rewrite rule:/usr/local/nginx/conf/wordpress.conf
	Test Nginx configure file......
	nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
	nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
	Reload Nginx......
	Gracefully shutting down php-fpm . done
	Starting php-fpm  done
	================================================
	Virtualhost infomation:
	Your domain: www.v5linux.com
	Home Directory: /home/wwwroot/www.v5linux.com
	Rewrite: wordpress
	Enable log: yes
	Create database: no
	Create ftp account: no
	=============================

3.创建一个数据库。

root@centos:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.23-MariaDB Source distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>

4.下载 WordPress 程序,打开https://cn.wordpress.org/ 下载 tar.gz 的软件包进行解压。

cd /opt/
wget -c https://cn.wordpress.org/wordpress-4.9-zh_CN.tar.gz
tar zxvf wordpress-4.9-zh_CN.tar.gz
cd wordpress/
mv * /home/wwwroot/www.v5linux.com # 创建的虚拟主机的目录
chown -R www:www *

5.设置域名解析并确认解析是否正常,可以设置完使用 dig 检查

# dig www.v5linux.com

; <<>> DiG 9.9.7-P3 <<>> www.v5linux.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18606
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;www.v5linux.com.		IN	A

;; ANSWER SECTION:
www.v5linux.com.	600	IN	A	59.111.92.230

;; Query time: 72 msec
;; SERVER: 192.168.130.33#53(192.168.130.33)
;; WHEN: Fri Nov 24 16:02:58 CST 2017
;; MSG SIZE  rcvd: 60

6.访问网站会出现如图所示的界面

7.点击[现在就开始],然后填写数据库名、用户名、密码、数据库的主机地址。

8.然后点击现在安装,填写站点的标题,站点登录的用户名和密码以及电子邮件,填写完毕后点击[安装 WordPress] 按钮

9.安装完毕后点击登录,填写用户名和密码

10.进入控制台