CentOS 7 配置wordpress(HTTP)

CentOS 7 配置wordpress(HTTP)

实验环境

服务端: 一台CentOS 7桌面版,IP地址:192.168.10.1/24,DNS:192.168.10.1,关闭防火墙和子系统
客户端: 一台CentOS 7桌面版,IP地址:192.168.10.2/24,DNS:192.168.10.1,关闭防火墙和子系统

服务端配置

DNS配置

nslookup www.hb.com             #解析正向地址
nslookup 192.168.10.1           #解析反向地址

image-20231224205244711

安装php软件包

yum install php php-mysql -y           #安装php和php-mysql数据库连接工具

image-20231224212427177

安装mysql数据库

yum install mariadb-server -y            #安装数据库服务

image-20231224205326711

将数据库服务加入到开机自启
systemctl enable mariadb              #将服务加入到开机自启
systemctl restart mariadb             #重启mariadb数据库服务

image-20231224205505012

image-20231224205532711

创建数据库
[root@localhost ~]# mysql                    #进入数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-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.
​
MariaDB [(none)]> create database wordpress; #创建wordpress数据库
Query OK, 1 row affected (0.00 sec)
​
MariaDB [(none)]> grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by 'Skills39!'; #创建数据库连接用户,wordpress代表数据库,*代表数据库中的表,localhost也可以是远端的,可以用远端的IP地址,域名或者主机名代替或者百分号
Query OK, 0 rows affected (0.00 sec)
​
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)         #刷新管理用户让其数据库生效
​
MariaDB [(none)]> exit                       #退出数据库
Bye

image-20231224210016704

重启数据库服务
systemctl restart mariadb                #重启数据库

image-20231224210620912

wordpress配置

上传wordpress安装包

image-20231224210745435

image-20231224210810993

上传成功

image-20231224210838388

创建存储wordpress的文件
mkdir /1

image-20231224210929085

解压wordpress压缩包到/1下
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz -C /1/

image-20231224211126221

解压成功

image-20231224211154509

配置wordpress连接mysql
cd /1/wordpress							 #切换到wordpress目录下
cp -a wp-config-sample.php wp-config.php #复制模板wp-config-sample.php wp-config.php
vim wp-config.php						 #编辑wp-config.php主配置文件
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');			 #填写wordpress数据库文件为wordpress

/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');			 #填写mysql数据库用户名为wordpress

/** MySQL数据库密码 */
define('DB_PASSWORD', 'Skills39!');		 #填写mysql数据库用户密码为Skills39!

/** MySQL主机 */
define('DB_HOST', 'localhost');			 #因为是一台服务器,可以写本地连接和访问

/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');			 #默认是utf-8编码

/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');

image-20231224211904100

http配置

yum install httpd -y				#安装httpd服务

image-20231224212509470

复制模板文件
find / | grep vhosts
cp -a /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/vhosts.conf

image-20231224212620485

编辑主配置文件允许读取根目录和index.php文件
vim /etc/httpd/conf/httpd.conf
102 <Directory />
103     AllowOverride none
104     Require all granted					#允许读取根目录
105 </Directory>

image-20231224212740464

163 <IfModule dir_module>
164     DirectoryIndex index.html index.php			#添加index.php文件
165 </IfModule>

image-20231224212808920

编辑虚拟配置文件
vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/1/wordpress"															
    ServerName www.hb.com
</VirtualHost>

image-20231224213046313

重启httpd服务
systemctl restart httpd				#重启httpd服务
systemctl status httpd				#查看httpd服务状态

image-20231224213119611

客户端测试

打开浏览器访问http://www.hb.com

image-20231224213448860

安装wordpress站点

image-20231224213542146

点击登录

image-20231224213604253

账户名称:wordpress
账户密码:wordpress

image-20231224213640234

登录后台成功

image-20231224213708403

扩展知识点

在wordpress里面发布一篇自定义文章

发布第一篇文章

image-20231224213743146

文章标题设置为hello,wlgczhywsx
文章内容:Always believe that beautiful things are about tohappen

image-20231224214015785

点击发布

image-20231224214051956

发布成功

image-20231224214110991

新建一个网站访问http://www.hb.com

image-20231224214222928

往下滑,找到hello,wlgczhywsx

image-20231224214259804

访问文章成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嘻嘻哥哥~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值