项目介绍
今天记录一次搭建 wordpres 博客,并且成功修改 wordpress 的默认主题,在其中,有几个坑需要注意以下,故此博客记录。
准备环境
Centos 7 服务器一台
//iptables 关闭、SElinux 修改为警告模式
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]#
# 检查 ynm 源
[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
源标识 源名称 状态
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,478
repolist: 11,898
[root@localhost ~]#
搭建 LAMP 环境
搭建 LAMP 环境,使用 yum 安装即可
[root@localhost ~]# yum -y install httpd php php-mysql mariadb mariadb-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
软件包 httpd-2.4.6-90.el7.centos.x86_64 已安装并且是最新版本
软件包 php-5.4.16-46.1.el7_7.x86_64 已安装并且是最新版本
软件包 php-mysql-5.4.16-46.1.el7_7.x86_64 已安装并且是最新版本
软件包 1:mariadb-5.5.64-1.el7.x86_64 已安装并且是最新版本
软件包 1:mariadb-server-5.5.64-1.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]#
添加 php 页面测试文件
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
~
启动 apche,通过进程和端口查看是否成功
[root@localhost html]# systemctl restart httpd
[root@localhost html]# ps -ef | grep httpd
root 4616 1 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4618 4616 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4619 4616 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4620 4616 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4621 4616 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4622 4616 0 21:10 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 4624 4226 0 21:10 pts/1 00:00:00 grep --color=auto httpd
[root@localhost html]# ss -lntp | grep httpd
LISTEN 0 128 :::80 :::* users:(("httpd",pid=4622,fd=4),(httpd",pid=4621,fd=4),("httpd",pid=4620,fd=4),("httpd",pid=4619,fd=4),("httpd",pid=4618,fd=4),("httpd",pid=4616,fd=4))
[root@localhost html]#
访问 php 测试页面
lamp搭建完毕
安装 wordpress 博客
上传安装包之后,可看到,*.zip格式,可用 unzip 命令解压
[root@localhost html]# ll
总用量 9628
-rw-r--r--. 1 root root 20 2月 29 21:09 index.php
drwxr-xr-x. 5 root root 4096 2月 8 2018 wordpress
-rw-r--r--. 1 root root 9848003 7月 13 2019 wordpress-4.9.4-zh_CN.zip
[root@localhost html]#
直接去访问,会出现一个问题,提示你需要配置修改一个文件
如果你不想配置文件,可以直接在数据库中授权,即可
[root@localhost html]# systemctl start mariadb
[root@localhost html]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 创建中文数据库 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 'lan'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
#刷新权限
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
再次去访问,点击 “现在开始!”
按上图输入,点击 “提交”,会进入下一页面
出现了第一个坑,不能写入文件,修改属主属组即可
# 将属主和属组都修改为 apache
[root@localhost html]# systemctl start httpd
[root@localhost html]# chown -R apache:apache wordpress
[root@localhost html]#
再次访问页面,刷新即可
点击 “现在安装”,填写个人信息
点击 “登录”,进入登录页面
点击 “登录”,进入后台管理
重新打开一个窗口,进入首页,如下
修改主题
选择自己喜欢的“主题”进行安装测试
发现 下载不了 进行升级
下载不了 使用 最新的 wordpress 资源包,安装即可