项目介绍
今天记录一次搭建 wordpres 博客,并且成功修改 wordpress 的默认主题,在其中,有几个坑需要注意以下,故此博客记录。
准备环境
Centos 7 服务器一台
# 暂时将 iptables 关闭、SElinux 修改为警告模式
[root@fp-22 ~]# systemctl stop firewalld.service
[root@fp-22 ~]# setenforce 0
# 检查 ynm 源
[root@fp-22 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.aliyun.com
repo id repo name status
!base/7/x86_64 CentOS-7 - Base 10,097
!extras/7/x86_64 CentOS-7 - Extras 323
!updates/7/x86_64 CentOS-7 - Updates 1,446
repolist: 11,866
所需软件包(可下载):
- wordpress-4.9.4-zh_CN.zip
-link 点击此处下载 - latest-zh_CN.zip
-link 点击此处下载
搭建 LAMP 环境
搭建 LAMP 环境,使用 yum 安装即可
[root@fp-22 ~]# yum -y install httpd php php-mysql mariadb mariadb-server
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.cqu.edu.cn
……
Dependency Installed:
httpd-tools.x86_64 0:2.4.6-90.el7.centos
libzip.x86_64 0:0.10.1-8.el7
……
Complete!
添加 php 页面测试文件
[root@fp-22 ~]# cd /var/www/html/
[root@fp-22 html]# vim info.php
<?php
phpinfo();
?>
启动 apche,通过进程和端口查看是否成功
[root@fp-22 html]# systemctl start httpd
[root@fp-22 html]# ps -ef |grep httpd
root 2015 1 0 21:55 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2017 2015 0 21:55 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
……
apache 2027 2015 0 21:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 2030 1802 0 21:59 pts/0 00:00:00 grep --color=auto httpd
[root@fp-22 html]# ss -lntp |grep httpd
LISTEN 0 128 [::]:80 [::]:* users:(("httpd",pid=2027,fd=4),("httpd",pid=2026,fd=4),("httpd",pid=2025,fd=4),("httpd",pid=2024,fd=4),("httpd",pid=2023,fd=4),("httpd",pid=2022,fd=4),("httpd",pid=2020,fd=4),("httpd",pid=2019,fd=4),("httpd",pid=2018,fd=4),("httpd",pid=2017,fd=4),("httpd",pid=2015,fd=4))
访问 php 测试页面
至此,LAMP 搭建完毕。
安装 wordpress 博客
上传安装包之后,可看到,*.zip格式,可用 unzip 命令解压
扫描二维码关注公众号,回复:
9394646 查看本文章
[root@fp-22 html]# ll
total 9628
-rw-r--r--. 1 root root 20 Feb 25 21:54 info.php
drwxr-xr-x. 5 root root 4096 Feb 8 2018 wordpress
-rw-r--r--. 1 root root 9848003 Jul 13 2019 wordpress-4.9.4-zh_CN.zip
此时,直接去访问,会出现一个问题,提示你需要配置修改一个文件
如果你不想配置文件,可以直接在数据库中授权,即可
[root@fp-22 ~]# systemctl start mariadb
[root@fp-22 ~]# mysql
……
# 创建中文数据库 wordpress
MariaDB [(none)]> create database wordpress charset utf8;
Query OK, 1 row affected (0.00 sec)
# 授予 tom 用户对于 wordpress 库的所有权限
MariaDB [(none)]> grant all on wordpress.* to 'tom'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
# 刷新权限
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
再次去访问,点击 “现在开始!”
按上图输入,点击 “提交”,会进入下一页面
出现了第一个坑,不能写入文件,修改属主属组即可
# 将属主和属组都修改为 apache
[root@fp-22 ~]# cd /var/www/html/
[root@fp-22 html]# chown -R apache:apache wordpress
再次访问页面,刷新即可
点击 “现在安装”,填写个人信息
点击 “安装 Wordpress”,即为安装成功
点击 “登录”,进入登录页面
点击 “登录”,进入后台管理
重新打开一个窗口,进入首页,如下
修改 wordpress 主题
进入后台管理,依次点击 “外观 --> 添加”
这里我们选择一款测试即可
点击 “启动”,重新打开一个窗口,访问首页,已经变更主题
在这里有一个坑,如果你未按照我上面的步骤一步一步来的话,会出现一个问题
点击 “安装” 后,没有出现正在安装,而是出现了如下图
此时,将上面提到的软件包(可下载)放入站点目录解压即可
[root@fp-22 html]# ll
total 22744
-rw-r--r--. 1 root root 20 Feb 25 21:54 info.php
-rw-r--r--. 1 root root 13427353 Feb 25 09:32 latest-zh_CN.zip
drwxr-xr-x. 5 root root 4096 Feb 25 22:35 wordpress
-rw-r--r--. 1 root root 9848003 Jul 13 2019 wordpress-4.9.4-zh_CN.zip
[root@fp-22 html]# unzip latest-zh_CN.zip
……
解压完成后,直接刷新页面,再次点击 “安装” 即可
总结
只有注入思想的博客才是好的博客