Centos7使用lamp架构部署wordpress

Centos7使用lamp架构部署wordpress

1、修改主机名(没有强制性要求改):

复制代码
[root@syf ~]# hostnamectl set-hostname lamp.example.com
[root@syf ~]# bash
[root@lamp ~]# 

2、关闭防火墙和selinux:

复制代码
[root@lamp ~]# systemctl stop firewalld
[root@lamp ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@lamp ~]# vim /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled      //改成disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


~                                                             
~   

重启:

复制代码
[root@lamp ~]# reboot

3、时钟同步服务器(同步CentOS官方服务器):

复制代码
[root@lamp ~]# rpm -q chrony 
chrony-3.2-2.el7.x86_64
[root@lamp ~]# vim /etc/chrony.conf   //没做修改,只需要服务启一下
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst   //CentOS官方时钟服务器
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
...
[root@lamp ~]# systemctl restart chronyd
[root@lamp ~]# systemctl enable chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
[root@lamp ~]# hwclock -w
[root@lamp ~]# timedatectl 
      Local time: Mon 2025-08-18 15:31:31 CST
  Universal time: Mon 2025-08-18 07:31:31 UTC
        RTC time: Mon 2025-08-18 07:31:31
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes     ////
 RTC in local TZ: no
      DST active: n/a

4、配置yum源:(阿里源镜像站中CentOS镜像)

复制代码
[root@lamp ~]# cd /etc/yum.repos.d/
[root@lamp yum.repos.d]# ls
CentOS-Base.repo       CentOS-Media.repo
CentOS-CR.repo         CentOS-Sources.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo
CentOS-fasttrack.repo
[root@lamp yum.repos.d]# rm -rf *
[root@lamp yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo   //CentOS 7镜像  https://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-18 15:38:22--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 116.207.180.59, 119.84.54.2, 119.84.54.233
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|116.207.180.59|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: '/etc/yum.repos.d/CentOS-Base.repo'

100%[====================>] 2,523       --.-K/s   in 0s      

2025-08-18 15:38:22 (404 MB/s) - '/etc/yum.repos.d/CentOS-Base.repo' saved [2523/2523]

[root@lamp yum.repos.d]# ls
CentOS-Base.repo
[root@lamp yum.repos.d]# yum -y install epel-release
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                   | 3.6 kB     00:00     
extras                                 | 2.9 kB     00:00     
updates                                | 2.9 kB     00:00     
(1/4): base/7/x86_64/group_gz            | 153 kB   00:00     
(2/4): extras/7/x86_64/primary_db        | 253 kB   00:00     
(3/4): updates/7/x86_64/primary_db       |  27 MB   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"
Trying other mirror.
(4/4): base/7/x86_64/primary_db          | 6.1 MB   00:00     
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package           Arch        Version      Repository   Size
==============================================================
Installing:
 epel-release      noarch      7-11         extras       15 k

Transaction Summary
==============================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm             |  15 kB   00:00     
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                   1/1 
  Verifying  : epel-release-7-11.noarch                   1/1 

Installed:
  epel-release.noarch 0:7-11                                  

Complete!
[root@lamp yum.repos.d]# ls
CentOS-Base.repo  epel.repo  epel-testing.repo

5、安装httpd和mariadb数据库:

复制代码
[root@lamp ~]# yum -y install httpd mariadb-server mariadb
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                   | 4.4 kB     00:00     
 * base: mirrors.aliyun.com
 * epel: mirror.math.princeton.edu
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel                                   | 4.3 kB     00:00     
(1/3): epel/x86_64/group                 | 399 kB   00:13     
(2/3): epel/x86_64/updateinfo            | 1.0 MB   01:17     
(3/3): epel/x86_64/primary_db            | 8.7 MB   08:08     
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-5.5.68-1.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7_9.1 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be updated
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be an update
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package        Arch   Version                  Repository
                                                         Size
==============================================================
Installing:
 httpd          x86_64 2.4.6-99.el7.centos.1    updates 2.7 M
 mariadb        x86_64 1:5.5.68-1.el7           base    8.8 M
 mariadb-server x86_64 1:5.5.68-1.el7           base     11 M
Installing for dependencies:
 apr            x86_64 1.4.8-7.el7              base    104 k
 apr-util       x86_64 1.5.2-6.el7_9.1          updates  92 k
 httpd-tools    x86_64 2.4.6-99.el7.centos.1    updates  94 k
 mailcap        noarch 2.1.41-2.el7             base     31 k
 perl-DBD-MySQL x86_64 4.023-6.el7              base    140 k
Updating for dependencies:
 mariadb-libs   x86_64 1:5.5.68-1.el7           base    760 k

Transaction Summary
==============================================================
Install  3 Packages (+5 Dependent packages)
Upgrade             ( 1 Dependent package)

Total download size: 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     
(2/9): apr-util-1.5.2-6.el7_9.1.x86_64.r |  92 kB   00:00     
(3/9): httpd-tools-2.4.6-99.el7.centos.1 |  94 kB   00:00     
(4/9): httpd-2.4.6-99.el7.centos.1.x86_6 | 2.7 MB   00:00     
(5/9): mailcap-2.1.41-2.el7.noarch.rpm   |  31 kB   00:00     
(6/9): mariadb-libs-5.5.68-1.el7.x86_64. | 760 kB   00:00     
(7/9): mariadb-5.5.68-1.el7.x86_64.rpm   | 8.8 MB   00:00     
(8/9): perl-DBD-MySQL-4.023-6.el7.x86_64 | 140 kB   00:00     
(9/9): mariadb-server-5.5.68-1.el7.x86_6 |  11 MB   00:00     
--------------------------------------------------------------
Total                             24 MB/s |  24 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:mariadb-libs-5.5.68-1.el7.x86_64        1/10 
  Installing : apr-1.4.8-7.el7.x86_64                    2/10 
  Installing : apr-util-1.5.2-6.el7_9.1.x86_64           3/10 
  Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_    4/10 
  Installing : perl-DBD-MySQL-4.023-6.el7.x86_64         5/10 
  Installing : 1:mariadb-5.5.68-1.el7.x86_64             6/10 
  Installing : mailcap-2.1.41-2.el7.noarch               7/10 
  Installing : httpd-2.4.6-99.el7.centos.1.x86_64        8/10 
  Installing : 1:mariadb-server-5.5.68-1.el7.x86_64      9/10 
  Cleanup    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64     10/10 
  Verifying  : httpd-tools-2.4.6-99.el7.centos.1.x86_    1/10 
  Verifying  : 1:mariadb-server-5.5.68-1.el7.x86_64      2/10 
  Verifying  : apr-1.4.8-7.el7.x86_64                    3/10 
  Verifying  : perl-DBD-MySQL-4.023-6.el7.x86_64         4/10 
  Verifying  : 1:mariadb-5.5.68-1.el7.x86_64             5/10 
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64        6/10 
  Verifying  : mailcap-2.1.41-2.el7.noarch               7/10 
  Verifying  : apr-util-1.5.2-6.el7_9.1.x86_64           8/10 
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64        9/10 
  Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64     10/10 

Installed:
  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                        

Dependency Installed:
  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                         

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.68-1.el7                          

Complete!
[root@lamp ~]# systemctl restart mariadb
[root@lamp ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

6、初始化数据库:

复制代码
[root@lamp ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS 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    //是否设置数据库用户密码
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     //是否移除匿名用户
 ... 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         //是否允许匿名用户远程登陆
 ... 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.

Remove test database and access to it? [Y/n] 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        //是否重新加载权限列表
 ... 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!

7、测试登陆数据库:

复制代码
[root@lamp ~]# mysql -uroot -p 
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 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)]> exit
Bye

8、安装php:

复制代码
[root@lamp ~]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Loaded plugins: fastestmirror, langpacks
remi-release-7.rpm                     |  28 kB     00:00     
Examining /var/tmp/yum-root-HeHI0q/remi-release-7.rpm: remi-release-7.9-6.el7.remi.noarch
Marking /var/tmp/yum-root-HeHI0q/remi-release-7.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package remi-release.noarch 0:7.9-6.el7.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package       Arch    Version         Repository        Size
==============================================================
Installing:
 remi-release  noarch  7.9-6.el7.remi  /remi-release-7   39 k

Transaction Summary
==============================================================
Install  1 Package

Total size: 39 k
Installed size: 39 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : remi-release-7.9-6.el7.remi.noarch         1/1 
  Verifying  : remi-release-7.9-6.el7.remi.noarch         1/1 

Installed:
  remi-release.noarch 0:7.9-6.el7.remi                        

Complete!
[root@lamp ~]# cd /etc/yum.repos.d/
[root@lamp yum.repos.d]# ls
CentOS-Base.repo   remi-php71.repo  remi-php82.repo
epel.repo          remi-php72.repo  remi-php83.repo
epel-testing.repo  remi-php73.repo  remi.repo
remi-modular.repo  remi-php74.repo  remi-safe.repo
remi-php54.repo    remi-php80.repo
remi-php70.repo    remi-php81.repo
[root@lamp yum.repos.d]# yum -y install yum-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror.math.princeton.edu
 * extras: mirrors.aliyun.com
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.aliyun.com
remi-safe                              | 3.0 kB     00:00     
remi-safe/primary_db                     | 2.6 MB   00:01     
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package       Arch       Version              Repository
                                                         Size
==============================================================
Updating:
 yum-utils     noarch     1.1.31-54.el7_8      base     122 k

Transaction Summary
==============================================================
Upgrade  1 Package

Total download size: 122 k
Downloading packages:
No Presto metadata available for base
yum-utils-1.1.31-54.el7_8.noarch.rpm     | 122 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : yum-utils-1.1.31-54.el7_8.noarch           1/2 
  Cleanup    : yum-utils-1.1.31-50.el7.noarch             2/2 
  Verifying  : yum-utils-1.1.31-54.el7_8.noarch           1/2 
  Verifying  : yum-utils-1.1.31-50.el7.noarch             2/2 

Updated:
  yum-utils.noarch 0:1.1.31-54.el7_8                          

Complete!
[root@lamp yum.repos.d]# yum-config-manager --enable remi-php70
Loaded plugins: 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 = 

[root@lamp yum.repos.d]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: pubmirror1.math.uh.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     
remi-php70/primary_db                    | 250 kB   00:01     
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-cli.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-common.x86_64 0:7.0.33-42.el7.remi will be installed
--> Processing Dependency: php-json(x86-64) = 7.0.33-42.el7.remi for package: php-common-7.0.33-42.el7.remi.x86_64
---> Package php-fpm.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-gd.x86_64 0:7.0.33-42.el7.remi will be installed
--> Processing Dependency: libgd.so.103()(64bit) for package: php-gd-7.0.33-42.el7.remi.x86_64
---> Package php-intl.x86_64 0:7.0.33-42.el7.remi will be installed
--> Processing Dependency: libicudata.so.69()(64bit) for package: php-intl-7.0.33-42.el7.remi.x86_64
--> Processing Dependency: libicui18n.so.69()(64bit) for package: php-intl-7.0.33-42.el7.remi.x86_64
--> Processing Dependency: libicuio.so.69()(64bit) for package: php-intl-7.0.33-42.el7.remi.x86_64
--> Processing Dependency: libicuuc.so.69()(64bit) for package: php-intl-7.0.33-42.el7.remi.x86_64
---> Package php-mbstring.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-mysqlnd.x86_64 0:7.0.33-42.el7.remi will be installed
--> Processing Dependency: php-pdo(x86-64) = 7.0.33-42.el7.remi for package: php-mysqlnd-7.0.33-42.el7.remi.x86_64
---> Package php-opcache.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-pecl-zip.x86_64 0:1.22.3-1.el7.remi.7.0 will be installed
--> Processing Dependency: libzip5(x86-64) >= 1.10.1 for package: php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64
--> Processing Dependency: libzip.so.5()(64bit) for package: php-pecl-zip-1.22.3-1.el7.remi.7.0.x86_64
--> Running transaction check
---> Package gd3php.x86_64 0:2.3.3-7.el7.remi will be installed
--> Processing Dependency: libraqm.so.0()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libwebp.so.7()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
---> Package libicu69.x86_64 0:69.1-4.el7.remi will be installed
---> Package libzip5.x86_64 0:1.10.1-1.el7.remi will be installed
--> Processing Dependency: libzstd(x86-64) >= 1.3.6 for package: libzip5-1.10.1-1.el7.remi.x86_64
--> Processing Dependency: libzstd.so.1()(64bit) for package: libzip5-1.10.1-1.el7.remi.x86_64
---> Package php-json.x86_64 0:7.0.33-42.el7.remi will be installed
---> Package php-pdo.x86_64 0:7.0.33-42.el7.remi will be installed
--> Running transaction check
---> Package libraqm.x86_64 0:0.7.0-4.el7 will be installed
---> Package libwebp7.x86_64 0:1.0.3-2.el7.remi will be installed
---> Package libzstd.x86_64 0:1.5.5-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package      Arch   Version                 Repository  Size
==============================================================
Installing:
 php          x86_64 7.0.33-42.el7.remi      remi-php70 2.6 M
 php-cli      x86_64 7.0.33-42.el7.remi      remi-php70 4.0 M
 php-common   x86_64 7.0.33-42.el7.remi      remi-php70 1.0 M
 php-fpm      x86_64 7.0.33-42.el7.remi      remi-php70 1.4 M
 php-gd       x86_64 7.0.33-42.el7.remi      remi-php70  80 k
 php-intl     x86_64 7.0.33-42.el7.remi      remi-php70 222 k
 php-mbstring x86_64 7.0.33-42.el7.remi      remi-php70 580 k
 php-mysqlnd  x86_64 7.0.33-42.el7.remi      remi-php70 245 k
 php-opcache  x86_64 7.0.33-42.el7.remi      remi-php70 168 k
 php-pecl-zip x86_64 1.22.3-1.el7.remi.7.0   remi-php70  65 k
Installing for dependencies:
 gd3php       x86_64 2.3.3-7.el7.remi        remi-safe  138 k
 libicu69     x86_64 69.1-4.el7.remi         remi-safe  9.6 M
 libraqm      x86_64 0.7.0-4.el7             epel        15 k
 libwebp7     x86_64 1.0.3-2.el7.remi        remi-safe  266 k
 libzip5      x86_64 1.10.1-1.el7.remi       remi-safe   67 k
 libzstd      x86_64 1.5.5-1.el7             epel       292 k
 php-json     x86_64 7.0.33-42.el7.remi      remi-php70  68 k
 php-pdo      x86_64 7.0.33-42.el7.remi      remi-php70 130 k

Transaction Summary
==============================================================
Install  10 Packages (+8 Dependent packages)

Total download size: 21 M
Installed size: 74 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/remi-safe/packages/gd3php-2.3.3-7.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Public key for gd3php-2.3.3-7.el7.remi.x86_64.rpm is not installed
(1/18): gd3php-2.3.3-7.el7.remi.x86_64.r | 138 kB   00:01     
warning: /var/cache/yum/x86_64/7/epel/packages/libraqm-0.7.0-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for libraqm-0.7.0-4.el7.x86_64.rpm is not installed
(2/18): libraqm-0.7.0-4.el7.x86_64.rpm   |  15 kB   00:01     
(3/18): libwebp7-1.0.3-2.el7.remi.x86_64 | 266 kB   00:03     
Public key for php-7.0.33-42.el7.remi.x86_64.rpm is not installed
(4/18): php-7.0.33-42.el7.remi.x86_64.rp | 2.6 MB   00:01     
(5/18): php-common-7.0.33-42.el7.remi.x8 | 1.0 MB   00:01     
(6/18): libzip5-1.10.1-1.el7.remi.x86_64 |  67 kB   00:05     
(7/18): php-cli-7.0.33-42.el7.remi.x86_6 | 4.0 MB   00:03     
(8/18): php-intl-7.0.33-42.el7.remi.x86_ | 222 kB   00:00     
(9/18): php-json-7.0.33-42.el7.remi.x86_ |  68 kB   00:00     
(10/18): php-mbstring-7.0.33-42.el7.remi | 580 kB   00:00     
(11/18): php-mysqlnd-7.0.33-42.el7.remi. | 245 kB   00:00     
(12/18): php-opcache-7.0.33-42.el7.remi. | 168 kB   00:00     
(13/18): php-pdo-7.0.33-42.el7.remi.x86_ | 130 kB   00:00     
(14/18): php-pecl-zip-1.22.3-1.el7.remi. |  65 kB   00:00     
(15/18): php-gd-7.0.33-42.el7.remi.x86_6 |  80 kB   00:04     
(16/18): libicu69-69.1-4.el7.remi.x86_64 | 9.6 MB   00:10     
(17/18): php-fpm-7.0.33-42.el7.remi.x86_ | 1.4 MB   00:11     
(18/18): libzstd-1.5.5-1.el7.x86_64.rpm  | 292 kB   00:22     
--------------------------------------------------------------
Total                            885 kB/s |  21 MB  00:24     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
 Userid     : "Remi Collet <RPMS@FamilleCollet.com>"
 Fingerprint: 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56
 Package    : remi-release-7.9-6.el7.remi.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : php-common-7.0.33-42.el7.remi.x86_64      1/18 
  Installing : php-json-7.0.33-42.el7.remi.x86_64        2/18 
  Installing : php-cli-7.0.33-42.el7.remi.x86_64         3/18 
  Installing : php-pdo-7.0.33-42.el7.remi.x86_64         4/18 
  Installing : libicu69-69.1-4.el7.remi.x86_64           5/18 
  Installing : libwebp7-1.0.3-2.el7.remi.x86_64          6/18 
  Installing : libzstd-1.5.5-1.el7.x86_64                7/18 
  Installing : libzip5-1.10.1-1.el7.remi.x86_64          8/18 
  Installing : libraqm-0.7.0-4.el7.x86_64                9/18 
  Installing : gd3php-2.3.3-7.el7.remi.x86_64           10/18 
  Installing : php-gd-7.0.33-42.el7.remi.x86_64         11/18 
  Installing : php-pecl-zip-1.22.3-1.el7.remi.7.0.x86   12/18 
  Installing : php-intl-7.0.33-42.el7.remi.x86_64       13/18 
  Installing : php-mysqlnd-7.0.33-42.el7.remi.x86_64    14/18 
  Installing : php-7.0.33-42.el7.remi.x86_64            15/18 
  Installing : php-fpm-7.0.33-42.el7.remi.x86_64        16/18 
  Installing : php-opcache-7.0.33-42.el7.remi.x86_64    17/18 
  Installing : php-mbstring-7.0.33-42.el7.remi.x86_64   18/18 
  Verifying  : php-cli-7.0.33-42.el7.remi.x86_64         1/18 
  Verifying  : gd3php-2.3.3-7.el7.remi.x86_64            2/18 
  Verifying  : php-fpm-7.0.33-42.el7.remi.x86_64         3/18 
  Verifying  : php-opcache-7.0.33-42.el7.remi.x86_64     4/18 
  Verifying  : libraqm-0.7.0-4.el7.x86_64                5/18 
  Verifying  : libzstd-1.5.5-1.el7.x86_64                6/18 
  Verifying  : php-mbstring-7.0.33-42.el7.remi.x86_64    7/18 
  Verifying  : libzip5-1.10.1-1.el7.remi.x86_64          8/18 
  Verifying  : php-pdo-7.0.33-42.el7.remi.x86_64         9/18 
  Verifying  : php-json-7.0.33-42.el7.remi.x86_64       10/18 
  Verifying  : php-mysqlnd-7.0.33-42.el7.remi.x86_64    11/18 
  Verifying  : php-gd-7.0.33-42.el7.remi.x86_64         12/18 
  Verifying  : php-7.0.33-42.el7.remi.x86_64            13/18 
  Verifying  : php-intl-7.0.33-42.el7.remi.x86_64       14/18 
  Verifying  : libwebp7-1.0.3-2.el7.remi.x86_64         15/18 
  Verifying  : libicu69-69.1-4.el7.remi.x86_64          16/18 
  Verifying  : php-common-7.0.33-42.el7.remi.x86_64     17/18 
  Verifying  : php-pecl-zip-1.22.3-1.el7.remi.7.0.x86   18/18 

Installed:
  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                 

Dependency Installed:
  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                         

Complete!
[root@lamp yum.repos.d]# php -v    //版本7.0
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 Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

9、配置php,将时区改成亚洲/上海:

复制代码
[root@lamp ~]# timedatectl 
      Local time: Mon 2025-08-18 16:54:23 CST
  Universal time: Mon 2025-08-18 08:54:23 UTC
        RTC time: Mon 2025-08-18 08:54:24
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
[root@lamp ~]# vim /etc/php.ini
...
/date.time   //查找时区

...
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai   //改成亚洲/上海,前面分号去掉
...
[root@lamp ~]# systemctl restart php-fpm
[root@lamp ~]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

10、配置默认网页:

复制代码
[root@lamp ~]# vim /etc/httpd/conf/httpd.conf 
...
/index     //查找index

...
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php    //指定php
</IfModule>
...
[root@lamp ~]# cd /var/www/html/
[root@lamp html]# ls
[root@lamp html]# vim index.php
<?php
        phpinfo();    //php测试网页,访问出来的是详细信息
?>
~                                                             
~                     
[root@lamp html]# systemctl restart httpd
[root@lamp html]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@lamp html]# ss -anlt
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128    127.0.0.1:9000                *:*    //php端口9000               
LISTEN     0      50      *:3306                *:*                  
LISTEN     0      128     *:111                 *:*                  
LISTEN     0      128     *:6000                *:*                  
LISTEN     0      5      192.168.122.1:53                  *:*                  
LISTEN     0      128     *:22                  *:*                  
LISTEN     0      128    127.0.0.1:631                 *:*                  
LISTEN     0      100    127.0.0.1:25                  *:*                  
LISTEN     0      128    127.0.0.1:6010                *:*                  
LISTEN     0      128    :::111                :::*                  
LISTEN     0      128    :::80                 :::*        //http端口80            
LISTEN     0      128    :::6000               :::*                  
LISTEN     0      128    :::22                 :::*                  
LISTEN     0      128       ::1:631                :::*                  
LISTEN     0      100       ::1:25                 :::*                  
LISTEN     0      128       ::1:6010               :::*                  
[root@lamp html]# systemctl restart php-fpm

11、测试访问 lamp 基础架构:

12、将 wordpress 压缩包上传到服务器当前的工作目录下(不限制上传位置):

复制代码
[root@lamp ~]# ls
anaconda-ks.cfg  Downloads             Pictures   Videos
Desktop          initial-setup-ks.cfg  Public
Documents        Music                 Templates
[root@lamp ~]# rz -E
rz waiting to receive.
[root@lamp ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  Templates
Desktop          Music                 Videos
Documents        Pictures              wordpress-6.5.5.tar.gz
Downloads        Public

13、解压 wordpress 压缩包:

复制代码
[root@lamp ~]# tar -xvzf wordpress-6.5.5.tar.gz 
wordpress/
wordpress/xmlrpc.php
wordpress/wp-blog-header.php
wordpress/readme.html
wordpress/wp-signup.php
......
[root@lamp ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  Templates
Desktop          Music                 Videos
Documents        Pictures              wordpress
Downloads        Public                wordpress-6.5.5.tar.gz
[root@lamp ~]# cp -r wordpress /var/www/html/

14、设置 wordpress 的权限:

复制代码
[root@lamp ~]# cd /var/www/html/
[root@lamp html]# ls
index.php  wordpress
[root@lamp html]# ll
total 8
-rw-r--r-- 1 root root   21 Aug 18 18:04 index.php
drwxr-xr-x 5 root root 4096 Aug 18 18:23 wordpress
[root@lamp html]# chown -R apache.apache wordpress/
[root@lamp html]# ll
total 8
-rw-r--r-- 1 root   root     21 Aug 18 18:04 index.php
drwxr-xr-x 5 apache apache 4096 Aug 18 18:23 wordpress
[root@lamp html]# ll wordpress/
total 228
-rw-r--r--  1 apache apache   405 Aug 18 18:23 index.php
-rw-r--r--  1 apache apache 19915 Aug 18 18:23 license.txt
-rw-r--r--  1 apache apache  7401 Aug 18 18:23 readme.html
-rw-r--r--  1 apache apache  7387 Aug 18 18:23 wp-activate.php
drwxr-xr-x  9 apache apache  4096 Aug 18 18:23 wp-admin
-rw-r--r--  1 apache apache   351 Aug 18 18:23 wp-blog-header.php
-rw-r--r--  1 apache apache  2323 Aug 18 18:23 wp-comments-post.php
-rw-r--r--  1 apache apache  3012 Aug 18 18:23 wp-config-sample.php
drwxr-xr-x  4 apache apache    52 Aug 18 18:23 wp-content
-rw-r--r--  1 apache apache  5638 Aug 18 18:23 wp-cron.php
drwxr-xr-x 30 apache apache 12288 Aug 18 18:23 wp-includes
-rw-r--r--  1 apache apache  2502 Aug 18 18:23 wp-links-opml.php
-rw-r--r--  1 apache apache  3927 Aug 18 18:23 wp-load.php
-rw-r--r--  1 apache apache 50917 Aug 18 18:23 wp-login.php
-rw-r--r--  1 apache apache  8525 Aug 18 18:23 wp-mail.php
-rw-r--r--  1 apache apache 28427 Aug 18 18:23 wp-settings.php
-rw-r--r--  1 apache apache 34385 Aug 18 18:23 wp-signup.php
-rw-r--r--  1 apache apache  4885 Aug 18 18:23 wp-trackback.php
-rw-r--r--  1 apache apache  3246 Aug 18 18:23 xmlrpc.php
[root@lamp html]# chmod -R 775 wordpress/

15、为 wordpress 配置数据库:

复制代码
[root@lamp html]# mysql -uroot -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 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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> create database wordpress_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress_db       |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 

16、为 wordpress 配置站点:

复制代码
[root@lamp ~]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/
[root@lamp ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
...
<VirtualHost 192.168.100.10:80>
    DocumentRoot "/var/www/html/wordpress"
    <Directory "/var/www/html/wordpress">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
</VirtualHost>

~                                                             
~   

17、重启 apache 服务:

复制代码
[root@lamp ~]# systemctl restart httpd

18、使用浏览器访问 wordpress 站点: