項目介紹
今天記錄一次搭建 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 資源包,安裝即可