当前位置: 首页 > news >正文

在 CentOS 7 上使用 LAMP 架构部署 WordPress

CentOS 7 LAMP 架构部署 WordPress全步骤

在这里插入图片描述

本文将详细介绍如何在 CentOS 7 系统上通过 LAMP(Linux + Apache + MariaDB + PHP)架构部署 WordPress 博客平台。

在CentOS 7上基于LAMP架构部署WordPress

一、系统基础配置

1. 修改主机名(本机IP:192.168.100.10)

[root@lamp ~]# hostnamectl set-hostname lamp.example.com  # 设置主机名为lamp.example.com
[root@lamp ~]# bash  # 刷新当前Shell会话,使主机名生效

2. 关闭防火墙和SELinux

[root@lamp ~]# systemctl stop firewalld  # 临时关闭防火墙
[root@lamp ~]# systemctl disable firewalld  # 永久禁用防火墙(开机不启动)
[root@lamp ~]# setenforce 0  # 临时关闭SELinux(立即生效)
[root@lamp ~]# vim /etc/selinux/config  SELINUX=disabled   # 永久关闭SELinux(需重启生效)

3. 配置时钟同步

[root@lamp ~]# yum -y install chrony  # 安装chrony时间同步工具
[root@lamp ~]# systemctl restart chronyd  # 重启chronyd服务
[root@lamp ~]# systemctl enable chronyd  # 设置chronyd开机自启
[root@lamp ~]# hwclock -w  # 将系统时间同步到硬件时钟(防止重启后时间错乱)

4.

# 下载阿里云 CentOS 7 yum 源配置文件。
[root@lamp yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-18 15:30:38--  https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 119.84.54.233, 119.84.54.6, 119.84.54.4
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|119.84.54.233|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”100%[=============================================>] 2,523       --.-K/s 用时 0s      2025-08-18 15:30:38 (1.16 GB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])[root@lamp yum.repos.d]# ls
CentOS-Base.repo
[root@lamp yum.repos.d]# yum -y install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                   | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                               | 253 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                              |  27 MB  00:00:01     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(4/4): base/7/x86_64/primary_db                                 | 6.1 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成依赖关系解决=======================================================================================Package                  架构               版本             源                  大小
=======================================================================================
正在安装:epel-release             noarch             7-11             extras              15 k事务概要
=======================================================================================
安装  1 软件包总下载量:15 k
安装大小:24 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
epel-release-7-11.noarch.rpm 的公钥尚未安装
epel-release-7-11.noarch.rpm                                    |  15 kB  00:00:00     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : epel-release-7-11.noarch                                           1/1 验证中      : epel-release-7-11.noarch                                           1/1 已安装:epel-release.noarch 0:7-11                                                           完毕!
[root@lamp yum.repos.d]# ls
CentOS-Base.repo  epel.repo  epel-testing.repo

二、安装LAMP组件

1. 安装Apache和MariaDB

# 安装Apache(httpd)和MariaDB数据库及服务端
[root@lamp ~]# yum -y install httpd mariadb-server mariadb
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                            | 4.4 kB  00:00:00     * base: mirrors.aliyun.com* epel: ftp-stud.hs-esslingen.de* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
epel                                                            | 4.3 kB  00:00:00     
(1/3): epel/x86_64/group                                        | 399 kB  00:00:28     
(2/3): epel/x86_64/updateinfo                                   | 1.0 MB  00:00:58     
(3/3): epel/x86_64/primary_db                                   | 8.7 MB  00:09:28     
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-99.el7.centos.1 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-99.el7.centos.1,它被软件包 httpd-2.4.6-99.el7.centos.1.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-99.el7.centos.1.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-99.el7.centos.1.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-99.el7.centos.1.x86_64 需要
---> 软件包 mariadb.x86_64.1.5.5.68-1.el7 将被 安装
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.68-1.el7,它被软件包 1:mariadb-5.5.68-1.el7.x86_64 需要
---> 软件包 mariadb-server.x86_64.1.5.5.68-1.el7 将被 安装
--> 正在处理依赖关系 perl-DBD-MySQL,它被软件包 1:mariadb-server-5.5.68-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-7.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7_9.1 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-99.el7.centos.1 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
---> 软件包 mariadb-libs.x86_64.1.5.5.60-1.el7_5 将被 升级
---> 软件包 mariadb-libs.x86_64.1.5.5.68-1.el7 将被 更新
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-6.el7 将被 安装
--> 解决依赖关系完成依赖关系解决=======================================================================================Package               架构          版本                         源              大小
=======================================================================================
正在安装:httpd                 x86_64        2.4.6-99.el7.centos.1        updates        2.7 Mmariadb               x86_64        1:5.5.68-1.el7               base           8.8 Mmariadb-server        x86_64        1:5.5.68-1.el7               base            11 M
为依赖而安装:apr                   x86_64        1.4.8-7.el7                  base           104 kapr-util              x86_64        1.5.2-6.el7_9.1              updates         92 khttpd-tools           x86_64        2.4.6-99.el7.centos.1        updates         94 kmailcap               noarch        2.1.41-2.el7                 base            31 kperl-DBD-MySQL        x86_64        4.023-6.el7                  base           140 k
为依赖而更新:mariadb-libs          x86_64        1:5.5.68-1.el7               base           760 k事务概要
=======================================================================================
安装  3 软件包 (+5 依赖软件包)
升级           ( 1 依赖软件包)总下载量:24 M
Downloading packages:
No Presto metadata available for base
(1/9): apr-1.4.8-7.el7.x86_64.rpm                               | 104 kB  00:00:00     
(2/9): apr-util-1.5.2-6.el7_9.1.x86_64.rpm                      |  92 kB  00:00:00     
(3/9): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm             |  94 kB  00:00:00     
(4/9): httpd-2.4.6-99.el7.centos.1.x86_64.rpm                   | 2.7 MB  00:00:00     
(5/9): mailcap-2.1.41-2.el7.noarch.rpm                          |  31 kB  00:00:00     
(6/9): mariadb-libs-5.5.68-1.el7.x86_64.rpm                     | 760 kB  00:00:00     
(7/9): mariadb-server-5.5.68-1.el7.x86_64.rpm                   |  11 MB  00:00:00     
(8/9): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm                    | 140 kB  00:00:00     
(9/9): mariadb-5.5.68-1.el7.x86_64.rpm                          | 8.8 MB  00:00:00     
---------------------------------------------------------------------------------------
总计                                                       27 MB/s |  24 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在更新    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                1/10 正在安装    : apr-1.4.8-7.el7.x86_64                                            2/10 正在安装    : apr-util-1.5.2-6.el7_9.1.x86_64                                   3/10 正在安装    : httpd-tools-2.4.6-99.el7.centos.1.x86_64                          4/10 正在安装    : perl-DBD-MySQL-4.023-6.el7.x86_64                                 5/10 正在安装    : 1:mariadb-5.5.68-1.el7.x86_64                                     6/10 正在安装    : mailcap-2.1.41-2.el7.noarch                                       7/10 正在安装    : httpd-2.4.6-99.el7.centos.1.x86_64                                8/10 正在安装    : 1:mariadb-server-5.5.68-1.el7.x86_64                              9/10 清理        : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                             10/10 验证中      : httpd-tools-2.4.6-99.el7.centos.1.x86_64                          1/10 验证中      : 1:mariadb-server-5.5.68-1.el7.x86_64                              2/10 验证中      : apr-1.4.8-7.el7.x86_64                                            3/10 验证中      : perl-DBD-MySQL-4.023-6.el7.x86_64                                 4/10 验证中      : 1:mariadb-5.5.68-1.el7.x86_64                                     5/10 验证中      : httpd-2.4.6-99.el7.centos.1.x86_64                                6/10 验证中      : mailcap-2.1.41-2.el7.noarch                                       7/10 验证中      : apr-util-1.5.2-6.el7_9.1.x86_64                                   8/10 验证中      : 1:mariadb-libs-5.5.68-1.el7.x86_64                                9/10 验证中      : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                             10/10 已安装:httpd.x86_64 0:2.4.6-99.el7.centos.1          mariadb.x86_64 1:5.5.68-1.el7         mariadb-server.x86_64 1:5.5.68-1.el7         作为依赖被安装:apr.x86_64 0:1.4.8-7.el7                       apr-util.x86_64 0:1.5.2-6.el7_9.1    httpd-tools.x86_64 0:2.4.6-99.el7.centos.1     mailcap.noarch 0:2.1.41-2.el7        perl-DBD-MySQL.x86_64 0:4.023-6.el7           作为依赖被升级:mariadb-libs.x86_64 1:5.5.68-1.el7                                                   完毕!

2. 初始化MariaDB数据库

[root@lamp ~]# systemctl restart mariadb  # 启动MariaDB服务
[root@lamp ~]# systemctl enable mariadb  # 设置MariaDB开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@lamp ~]# mysql_secure_installation  # 运行数据库安全初始化脚本(加固数据库)NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):     #  初始密码为空:直接回车
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] Y    #  是否改root密码:输入Y
New password:          #设置密码
Re-enter new password:        #确认密码
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] y    #是否移除匿名用户,禁止未授权访问:输入`Y`... Success!Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n    #是否禁止root远程登录:输入`n`允许远程管理,按需选择... skipping.By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
输入`Y`
Remove test database and access to it? [Y/n] y    # 是否移除默认测试库输入Y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] y      #  刷新权限表:输入Y,使配置立即生效... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!
[root@lamp ~]# mysql -uroot -p       # 用 root 用户登录MariaDB
Enter password:       # 输入密码
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (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)]> exit
Bye

数据库安全配置步骤说明

3. 安装PHP及扩展

# 安装Remi仓库(提供高版本PHP)
[root@lamp ~]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
已加载插件:fastestmirror, langpacks
remi-release-7.rpm                                              |  28 kB  00:00:00     
正在检查 /var/tmp/yum-root-_zrwpI/remi-release-7.rpm: remi-release-7.9-6.el7.remi.noarch
/var/tmp/yum-root-_zrwpI/remi-release-7.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 remi-release.noarch.0.7.9-6.el7.remi 将被 安装
--> 解决依赖关系完成依赖关系解决=======================================================================================Package             架构          版本                   源                      大小
=======================================================================================
正在安装:remi-release        noarch        7.9-6.el7.remi         /remi-release-7         39 k事务概要
=======================================================================================
安装  1 软件包总计:39 k
安装大小:39 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : remi-release-7.9-6.el7.remi.noarch                                 1/1 验证中      : remi-release-7.9-6.el7.remi.noarch                                 1/1 已安装:remi-release.noarch 0:7.9-6.el7.remi                                                 完毕!# 安装yum工具(用于管理仓库)
[root@lamp ~]# yum -y install yum-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: ftp-stud.hs-esslingen.de* extras: mirrors.aliyun.com* remi-safe: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.aliyun.com
remi-safe                                                       | 3.0 kB  00:00:00     
remi-safe/primary_db                                            | 2.6 MB  00:00:01     
正在解决依赖关系
--> 正在检查事务
---> 软件包 yum-utils.noarch.0.1.1.31-50.el7 将被 升级
---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 更新
--> 解决依赖关系完成依赖关系解决=======================================================================================Package             架构             版本                        源              大小
=======================================================================================
正在更新:yum-utils           noarch           1.1.31-54.el7_8             base           122 k事务概要
=======================================================================================
升级  1 软件包总下载量:122 k
Downloading packages:
No Presto metadata available for base
yum-utils-1.1.31-54.el7_8.noarch.rpm                            | 122 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在更新    : yum-utils-1.1.31-54.el7_8.noarch                                   1/2 清理        : yum-utils-1.1.31-50.el7.noarch                                     2/2 验证中      : yum-utils-1.1.31-54.el7_8.noarch                                   1/2 验证中      : yum-utils-1.1.31-50.el7.noarch                                     2/2 更新完毕:yum-utils.noarch 0:1.1.31-54.el7_8                                                   完毕!# 启用PHP 7.0仓库
[root@lamp ~]# yum-config-manager --enable remi-php70
已加载插件:fastestmirror, langpacks
================================== repo: remi-php70 ===================================
[remi-php70]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = 
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi-php70
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage = 
enabled = 1
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/remi-php70/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/remi-php70/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
hdrdir = /var/cache/yum/x86_64/7/remi-php70/headers
http_caching = all
includepkgs = 
ip_resolve = 
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = http://cdn.remirepo.net/enterprise/7/php70/mirror
mirrorlist_expire = 86400
name = Remi's PHP 7.0 RPM repository for Enterprise Linux 7 - x86_64
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/remi-php70
pkgdir = /var/cache/yum/x86_64/7/remi-php70/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
ui_id = remi-php70
ui_repoid_vars = releasever,basearch
username = # 安装PHP及WordPress所需扩展(如图片处理、数据库连接等)
[root@lamp ~]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: mirror.math.princeton.edu* extras: mirrors.aliyun.com* remi-php70: mirrors.tuna.tsinghua.edu.cn* remi-safe: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.aliyun.com
remi-php70                                                      | 3.0 kB  00:00:00     
remi-php70/primary_db                                           | 250 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 php.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-cli.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-common.x86_64.0.7.0.33-42.el7.remi 将被 安装
--> 正在处理依赖关系 php-json(x86-64) = 7.0.33-42.el7.remi,它被软件包 php-common-7.0.33-42.el7.remi.x86_64 需要
---> 软件包 php-fpm.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-gd.x86_64.0.7.0.33-42.el7.remi 将被 安装
--> 正在处理依赖关系 libgd.so.103()(64bit),它被软件包 php-gd-7.0.33-42.el7.remi.x86_64 需要
---> 软件包 php-intl.x86_64.0.7.0.33-42.el7.remi 将被 安装
--> 正在处理依赖关系 libicudata.so.69()(64bit),它被软件包 php-intl-7.0.33-42.el7.remi.x86_64 需要
--> 正在处理依赖关系 libicui18n.so.69()(64bit),它被软件包 php-intl-7.0.33-42.el7.remi.x86_64 需要
--> 正在处理依赖关系 libicuio.so.69()(64bit),它被软件包 php-intl-7.0.33-42.el7.remi.x86_64 需要
--> 正在处理依赖关系 libicuuc.so.69()(64bit),它被软件包 php-intl-7.0.33-42.el7.remi.x86_64 需要
---> 软件包 php-mbstring.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-mysqlnd.x86_64.0.7.0.33-42.el7.remi 将被 安装
--> 正在处理依赖关系 php-pdo(x86-64) = 7.0.33-42.el7.remi,它被软件包 php-mysqlnd-7.0.33-42.el7.remi.x86_64 需要
---> 软件包 php-opcache.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-pecl-zip.x86_64.0.1.22.3-1.el7.remi.7.0 将被 安装
--> 正在处理依赖关系 libzip5(x86-64) >= 1.10.1,它被软件包 php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64 需要
--> 正在处理依赖关系 libzip.so.5()(64bit),它被软件包 php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64 需要
--> 正在检查事务
---> 软件包 gd3php.x86_64.0.2.3.3-7.el7.remi 将被 安装
--> 正在处理依赖关系 libraqm.so.0()(64bit),它被软件包 gd3php-2.3.3-7.el7.remi.x86_64 需要
--> 正在处理依赖关系 libwebp.so.7()(64bit),它被软件包 gd3php-2.3.3-7.el7.remi.x86_64 需要
---> 软件包 libicu69.x86_64.0.69.1-4.el7.remi 将被 安装
---> 软件包 libzip5.x86_64.0.1.10.1-1.el7.remi 将被 安装
--> 正在处理依赖关系 libzstd(x86-64) >= 1.3.6,它被软件包 libzip5-1.10.1-1.el7.remi.x86_64 需要
--> 正在处理依赖关系 libzstd.so.1()(64bit),它被软件包 libzip5-1.10.1-1.el7.remi.x86_64 需要
---> 软件包 php-json.x86_64.0.7.0.33-42.el7.remi 将被 安装
---> 软件包 php-pdo.x86_64.0.7.0.33-42.el7.remi 将被 安装
--> 正在检查事务
---> 软件包 libraqm.x86_64.0.0.7.0-4.el7 将被 安装
---> 软件包 libwebp7.x86_64.0.1.0.3-2.el7.remi 将被 安装
---> 软件包 libzstd.x86_64.0.1.5.5-1.el7 将被 安装
--> 解决依赖关系完成依赖关系解决=======================================================================================Package            架构         版本                           源                大小
=======================================================================================
正在安装:php                x86_64       7.0.33-42.el7.remi             remi-php70       2.6 Mphp-cli            x86_64       7.0.33-42.el7.remi             remi-php70       4.0 Mphp-common         x86_64       7.0.33-42.el7.remi             remi-php70       1.0 Mphp-fpm            x86_64       7.0.33-42.el7.remi             remi-php70       1.4 Mphp-gd             x86_64       7.0.33-42.el7.remi             remi-php70        80 kphp-intl           x86_64       7.0.33-42.el7.remi             remi-php70       222 kphp-mbstring       x86_64       7.0.33-42.el7.remi             remi-php70       580 kphp-mysqlnd        x86_64       7.0.33-42.el7.remi             remi-php70       245 kphp-opcache        x86_64       7.0.33-42.el7.remi             remi-php70       168 kphp-pecl-zip       x86_64       1.22.3-1.el7.remi.7.0          remi-php70        65 k
为依赖而安装:gd3php             x86_64       2.3.3-7.el7.remi               remi-safe        138 klibicu69           x86_64       69.1-4.el7.remi                remi-safe        9.6 Mlibraqm            x86_64       0.7.0-4.el7                    epel              15 klibwebp7           x86_64       1.0.3-2.el7.remi               remi-safe        266 klibzip5            x86_64       1.10.1-1.el7.remi              remi-safe         67 klibzstd            x86_64       1.5.5-1.el7                    epel             292 kphp-json           x86_64       7.0.33-42.el7.remi             remi-php70        68 kphp-pdo            x86_64       7.0.33-42.el7.remi             remi-php70       130 k事务概要
=======================================================================================
安装  10 软件包 (+8 依赖软件包)总下载量:21 M
安装大小:74 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/libraqm-0.7.0-4.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
libraqm-0.7.0-4.el7.x86_64.rpm 的公钥尚未安装
(1/18): libraqm-0.7.0-4.el7.x86_64.rpm                          |  15 kB  00:00:01     
警告:/var/cache/yum/x86_64/7/remi-safe/packages/gd3php-2.3.3-7.el7.remi.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 00f97f56: NOKEY
gd3php-2.3.3-7.el7.remi.x86_64.rpm 的公钥尚未安装
(2/18): gd3php-2.3.3-7.el7.remi.x86_64.rpm                      | 138 kB  00:00:01     
(3/18): libwebp7-1.0.3-2.el7.remi.x86_64.rpm                    | 266 kB  00:00:00     
(4/18): libzip5-1.10.1-1.el7.remi.x86_64.rpm                    |  67 kB  00:00:00     
(5/18): libicu69-69.1-4.el7.remi.x86_64.rpm                     | 9.6 MB  00:00:02     
php-7.0.33-42.el7.remi.x86_64.rpm 的公钥尚未安装     ] 3.8 MB/s |  13 MB  00:00:02 ETA 
(6/18): php-7.0.33-42.el7.remi.x86_64.rpm                       | 2.6 MB  00:00:01     
(7/18): php-cli-7.0.33-42.el7.remi.x86_64.rpm                   | 4.0 MB  00:00:01     
(8/18): php-common-7.0.33-42.el7.remi.x86_64.rpm                | 1.0 MB  00:00:00     
(9/18): php-gd-7.0.33-42.el7.remi.x86_64.rpm                    |  80 kB  00:00:00     
(10/18): php-intl-7.0.33-42.el7.remi.x86_64.rpm                 | 222 kB  00:00:00     
(11/18): php-fpm-7.0.33-42.el7.remi.x86_64.rpm                  | 1.4 MB  00:00:00     
(12/18): php-mbstring-7.0.33-42.el7.remi.x86_64.rpm             | 580 kB  00:00:00     
(13/18): php-mysqlnd-7.0.33-42.el7.remi.x86_64.rpm              | 245 kB  00:00:00     
(14/18): php-json-7.0.33-42.el7.remi.x86_64.rpm                 |  68 kB  00:00:00     
(15/18): php-opcache-7.0.33-42.el7.remi.x86_64.rpm              | 168 kB  00:00:00     
(16/18): php-pdo-7.0.33-42.el7.remi.x86_64.rpm                  | 130 kB  00:00:00     
(17/18): php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64.rpm          |  65 kB  00:00:00     
(18/18): libzstd-1.5.5-1.el7.x86_64.rpm                         | 292 kB  00:00:04     
---------------------------------------------------------------------------------------
总计                                                      3.5 MB/s |  21 MB  00:05     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi 检索密钥
导入 GPG key 0x00F97F56:用户ID     : "Remi Collet <RPMS@FamilleCollet.com>"指纹       : 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56软件包     : remi-release-7.9-6.el7.remi.noarch (installed)来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:用户ID     : "Fedora EPEL (7) <epel@fedoraproject.org>"指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5软件包     : epel-release-7-11.noarch (@extras)来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : php-common-7.0.33-42.el7.remi.x86_64                              1/18 正在安装    : php-json-7.0.33-42.el7.remi.x86_64                                2/18 正在安装    : php-cli-7.0.33-42.el7.remi.x86_64                                 3/18 正在安装    : php-pdo-7.0.33-42.el7.remi.x86_64                                 4/18 正在安装    : libicu69-69.1-4.el7.remi.x86_64                                   5/18 正在安装    : libwebp7-1.0.3-2.el7.remi.x86_64                                  6/18 正在安装    : libzstd-1.5.5-1.el7.x86_64                                        7/18 正在安装    : libzip5-1.10.1-1.el7.remi.x86_64                                  8/18 正在安装    : libraqm-0.7.0-4.el7.x86_64                                        9/18 正在安装    : gd3php-2.3.3-7.el7.remi.x86_64                                   10/18 正在安装    : php-gd-7.0.33-42.el7.remi.x86_64                                 11/18 正在安装    : php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64                        12/18 正在安装    : php-intl-7.0.33-42.el7.remi.x86_64                               13/18 正在安装    : php-mysqlnd-7.0.33-42.el7.remi.x86_64                            14/18 正在安装    : php-7.0.33-42.el7.remi.x86_64                                    15/18 正在安装    : php-fpm-7.0.33-42.el7.remi.x86_64                                16/18 正在安装    : php-opcache-7.0.33-42.el7.remi.x86_64                            17/18 正在安装    : php-mbstring-7.0.33-42.el7.remi.x86_64                           18/18 验证中      : php-cli-7.0.33-42.el7.remi.x86_64                                 1/18 验证中      : gd3php-2.3.3-7.el7.remi.x86_64                                    2/18 验证中      : php-fpm-7.0.33-42.el7.remi.x86_64                                 3/18 验证中      : php-opcache-7.0.33-42.el7.remi.x86_64                             4/18 验证中      : libraqm-0.7.0-4.el7.x86_64                                        5/18 验证中      : libzstd-1.5.5-1.el7.x86_64                                        6/18 验证中      : php-mbstring-7.0.33-42.el7.remi.x86_64                            7/18 验证中      : libzip5-1.10.1-1.el7.remi.x86_64                                  8/18 验证中      : php-pdo-7.0.33-42.el7.remi.x86_64                                 9/18 验证中      : php-json-7.0.33-42.el7.remi.x86_64                               10/18 验证中      : php-mysqlnd-7.0.33-42.el7.remi.x86_64                            11/18 验证中      : php-gd-7.0.33-42.el7.remi.x86_64                                 12/18 验证中      : php-7.0.33-42.el7.remi.x86_64                                    13/18 验证中      : php-intl-7.0.33-42.el7.remi.x86_64                               14/18 验证中      : libwebp7-1.0.3-2.el7.remi.x86_64                                 15/18 验证中      : libicu69-69.1-4.el7.remi.x86_64                                  16/18 验证中      : php-common-7.0.33-42.el7.remi.x86_64                             17/18 验证中      : php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64                        18/18 已安装:php.x86_64 0:7.0.33-42.el7.remi          php-cli.x86_64 0:7.0.33-42.el7.remi        php-common.x86_64 0:7.0.33-42.el7.remi   php-fpm.x86_64 0:7.0.33-42.el7.remi        php-gd.x86_64 0:7.0.33-42.el7.remi       php-intl.x86_64 0:7.0.33-42.el7.remi       php-mbstring.x86_64 0:7.0.33-42.el7.remi php-mysqlnd.x86_64 0:7.0.33-42.el7.remi    php-opcache.x86_64 0:7.0.33-42.el7.remi  php-pecl-zip.x86_64 0:1.22.3-1.el7.remi.7.0作为依赖被安装:gd3php.x86_64 0:2.3.3-7.el7.remi           libicu69.x86_64 0:69.1-4.el7.remi        libraqm.x86_64 0:0.7.0-4.el7               libwebp7.x86_64 0:1.0.3-2.el7.remi       libzip5.x86_64 0:1.10.1-1.el7.remi         libzstd.x86_64 0:1.5.5-1.el7             php-json.x86_64 0:7.0.33-42.el7.remi       php-pdo.x86_64 0:7.0.33-42.el7.remi      完毕!# 验证PHP版本(确认安装成功)
[root@lamp ~]# php -v
PHP 7.0.33 (cli) (built: Jun  5 2024 09:34:26) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologieswith Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

4. 配置PHP时区

[root@lamp ~]# vim /etc/php.ini  # 编辑PHP主配置文件# 修改时区配置为:date.timezone = Asia/Shanghai(确保时间显示正确)[root@lamp ~]# systemctl restart php-fpm  # 重启PHP进程管理器
[root@lamp ~]# systemctl enable php-fpm  # 设置php-fpm开机自启

三、配置Apache服务

1. 设置默认网页

[root@lamp ~]# vim /etc/httpd/conf/httpd.conf  # 编辑Apache主配置文件# 找到<IfModule dir_module>部分,修改为:<IfModule dir_module>DirectoryIndex index.html index.php  # 加载index.php 、 index网页文件
</IfModule>

2. 创建PHP测试页面

[root@lamp ~]# vim /var/www/html/index.php  # 创建PHP信息测试页# 添加以下内容(用于验证PHP是否正常运行):<?phpphpinfo();  # 输出PHP配置信息
?>[root@lamp ~]# systemctl restart httpd  # 重启Apache使配置生效
[root@lamp ~]# systemctl enable httpd  # 设置Apache开机自启

测试说明:浏览器访问服务器IP(如http://192.168.100.20),若显示PHP版本、模块等信息,说明LAMP架构正常。

在这里插入图片描述

四、部署WordPress

1. 准备安装包(从本地上传)

[root@lamp ~]# yum -y install lrzsz  # 安装文件上传工具(支持从本地向服务器上传文件)
[root@lamp ~]# mkdir /opt/software  # 创建存放软件包的目录
[root@lamp ~]# cd /opt/software  # 进入软件目录
[root@lamp software]# rz  # 执行后选择本地的wordpress-6.5.5.tar.gz文件上传

2. 解压并部署文件

[root@lamp software]# yum -y install tar  # 安装解压工具(若未安装)
[root@lamp software]# tar -zxvf wordpress-6.5.5.tar.gz  # 解压WordPress压缩包
[root@lamp software]# cp -R wordpress /var/www/html/  # 将解压后的文件复制到Apache网站根目录(供浏览器访问)

3. 配置目录权限

[root@lamp software]# chown -R apache.apache /var/www/html/wordpress/  # 将目录所有者所有组改为Apache用户Apache组(确保网站可读写)
[root@lamp software]# chmod -R 775 /var/www/html/wordpress/  # 设置权限:所有者和组有读写执行权,其他用户有读执行权

4. 创建WordPress数据库及用户

[root@lamp software]# mysql -u root -p  # 登录MariaDB(-u指定用户,-p提示输入密码)
# 输入密码redhat(之前设置的数据库root密码)MariaDB [(none)]> create database wordpress_db;  # 创建名为wordpress_db的数据库
MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by 'redhat';  # 创建本地用户wordpress_user,密码redhat
MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';  # 授权该用户管理wordpress_db数据库
MariaDB [(none)]> flush privileges;  # 刷新权限表(使授权生效)
MariaDB [(none)]> exit  # 退出数据库[root@lamp software]# mysql -u root -p  # 登录MariaDB(-u指定用户,-p提示输入密码)
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (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_db;    # 创建名为wordpress_db的数据库
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> create user'wordpress_user'@'localhost' identified by 'redhat';  # 创建本地用户wordpress_user,密码redhat
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';# 授权该用户管理wordpress_db数据库
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush privileges;  # 刷新权限表(使授权生效)MariaDB [(none)]> show databases;   #查看数据库列表
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress_db       |
+--------------------+
4 rows in set (0.00 sec)MariaDB [(none)]> exit    # 退出数据库
Bye

5. 配置虚拟主机

[root@lamp software]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/  # 复制虚拟主机配置模板到Apache配置目录
[root@lamp software]# vim /etc/httpd/conf.d/httpd-vhosts.conf  # 编辑虚拟主机配置
# 添加以下内容(指定WordPress网站目录和访问权限):
````ba
<VirtualHost 192.168.100.20:80>  # 绑定服务器IP和80端口DocumentRoot "/var/www/html/wordpress"  # 网站根目录<Directory "/var/www/html/wordpress">  # 目录权限配置Options Indexes FollowSymLinks  # 允许目录索引和跟随符号链接AllowOverride all  # 允许.htaccess文件覆盖配置(WordPress固定链接需要)Require all granted  # 允许所有用户访问</Directory>
</VirtualHost>[root@lamp software]# systemctl restart httpd  # 重启Apache使虚拟主机配置生效

五、完成WordPress安装

  1. 浏览器访问服务器IP(如http://192.168.100.20),按向导完成:
    • 选择语言(如“中文(简体)”)
    • 输入数据库信息(前文创建的数据库名、用户名、密码)
    • 填写网站基本信息(站点标题、管理员账号密码等)
  2. 点击“安装WordPress”,完成后使用管理员账号登录后台(http://IP/wp-admin

至此,WordPress部署完成,可通过前台访问网站或后台管理内容。

在这里插入图片描述

http://www.dtcms.com/a/337109.html

相关文章:

  • 制作全流程对比:侗家灰水粽VS布依族草灰粽的8道工序差异
  • 大厂 | 华为半导体业务部2026届秋招启动
  • scikit-learn/sklearn学习|弹性网络ElasticNet解读
  • 机器学习-决策树:从原理到实战的机器学习入门指南
  • 大模型的底层运算线性代数
  • 实现自学习系统,输入excel文件,能学习后进行相应回答
  • 香港服务器是否支持RAID磁盘阵列?
  • RTSP 播放器 vs RTMP 播放器:延迟对比与技术实践
  • HAProxy使用方法以及和LVS区别
  • 【数据库】Navicat 导入 Excel 数据乱码问题的解决方法
  • NY291NY297美光固态闪存NY298NY303
  • Jina Embeddings:高性能多模态向量模型的演进之路
  • Minitab AI 加持的头脑风暴法,破解企业改进难题
  • 驱动开发系列64 - glCompileShader实现之 GLSL normalize 精度优化
  • Linux 中断机制深度分析
  • SpatialLLM,SpatialReasoner,SpatialLM论文解读
  • 云原生事件驱动引擎(RocketMQ-EventBridge)应用场景与技术解析
  • 01数据结构-交换排序
  • 【EI会议征稿通知】第五届高性能计算、大数据与通信工程国际学术会议(ICHBC 2025)
  • 蓝桥杯算法之搜索章 - 6
  • LeetCode热题100--226. 翻转二叉树--简单
  • SSH 登录失败(publickey)问题总结
  • 【具身智能】2025:具身智能机器人量产元年——AI与物理世界的融合革命
  • UE TCP通信
  • FTP服务器
  • 【Python面试题】写一个用元类(metaclass)实现API接口自动注册的Demo。以及装饰器在项目中典型应用场景。
  • Unity进阶--C#补充知识点--【Unity跨平台的原理】Mono与IL2CPP
  • 继承中的向上转型、向下转型与动态绑定的深入解析
  • 【案例分享】AI使用分享|如何运用 GPT完成小任务并提升效率 —— Prompt 与案例整理
  • 跨平台笔记协作:cpolar 提升 Obsidian 知识库共享效率方案