安装 WordPress 于 Linux (阿尔玛Linux)提供了易用性、定制选项、安全性和社区支持的强大组合。 对于寻求在线业务的个人和企业来说,这是一个重要的选择。 这 知识库文章 向您展示如何安装 WordPress Linux – 特别是 AlmaLinux。
查看所有产品
流体网 托管可以由您来完成 WordPress 网站 优于其他网络托管提供商。 我们的 网络托管博客 可以帮助您将精彩的内容集成到您的网站页面中。
安装 WordPress 的步骤 Linux (阿尔玛Linux)
学习安装 WordPress 的要求 Linux
- 操作系统:AlmaLinux OS 8。
- 系统权限: 用那个 sudo 以 root 身份运行命令 或一个 具有管理权限的用户登录AlmaLinux 8系统。
您可以按照下一节中的步骤在其上安装 WordPress Linux (阿尔玛Linux)。
第1步:更新DNF仓库缓存
系统更新命令为 丹化百胜 (DNF) 可以设置一个新的系统存储库缓存,其中包含仍可在系统存储库中安装的更新的软件包列表:
sudo dnf update
第 2 步:安装 Apache AlmaLinux 上的 HTTPd
通过其中之一创建 WordPress 网站 Browser 要通过本地或 Internet 网络进行交付,需要 Web 服务器。 你可以安装它 Apache HTTP服务器 通过运行以下命令:
sudo dnf install httpd -y
您可以运行以下命令来启动它 httpd 服务并将其配置为在启动时运行:
sudo systemctl start httpd
sudo systemctl enable httpd
要检查httpd服务的状态,可以运行以下命令:
sudo systemctl status httpd
这是输出:
~]# sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-08-28 03:08:33 UTC; 10s ago
Docs: man:httpd.service(8)
Main PID: 22773 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 11968)
Memory: 28.3M
CGroup: /system.slice/httpd.service
├─22773 /usr/sbin/httpd -DFOREGROUND
├─22774 /usr/sbin/httpd -DFOREGROUND
├─22775 /usr/sbin/httpd -DFOREGROUND
├─22776 /usr/sbin/httpd -DFOREGROUND
└─22777 /usr/sbin/httpd -DFOREGROUND
如果存在以下情况,请运行以下命令启用 HTTP 和 HTTPS 服务: 防火墙 配置为:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo systemctl reload firewalld
您可以通过以下方式检查一切是否正常工作 https://您的服务器IP地址 或者 https://您的域名.com。 如果一切设置正确,您也应该如此 受到标准的欢迎 Apache 页 为您 的版本 Apache httpd服务。
第 3 步:安装 MariaDB 数据库服务器
你可以 安装 MariaDB 通过运行以下命令:
sudo dnf install mariadb-server mariadb
您可以运行以下命令来启动它 MariaDB 服务并将其配置为在启动时运行:
sudo systemctl start mariadb
sudo systemctl enable mariadb
检查状态 MariaDB 服务,您可以运行以下命令:
sudo systemctl status mariadb
这是输出:
~]# sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-08-28 03:13:17 UTC; 43s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 26464 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 11968)
Memory: 84.0M
CGroup: /system.slice/mariadb.service
└─26464 /usr/libexec/mysqld --basedir=/usr
MariaDB 默认情况下安装并不安全。 运行以下命令来备份您的 MariaDB 安装数据库软件后的服务器。 这 该命令启动一系列安全配置 改善您的保护 MariaDB 安装:
sudo mysql_secure_installation
这是输出:
~]# sudo 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] Y
... Success!
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!
为了使更改生效,您必须重新启动数据库服务:
sudo systemctl restart mariadb
第 4 步:安装 PHP 和 PHP 扩展
截至撰写本文时,AlmaLinux 存储库中可用的 PHP 版本是 7.2,WordPress 不支持该版本。 到 安装 PHP 8.1你必须用那个 Remis RPM 存储库其中缩写“RPM”代表 RPM 软件包管理器或 Red Hat 软件包管理器 (RPM)。 但请注意,添加外部存储库可能会给系统稳定性和安全性带来风险。 我们建议对您添加的任何存储库进行彻底研究并谨慎行事。
要安装 为公司提供的附加套餐 Linux (EPEL) 发布,运行以下命令:
sudo dnf install epel-release
要补充的是 雷米存储库运行以下命令:
sudsudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
运行以下命令来更新存储库:
sudo dnf update
运行以下命令将 PHP 模块重置为默认状态:
sudo dnf module reset php
要激活 remi PHP 8.1 模块,请运行以下命令:
sudo dnf module enable php:remi-8.1
运行以下命令安装 PHP 和其他支持包:
sudo dnf install psudo dnf install php php-curl php-bcmath php-gd php-soap php-zip php-mbstring php-mysqlnd php-xml php-intl php-zip
要检查安装的 PHP 版本,请运行以下命令:
php -v
这是输出:
~]# php -v
PHP 8.1.22 (cli) (built: Aug 1 2023 16:16:09) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.22, Copyright (c) Zend Technologies
with Zend OPcache v8.1.22, Copyright (c), by Zend Technologies
步骤5:创建数据库和数据库用户
登录 MariaDB 袖子,运行以下命令。 然后你会被要求输入 MariaDB 根密码:
sudo mysql -u root -p
执行以下命令创建数据库和数据库用户。 代替 数据库密码 与一个 强而安全的密码:
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'DB_password';
然后执行以下命令,为数据库用户授予和删除所有权限:
GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
您还可以更换 wordpress_数据库 和 wordpress_用户 与您的数据库详细信息。
离开这个 MySQL 在命令提示符中,运行以下命令:
exit
这是输出:
~]# sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 8
Server version: 10.3.35-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_db;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'DB_password';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit
Bye
你也可以参考这篇文章 如何在AlmaLinux上安装LAMP堆栈 关于安装的详细信息 全灯(Linux, ApacheMySQLPHP) 堆栈 在AlmaLinux上。 了解如何安装 WordPress Linux 如果没有 LAMP 信息,(AlmaLinux)将是不完整的知识。
第 6 步:下载 WordPress
默认存储库不包含 WordPress。 我们需要手动下载最新版本的WordPress 官方 WordPress 网站。 这一步在学习如何安装WordPress的过程中是必要的 Linux (阿尔玛Linux),
要下载 WordPress,请运行以下命令:
sudo wget https://wordpress.org/latest.tar.gz
这是输出:
~]# sudo wget https://wordpress.org/latest.tar.gz
--2023-08-28 03:49:40-- https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.253
Connecting to wordpress.org (wordpress.org)|198.143.164.253|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23445410 (22M) [application/octet-stream]
Saving to: 'latest.tar.gz'
latest.tar.gz 100%[=====================================================================================>] 22.36M 52.8MB/s in 0.4s
2023-08-28 03:49:41 (52.8 MB/s) - 'latest.tar.gz' saved [23445410/23445410]
第 7 步:配置并安装 WordPress
下载 WordPress 后,运行以下命令来解压文件:
sudo tar -xvzf latest.tar.gz
要将文件移动到 Web根目录运行以下命令:
sudo mv wordpress/* /var/www/html/
运行以下命令以授予 Apache 用户对移动文件夹的读写权限:
sudo chown -R apache:apache /var/www/html/
提高安全性 Linux (SELinux) 有时会导致特定的权限问题。 因此,您需要运行以下命令:
sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R
要在 SELinux 中正确应用更新,请运行以下命令:
sudo restorecon -Rv /var/www/html/
然后你需要创建一个 Apache 虚拟主机配置文件 对于WordPress。 您可以通过运行以下命令来执行此操作:
vi /etc/httpd/conf.d/wordpress.conf
按 使用 i 键盘快捷键在 Vi 编辑器中进入插入模式,对文件进行更改并添加以下详细信息。 您必须将占位符详细信息替换为与您的设置匹配的值:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/your-domain.com_error.log
CustomLog /var/log/httpd/your-domain.com_access.log combined
</VirtualHost>
完成所有更改后,按 在 Vi 编辑器中使用 Esc 组合键退出插入模式。 然后按 单击 :wq 键盘快捷键保存更改并退出 Vi 编辑器。 下一个, 重新启动这个 Apache 通过执行服务 输入以下命令以反映更改:
sudo systemctl restart httpd
您还可以通过阅读文章使用 WP-CLI 命令快速安装 WordPress 使用 WP-CLI 安装 WordPress。 如果你的服务器有一个 cPanel 或 Plesk 控制面板您可以使用 软性 或者 可湿性粉剂工具包 为您的域安装 WordPress 的工具。
第8步:让我们开始吧! WordPress 安装向导
最后,打开网络浏览器并输入域名,例如 https://您的服务器IP地址 或者 https://您的域名.com 您安装 WordPress 的服务器。 然后点击“让我们开始吧!”。 开始按钮:
Enter 您创建的数据库详细信息。 然后点击“发送”按钮:
您可以通过单击“运行安装”按钮开始 WordPress 安装:
输入所需的详细信息,然后单击“安装 WordPress”按钮:
WordPress 安装完成后,您可以输入 WordPress 管理员用户名和密码。 要访问 WordPress 管理面板选择窗口中显示的“登录”选项:

在出现的页面上,您将看到 WordPress 管理面板仪表板:

WordPress 管理面板通常通过 URL 访问 your-domain.com/wp-admin。 您还可以根据需要自定义 WordPress 管理面板 URL。 例如,这是一个最佳实践 限制对 WordPress 管理面板的访问。
恭喜您成功学习如何安装WordPress Linux (阿尔玛Linux)。 现在你已经准备好了 使用 WordPress 创建出色的网站!
如何卸载 WordPress Linux (阿尔玛Linux)
学习如何安装 WordPress 后 Linux 在AlmaLinux上完成安装后,您可能需要从系统中删除WordPress。 让我们了解如何执行卸载。
转到 WordPress 文件所在的目录。 这通常是您网站的根目录,通常位于 /var/www/html 或类似的方式。 然后删除所有 WordPress 文件和文件夹:
sudo rm -r /var/www/html/*
使用命令行或 类似 phpMyAdmin 的工具 访问您的数据库。 删除 WordPress 数据库时,值 wordpress_数据库 显示在 example 以下应替换为您实际数据库的名称:
DROP DATABASE wordpress_db;
然后删除 WordPress 网站的虚拟主机设置 /etc/httpd/conf.d/wordpress.conf:
sudo systemctl restart httpd
完成所有更改后,重新启动 Apache 服务反映变化:
sudo systemctl restart httpd
使用 Liquid Web 托管您的 WordPress 网站
我们希望您已经学会如何安装 WordPress Linux (AlmaLinux) 在本文的帮助下。 通过选择,您可以受益于无忧的托管、优化的性能和安全的环境 Liquid Web 为您的 WordPress 网站提供的托管计划 在AlmaLinux上。
获取 VPS 托管
通过选择正确的托管计划,您可以腾出更多时间专注于向受众提供卓越的内容和体验。 您在 AlmaLinux 上运行的 WordPress 网站将获得蓬勃发展所需的关注,因为 Liquid Web 作为值得信赖的托管公司享有盛誉。 接收有关我们的信息 各种托管服务如果您想特别关注与您的 WordPress 托管需求相关的功能、澄清任何问题或做出明智的决定,您可以联系我们的专家。
与我们聊天