利用Wordpress 搭建自己的博客
一、首先搭建好LNMP环境
关于环境的搭建请看博文:https://www.jianshu.com/p/d8a9fa6f6af7
二、安装Wordpress
2.1.1 下载Wordpress安装包
- 下载地址:https://wordpress.org/
- 下载地址:https://zh-cn.wordpress.com/
3.上传至软件存放目录
[root@web01 ~]# cd /server/tools/
[root@web01 /server/tools]# rz -E
rz waiting to receive.
[root@web01 /server/tools]# ls
libiconv-1.16 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz nginx-1.16.0.tar.gz php-7.3.5.tar.gz
libiconv-1.16.tar.gz nginx-1.16.0 php-7.3.5 wordpress-5.4.1-zh_CN.zip
4.解压拷贝内容到blog目录下
[root@web01 /server/tools]# unzip wordpress-5.4.1-zh_CN.zip
Archive: wordpress-5.4.1-zh_CN.zip
creating: wordpress/
inflating: wordpress/wp-login.php
[root@web01 /server/tools]# ls -sh
total 653M
4.0K libiconv-1.16 0 nginx-1.16.0 19M php-7.3.5.tar.gz
5.0M libiconv-1.16.tar.gz 1012K nginx-1.16.0.tar.gz 4.0K wordpress
615M mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 4.0K php-7.3.5 14M wordpress-5.4.1-zh_CN.zip
[root@web01 /server/tools]# mv wordpress/* /application/nginx/html/blog/
mv: overwrite ‘/application/nginx/html/blog/index.php’? yes
[root@web01 /server/tools]# ls /application/nginx/html/blog/
index.html readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php
- 授权www用户管理blog目录
[root@web01 /server/tools]# id www
uid=888(www) gid=888(www) groups=888(www)
[root@web01 /server/tools]# chown -R www.www /application/nginx/html/blog/
[root@web01 /server/tools]# ls -l /application/nginx/html/blog/
total 208
-rw-r--r-- 1 www www 47 May 10 13:59 index.html
-rw-r--r-- 1 www www 405 Feb 6 14:33 index.php
-rw-r--r-- 1 www www 19915 Apr 30 04:09 license.txt
-rw-r--r-- 1 www www 7005 Apr 30 04:10 readme.html
-rw-r--r-- 1 www www 6912 Feb 6 14:33 wp-activate.php
drwxr-xr-x 9 www www 4096 Apr 30 04:00 wp-admin
-rw-r--r-- 1 www www 351 Feb 6 14:33 wp-blog-header.php
-rw-r--r-- 1 www www 2275 Feb 6 14:33 wp-comments-post.php
-rw-r--r-- 1 www www 2776 Apr 30 04:10 wp-config-sample.php
drwxr-xr-x 5 www www 69 Apr 30 04:10 wp-content
-rw-r--r-- 1 www www 3940 Feb 6 14:33 wp-cron.php
drwxr-xr-x 21 www www 8192 Apr 30 04:10 wp-includes
-rw-r--r-- 1 www www 2496 Feb 6 14:33 wp-links-opml.php
-rw-r--r-- 1 www www 3300 Feb 6 14:33 wp-load.php
-rw-r--r-- 1 www www 47874 Feb 10 11:50 wp-login.php
-rw-r--r-- 1 www www 8509 Apr 14 19:34 wp-mail.php
-rw-r--r-- 1 www www 19396 Apr 10 11:59 wp-settings.php
-rw-r--r-- 1 www www 31111 Feb 6 14:33 wp-signup.php
-rw-r--r-- 1 www www 4755 Feb 6 14:33 wp-trackback.php
-rw-r--r-- 1 www www 3133 Feb 6 14:33 xmlrpc.php
6.在mysql数据库例创建管理WordPress的用户以及WordPress的数据库
mysql> create database wordpress charset UTF8;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |
+--------------------+
5 rows in set (0.00 sec)
mysql> grant all privileges on wordpress.* to 'wordpress'@'%' identified by '密码';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
31 rows in set (0.00 sec)
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| wordpress | % |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
4 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
7.检查LNMP环境服务是否启动
[root@web01 ~]# netstat -luntp|egrep -i "nginx|php|mysql"
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1396/php-fpm: maste
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1551/nginx: master
tcp6 0 0 :::3306 :::* LISTEN 1390/mysqld
8.开始配置WordPress
9.如果出现数据库报错,不能生成数据库连接文件,要手动配置数据库连接文件
[root@web01 /application/nginx/html/blog]# ll
total 212
-rw-r--r-- 1 www www 47 May 10 13:59 index.html
-rw-r--r-- 1 www www 405 Feb 6 14:33 index.php
-rw-r--r-- 1 www www 19915 Apr 30 04:09 license.txt
-rw-r--r-- 1 www www 7005 Apr 30 04:10 readme.html
-rw-r--r-- 1 www www 6912 Feb 6 14:33 wp-activate.php
drwxr-xr-x 9 www www 4096 Apr 30 04:00 wp-admin
-rw-r--r-- 1 www www 351 Feb 6 14:33 wp-blog-header.php
-rw-r--r-- 1 www www 2275 Feb 6 14:33 wp-comments-post.php
-rw-rw-rw- 1 www www 3055 May 14 12:12 wp-config.php
-rw-r--r-- 1 www www 2776 Apr 30 04:10 wp-config-sample.php #就是这个
drwxr-xr-x 7 www www 99 May 14 12:26 wp-content
-rw-r--r-- 1 www www 3940 Feb 6 14:33 wp-cron.php
drwxr-xr-x 21 www www 8192 Apr 30 04:10 wp-includes
-rw-r--r-- 1 www www 2496 Feb 6 14:33 wp-links-opml.php
-rw-r--r-- 1 www www 3300 Feb 6 14:33 wp-load.php
-rw-r--r-- 1 www www 47874 Feb 10 11:50 wp-login.php
-rw-r--r-- 1 www www 8509 Apr 14 19:34 wp-mail.php
-rw-r--r-- 1 www www 19396 Apr 10 11:59 wp-settings.php
-rw-r--r-- 1 www www 31111 Feb 6 14:33 wp-signup.php
-rw-r--r-- 1 www www 4755 Feb 6 14:33 wp-trackback.php
-rw-r--r-- 1 www www 3133 Feb 6 14:33 xmlrpc.php
[root@web01 /application/nginx/html/blog]# cp wp-config-sample.php wp-config.php
[root@web01 /application/nginx/html/blog]# vim wp-config.php
#填写如下数据
/** WordPress数据库的名称 */
define( 'DB_NAME', 'wordpress' );
/** MySQL数据库用户名 */
define( 'DB_USER', 'wordpress' );
/** MySQL数据库密码 */
define( 'DB_PASSWORD', '123456' );
/** MySQL主机 */
define( 'DB_HOST', 'localhost' );
/** 创建数据表时默认的文字编码 */
define( 'DB_CHARSET', 'utf8mb4' );
幸福是努力奋斗获得的-------。