操作环境

  • 硬件:华为云服务器
  • 操作系统:Rocky Linux 9.0 64bit
  • 服务器软件:nginx 1.24.0,php 8.2.6,openssl 3.0.7,MySQL 8.0.33

前提条件

  • nginx已安装好,并开启SSL
  • PHP已安装好
  • MySQL已安装好

相关说明

安装前请注意检查待安装的WordPress版本与PHP版本和MySQL版本的兼容性。

## 要运行WordPress,请确保您的主机支持:

此版本。我们推荐ApacheNginx作为运行WordPress的最可靠和功能最强的服务器,但任何支持PHP和MySQL的服务器都可运行。尽管如此,我们无法测试所有可能的环境,但我们主机页面上的每个主机服务都毫无问题的支持上述环境。

详情请参见:
系统要求 | WordPress.org China 简体中文

建议安装最新版本的nginx、openssl、PHP、MySQL和WordPress,目前上述软件的最新版本如下:

  • nginx最新版本为1.24.0。
  • openssl最新版本为 3.0.8。(我的yum源里openssl最新版本是3.0.7)
  • php最新版本为8.2.6。
  • MySQL最新版本为 8.0.33。
  • WordPress最新版本为6.2.2。

操作步骤

1.从WordPress官网下载最新版本安装包

下载地址为:

建议直接下载 tar.gz包,方便在linux服务器上用tar解压缩。

方式一:本地windows终端下载并上传

  • 使用windows终端下载上述软件包,在下载目录下会新建wordpress-6.2.2-zh_CN.tar.gz文件。
  • 将下载的文件上传云服务器相关目录(可以在MobaXterm_Personal中通过SFTP上传),建议是nginx安装目录的html子目录。

方式二:在云服务器上直接下载。

下载完成后,会得到wordpress-6.2.2-zh_CN.tar.gz文件。

2.用tar解压缩下载的软件包

软件包解压缩后,会在当前目录(html)下得到wordpress的文件夹。

3.创建wordpress数据库及登录用户名和密码

方式一:在windows终端使用MySQL Workbench 8.0软件

略。

方式二:在linux服务器上使用命令行方式

(1)连接mysql,并查看user数据。
(2)新建用户wordpress,注意将命令中的 User-WordPress-PW-1234替换为自己设置的密码。
(3)查看并新建数据库 wordpress

首先,使用指令 show databases检查是否存在wordpress数据库,如没有,则用以下指令创建它: create database wordpress

(4)为数据库用户wordpress赋予访问数据库wordpress的所有权限。

指令如下: grant all on wordpress.* to 'wordpress'@'%';

4.用浏览器访问/wordpress/wp-admin/install.php

假定我们在前期nginx安装时已设置html为root目录(系统默认设置),在浏览器网址输入:wslibai.com/wordpress/wp-admin/install.php即可启动wordpress配置界面。(请注意将网站域名替换为你自己的域名或主机IP地址)



因安装过程未截屏保留相关信息,以上三张图片取自下文:WordPress搭建教程:手把手教你搭建WordPress博客 – 知乎,特此申明。不告而取,实属无礼。若有冒犯,还请海涵。如有侵权,告知即删。

按屏幕提示信息输入相关信息,即可进入下一步配置界面(5分钟安装程序)。

如安装过程出现问题,比如 不能选择数据库等错误,请参考[[Linux WordPress 不能选择数据库问题]],也可参考以下著名的5分钟安装说明,手动复制和修改 wp-config.php文件,即可解决问题。

Installation: Famous 5-minute install

  1. Unzip the package in an empty directory and upload everything.
  2. Open wp-admin/install.php in your browser. It will take you through the process to set up a  wp-config.php file with your database connection details.
  3. If for some reason this does not work, do not worry. It may not work on all web hosts. Open up  wp-config-sample.php with a text editor like WordPad or similar and fill in your database connection details.
  4. Save the file as  wp-config.php and upload it.
  5. Open wp-admin/install.php in your browser.
  6. Once the configuration file is set up, the installer will set up the tables needed for your site. If there is an error, double check your  wp-config.php file, and try again. If it fails again, please go to the WordPress support forums with as much data as you can gather.
  7. If you did not enter a password, note the password given to you. If you did not provide a username, it will be  admin.
  8. The installer should then send you to the login page. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on “Profile” to change the password.

5.使用5分钟安装程序完成安装

在5分钟安装程序表单内,填写好相关信息,点击屏幕左下方的 安装WordPress按钮。

6.登录后台管理界面

稍等一会,就进入了登录界面,输入上一步设置的用户名和密码即可登录wordpress后台管理界面。

至此,WordPress安装已经完成,现在,你可以通过管理界面安装插件、配置主题、发布文章,开启你的博主生活了。

但仍需进行一些优化配置,才能确保网站的性能保持最佳。更多信息,请查看[[WordPress网站优化]]。