华为云服务器搭建基于LNMP部署wordpress

Ubuntu系统搭建过程目录

  • 一、检查环境
  • 三、安装Nginx
    • [3.1 下载并解压nginx](#3.1 下载并解压nginx)
    • [3.2. 编译安装](#3.2. 编译安装)
    • [3.3 启动和停止和测试](#3.3 启动和停止和测试)
    • [3.4 创建服务脚本](#3.4 创建服务脚本)
    • [3.5 Nginx目录](#3.5 Nginx目录)
  • 四、安装Mysql
    • [4.1 安全安装配置](#4.1 安全安装配置)
    • [4.2 修改权限和密码](#4.2 修改权限和密码)
    • [4.3 重启MySQL服务](#4.3 重启MySQL服务)
  • 五、安装PHP
    • [5.1 测试](#5.1 测试)
    • 截图
  • 五、下载并安装wordpress以及配置
    • [5.1 下载并解压移动](#5.1 下载并解压移动)
    • [5.2 创建wordpress数据库以及wordpress用户](#5.2 创建wordpress数据库以及wordpress用户)
    • [5.3 重启Apache和mysql](#5.3 重启Apache和mysql)

Wordpress推荐 PHP 8.0+ 以及 MySQL 版本 8.0+

更新系统 apt update

一、检查环境

1.1 检查是否安装Nginx

bash 复制代码
[root@huaweiyun:~]# nginx -v

1.2 检查是否安装Mysql

bash 复制代码
[root@huaweiyun:~]# mysql --version

1.3 检查是否安装PHP

bash 复制代码
[root@huaweiyun:~]# php -v

二、更新软件包以及安装所需要的依赖

bash 复制代码
# 先安装需要的依赖,gcc
# openssl需要在应用中启用 HTTPS 支持或实现数据加密时会用到
# libssl-dev 在编译支持 HTTPS 或加密功能的软件(如 Nginx 或 Apache)时需要该库
# libpcre3运行库,于支持复杂的文本匹配逻辑,例如 Nginx 的 rewrite 规则
# libpcre3-dev在编译 Nginx 等需要正则匹配功能的软件时使用
# zlib1g-devZlib 的开发头文件和静态库,场景: Nginx 使用它来支持 HTTP 压缩(gzip 压缩)
# libgd-dev如果 Nginx 或其他应用需要支持图片处理或生成缩略图功能时,会依赖该库
# 
[root@huaweiyun ~/downloads] # apt update && apt -y install gcc make libpcre3 libpcre3-dev openssl libssl-dev zlib1g-dev wget curl vim libgd3 

三、安装Nginx

3.1 下载并解压nginx

官网 https://nginx.org/en/download.html

bash 复制代码
# 创建用户和组
[root@huaweiyun ~] # useradd -s /sbin/nologin nginx
[root@huaweiyun ~] # mkdir downloads
[root@huaweiyun ~] # cd downloads/
[root@huaweiyun ~/downloads] # wget https://nginx.org/download/nginx-1.26.2.tar.gz
[root@huaweiyun ~/downloads] # tar -xvzf nginx-1.26.2.tar.gz
[root@huaweiyun ~/downloads] # ll
total 1228
drwxr-xr-x 3 root root     4096 Dec 14 11:06 ./
drwx------ 5 root root     4096 Dec 14 11:06 ../
drwxr-xr-x 8  502 staff    4096 Aug 13 00:39 nginx-1.26.2/
-rw-r--r-- 1 root root  1244789 Aug 13 00:39 nginx-1.26.2.tar.gz
[root@huaweiyun ~/downloads/nginx-1.26.2] # ll
total 860
drwxr-xr-x 8  502 staff   4096 Aug 13 00:39 ./
drwxr-xr-x 3 root root    4096 Dec 14 11:06 ../
drwxr-xr-x 6  502 staff   4096 Dec 14 11:06 auto/
-rw-r--r-- 1  502 staff 327851 Aug 13 00:39 CHANGES
-rw-r--r-- 1  502 staff 501527 Aug 13 00:39 CHANGES.ru
drwxr-xr-x 2  502 staff   4096 Dec 14 11:06 conf/
-rwxr-xr-x 1  502 staff   2611 Aug 12 22:28 configure*
drwxr-xr-x 4  502 staff   4096 Dec 14 11:06 contrib/
drwxr-xr-x 2  502 staff   4096 Dec 14 11:06 html/
-rw-r--r-- 1  502 staff   1397 Aug 12 22:28 LICENSE
drwxr-xr-x 2  502 staff   4096 Dec 14 11:06 man/
-rw-r--r-- 1  502 staff     49 Aug 12 22:28 README
drwxr-xr-x 9  502 staff   4096 Aug 13 00:39 src/

3.2. 编译安装

bash 复制代码
[root@huaweiyun ~/downloads/nginx-1.26.2] # ./configure --prefix=/env/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
[root@huaweiyun ~/downloads/nginx-1.26.2] # make && make install
# 修改权限
[root@huaweiyun  ~/downloads/nginx-1.26.2] # chown -R nginx.nginx /env/nginx
[root@huaweiyun  ~/downloads/nginx-1.26.2] # ll /env/nginx/
total 24
drwxr-xr-x  6 root root 4096 Dec 14 11:28 ./
drwxr-xr-x 14 root root 4096 Dec 14 11:11 ../
drwxr-xr-x  2 root root 4096 Dec 14 11:28 conf/
drwxr-xr-x  2 root root 4096 Dec 14 11:28 html/
drwxr-xr-x  2 root root 4096 Dec 14 11:28 logs/
drwxr-xr-x  2 root root 4096 Dec 14 11:28 sbin/
[root@huaweiyun /env/nginx/] # ls /env/nginx/sbin/
nginx
[root@huaweiyun /env/nginx/] # ln -s /env/nginx/sbin/nginx /usr/sbin/
#查看版本
[root@huaweiyun /env/nginx/sbin/] # nginx -v
nginx version: nginx/1.26.2
# 查看编译参数
[root@huaweiyun /env/nginx/sbin/] # nginx -V

3.3 启动和停止和测试

bash 复制代码
# 启动nginx
[root@huaweiyun /usr/local/nginx] # nginx
# 浏览器可以访问看到下面图示
[root@huaweiyun /usr/local/nginx] # ss -ntl
LISTEN    0         511                0.0.0.0:80                 0.0.0.0:* 
# 关闭nginx
[root@huaweiyun /usr/local/nginx] # nginx -s stop
[root@huaweiyun /usr/local/nginx] # ss -ntl

./nginx 启动

./nginx-S stop 快速停止

./nginx-Squit 优雅关闭,在退出前完成已经接受的连接请求

./nginx-sreload 重新加载配置

3.4 创建服务脚本

bash 复制代码
# vi /lib/systemd/system/nginx.service,添加并保存以下内容
[Unit]
# 该服务为 Nginx Web 服务器
Description=nginx - high performance web server   
# 
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target 

[Service]
# 该服务是一个后台运行的守护进程
Type=forking

#指定pid文件的目录,默认在logs目录下,可选配置
PIDFile=/env/nginx/run/nginx.pid

# 启动 Nginx,并指定配置文件路径为 /usr/local/nginx/conf/nginx.conf
ExecStart=/env/nginx/sbin/nginx -c /env/nginx/conf/nginx.conf

# 重新加载 Nginx 的配置,而不需要停止服务
ExecReload=/bin/kill -s HUP $MAINPID

# 停止 Nginx 服务(强制终止进程)
ExecStop=/bin/kill -s TERM $MAINPID

LimitNOFILE=100000

# 在启动服务之前执行 nginx -t 命令,测试配置文件的正确性
ExecStartPre=/env/nginx/sbin/nginx -t


[Install]
# 指定服务在多用户目标(系统正常运行的典型运行级别)下启用
WantedBy=multi-user.target

# 创建pid文件存放的目录
[root@huaweiyun /usr/local/nginx] # mkdir /env/nginx/run/
[root@huaweiyun /usr/local/nginx] # vim /env/nginx/run/nginx.pid
进程号
# 修改配置文件
[root@huaweiyun /usr/local/nginx] # vim /env/nginx/conf/nginx.conf
pid   /env/nginx/run/nginx.pid;

# 重新加载
[root@huaweiyun /usr/local/nginx] # systemctl daemon-reload
[root@huaweiyun /usr/local/nginx] # systemctl enable --now nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service

[root@huaweiyun /usr/local/nginx] # ll /apps/nginx/run/
total 4
-rw-r--r-- 1 root root 5 Sep 22 13:01 nginx.pid

[root@huaweiyun /usr/local/nginx] # ss -ntl 


[root@huaweiyun /usr/local/nginx] # systemctl stop nginx
[root@huaweiyun /usr/local/nginx] # systemctl status nginx
[root@huaweiyun /usr/local/nginx] # ss -ntl 

systemctl enable nginx 开机自启

3.5 Nginx目录


nginx.conf

日志文件

四、安装Mysql

bash 复制代码
[root@huaweiyun ~]# apt -y install mysql-server-8.0 php8.2-mysql 
[root@huaweiyun:~]# mysql --version

4.1 安全安装配置

bash 复制代码
[root@huaweiyun:~]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?  # 是否检查并设置密码的强度    yes  or  no ,这边建议选yes

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8     # 低长度>= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters    # 支持数字、混合大小写和特殊字符
STRONG Length >= 8, numeric, mixed case, special characters and dictionary   # 数字,混合大小写,特殊字符和字典文件
file

# 0  1   2 分别代表LOW,MEDIUM ,STRONG
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

# 默认情况下使用auth_socket跳过为root设置的密码作为身份验证。如果您希望使用密码身份验证,可以使用"ALTER_USER"命令。
Skipping password set for root as authentication with auth_socket is used by default.
If you would like to use password authentication instead, this can be done with the "ALTER_USER" command.
See https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management for more information.

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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.

# 禁止root用户远程登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

4.2 修改权限和密码

# 进入mysql
[root@huaweiyun:~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.40-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 选择mysql数据库
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
# 查询MySQL中root用户的用户名、允许登录的主机和认证插件
mysql> SELECT user, host, plugin FROM user WHERE user='root';
+------+-----------+-------------+
| user | host      | plugin      |
+------+-----------+-------------+
| root | localhost | auth_socket |
+------+-----------+-------------+
1 row in set (0.00 sec)
# 如果plugin列显示为auth_socket,则需要将其更改为mysql_native_password
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root'; 
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

# 再次查询
mysql> SELECT user, host, plugin, authentication_string FROM mysql.user WHERE user='root';
+------+-----------+-----------------------+-----------------------+
| user | host      | plugin                | authentication_string |
+------+-----------+-----------------------+-----------------------+
| root | localhost | mysql_native_password |                       |
+------+-----------+-----------------------+-----------------------+
1 row in set (0.00 sec)

# 修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '你自己的数据库密码';
# 刷新权限
mysql> FLUSH PRIVILEGES;
mysql> exit
Bye

4.3 重启MySQL服务

bash 复制代码
[root@huaweiyun:~]# systemctl restart mysql

五、安装PHP

bash 复制代码
# 添加 PHP PPA
[root@huaweiyun ~] # apt update
# 设置php安装源安装php
[root@huaweiyun ~] # add-apt-repository ppa:ondrej/php -y
#输入之后会出现Press [ENTER] to continue or Ctrl-c to cancel.按回车就好
[root@huaweiyun ~] # apt install php8.2 php8.2-fpm php8.2-mysql -y
[root@huaweiyun ~] # php -v         #检查php版本
# 启动 PHP-FPM 服务
[root@huaweiyun ~] # systemctl list-units --type=service | grep php
[root@huaweiyun ~] # systemctl start php8.2-fpm
[root@huaweiyun ~] # systemctl enable php8.2-fpm
[root@huaweiyun ~] # systemctl status php8.2-fpm

5.1 测试

bash 复制代码
[root@huaweiyun:~]# cd /data/www/wordpress/
[root@huaweiyun:/data/www/wordpress/]# ls
index.html
[root@huaweiyun:/data/www/wordpress/]# vim info.php
[root@huaweiyun:/data/www/wordpress/]# cat info.php 
<?
    phpinfo();
>

截图

五、下载并安装wordpress以及配置

5.1 下载并解压移动

官网下载 https://cn.wordpress.org/download/releases/

bash 复制代码
server {
        listen 80 ;
        listen [::]:80 ;
 
        # listen 443 ssl http2;
        # listen [::]:443 ssl http2;
        root /var/www/html/wordpress;
    
        index index.php index.html index.htm index.nginx-debian.html;
    
        server_name localhost;
    
        location / {
                try_files $uri $uri/ =404;
        }
    
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php-fpm.sock;
        }
    
        location ~ /\.ht {
                deny all;
        }
 
}
bash 复制代码
[root@huaweiyun:~/downloads]# wget https://cn.wordpress.org/wordpress-6.7.1-zh_CN.tar.gz                        # 下载
--2024-12-07 14:26:41--  https://cn.wordpress.org/wordpress-6.7.1-zh_CN.tar.gz
Resolving cn.wordpress.org (cn.wordpress.org)... 198.143.164.252
Connecting to cn.wordpress.org (cn.wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 33984315 (32M) [application/octet-stream]
Saving to: 'wordpress-6.7.1-zh_CN.tar.gz'

wordpress-6.7.1-zh_CN.tar.gz            100%[============================================================================>]  32.41M   689KB/s    in 78s     

2024-12-07 14:28:02 (428 KB/s) - 'wordpress-6.7.1-zh_CN.tar.gz' saved [33984315/33984315]

[root@huaweiyun:~/downloads]# ll
total 33196
drwxr-xr-x 2 root root     4096 Dec  7 14:26 ./
drwx------ 6 root root     4096 Dec  7 14:29 ../
-rw-r--r-- 1 root root 33984315 Nov 24 19:00 wordpress-6.7.1-zh_CN.tar.gz
[root@huaweiyun:~/downloads]# tar -zxvf wordpress-6.7.1-zh_CN.tar.gz     # 解压
[root@huaweiyun:~/downloads]# ll
total 33200
drwxr-xr-x 3 root root     4096 Dec  7 14:40 ./
drwx------ 6 root root     4096 Dec  7 14:29 ../
drwxr-xr-x 5 1006 1006     4096 Nov 24 19:00 wordpress/
-rw-r--r-- 1 root root 33984315 Nov 24 19:00 wordpress-6.7.1-zh_CN.tar.gz

[root@huaweiyun:~/downloads]# cd wordpress/
[root@huaweiyun:~/downloads/wordpress]# ll
total 244
drwxr-xr-x  5 1006 1006  4096 Nov 24 19:00 ./
drwxr-xr-x  3 root root  4096 Dec  7 14:40 ../
-rw-r--r--  1 1006 1006   405 Feb  6  2020 index.php
-rw-r--r--  1 1006 1006 19915 Jan  1  2024 license.txt
-rw-r--r--  1 1006 1006  7409 Jun 18 19:59 readme.html
-rw-r--r--  1 1006 1006  7387 Feb 13  2024 wp-activate.php
drwxr-xr-x  9 1006 1006  4096 Nov 24 19:00 wp-admin/
-rw-r--r--  1 1006 1006   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 1006 1006  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--  1 1006 1006  3336 Oct 15 23:24 wp-config-sample.php
drwxr-xr-x  5 1006 1006  4096 Nov 24 19:00 wp-content/
-rw-r--r--  1 1006 1006  5617 Aug  3 03:40 wp-cron.php
drwxr-xr-x 30 1006 1006 16384 Nov 24 19:00 wp-includes/
-rw-r--r--  1 1006 1006  2502 Nov 27  2022 wp-links-opml.php
-rw-r--r--  1 1006 1006  3937 Mar 11  2024 wp-load.php
-rw-r--r--  1 1006 1006 51367 Oct  1 03:12 wp-login.php
-rw-r--r--  1 1006 1006  8543 Sep 19 06:37 wp-mail.php
-rw-r--r--  1 1006 1006 29032 Oct  1 01:08 wp-settings.php
-rw-r--r--  1 1006 1006 34385 Jun 20  2023 wp-signup.php
-rw-r--r--  1 1006 1006  5102 Oct 18 23:56 wp-trackback.php
-rw-r--r--  1 1006 1006  3246 Mar  2  2024 xmlrpc.php
# 将 wordpress目录下的文件移动到/var/www/html目录下
[root@huaweiyun:~/downloads/wordpress]# mv * /var/www/html/
[root@huaweiyun:~/downloads/wordpress]# ll /var/www/html
total 260
drwxr-xr-x  5 root root  4096 Dec  7 14:51 ./
drwxr-xr-x  3 root root  4096 Dec  3 12:26 ../
-rw-r--r--  1 root root 10918 Dec  3 12:26 index.html
-rw-r--r--  1 1006 1006   405 Feb  6  2020 index.php
-rw-r--r--  1 root root    20 Dec  7 14:29 info.php
-rw-r--r--  1 1006 1006 19915 Jan  1  2024 license.txt
-rw-r--r--  1 1006 1006  7409 Jun 18 19:59 readme.html
-rw-r--r--  1 1006 1006  7387 Feb 13  2024 wp-activate.php
drwxr-xr-x  9 1006 1006  4096 Nov 24 19:00 wp-admin/
-rw-r--r--  1 1006 1006   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 1006 1006  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--  1 1006 1006  3336 Oct 15 23:24 wp-config-sample.php
drwxr-xr-x  5 1006 1006  4096 Nov 24 19:00 wp-content/
-rw-r--r--  1 1006 1006  5617 Aug  3 03:40 wp-cron.php
drwxr-xr-x 30 1006 1006 16384 Nov 24 19:00 wp-includes/
-rw-r--r--  1 1006 1006  2502 Nov 27  2022 wp-links-opml.php
-rw-r--r--  1 1006 1006  3937 Mar 11  2024 wp-load.php
-rw-r--r--  1 1006 1006 51367 Oct  1 03:12 wp-login.php
-rw-r--r--  1 1006 1006  8543 Sep 19 06:37 wp-mail.php
-rw-r--r--  1 1006 1006 29032 Oct  1 01:08 wp-settings.php
-rw-r--r--  1 1006 1006 34385 Jun 20  2023 wp-signup.php
-rw-r--r--  1 1006 1006  5102 Oct 18 23:56 wp-trackback.php
-rw-r--r--  1 1006 1006  3246 Mar  2  2024 xmlrpc.php

# 将/var/www/html/下面所有者修改为www-data
[root@huaweiyun:/var/www/html]# chown -R www-data.www-data /var/www/html
[root@huaweiyun:/var/www/html]# ll
total 260
drwxr-xr-x  5 www-data www-data  4096 Dec  7 14:51 ./
drwxr-xr-x  3 root     root      4096 Dec  3 12:26 ../
-rw-r--r--  1 www-data www-data 10918 Dec  3 12:26 index.html
-rw-r--r--  1 www-data www-data   405 Feb  6  2020 index.php
-rw-r--r--  1 www-data www-data    20 Dec  7 14:29 info.php
-rw-r--r--  1 www-data www-data 19915 Jan  1  2024 license.txt
-rw-r--r--  1 www-data www-data  7409 Jun 18 19:59 readme.html
-rw-r--r--  1 www-data www-data  7387 Feb 13  2024 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Nov 24 19:00 wp-admin/
-rw-r--r--  1 www-data www-data   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 www-data www-data  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--  1 www-data www-data  3336 Oct 15 23:24 wp-config-sample.php
drwxr-xr-x  5 www-data www-data  4096 Nov 24 19:00 wp-content/
-rw-r--r--  1 www-data www-data  5617 Aug  3 03:40 wp-cron.php
drwxr-xr-x 30 www-data www-data 16384 Nov 24 19:00 wp-includes/
-rw-r--r--  1 www-data www-data  2502 Nov 27  2022 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3937 Mar 11  2024 wp-load.php
-rw-r--r--  1 www-data www-data 51367 Oct  1 03:12 wp-login.php
-rw-r--r--  1 www-data www-data  8543 Sep 19 06:37 wp-mail.php
-rw-r--r--  1 www-data www-data 29032 Oct  1 01:08 wp-settings.php
-rw-r--r--  1 www-data www-data 34385 Jun 20  2023 wp-signup.php
-rw-r--r--  1 www-data www-data  5102 Oct 18 23:56 wp-trackback.php
-rw-r--r--  1 www-data www-data  3246 Mar  2  2024 xmlrpc.php

# 赋予文件的执行权限
[root@huaweiyun:/var/www/html]# chmod -R 755 /var/www/html
[root@huaweiyun:/var/www/html]# ll
total 260
drwxr-xr-x  5 www-data www-data  4096 Dec  7 14:51 ./
drwxr-xr-x  3 root     root      4096 Dec  3 12:26 ../
-rwxr-xr-x  1 www-data www-data 10918 Dec  3 12:26 index.html*
-rwxr-xr-x  1 www-data www-data   405 Feb  6  2020 index.php*
-rwxr-xr-x  1 www-data www-data    20 Dec  7 14:29 info.php*
-rwxr-xr-x  1 www-data www-data 19915 Jan  1  2024 license.txt*
-rwxr-xr-x  1 www-data www-data  7409 Jun 18 19:59 readme.html*
-rwxr-xr-x  1 www-data www-data  7387 Feb 13  2024 wp-activate.php*
drwxr-xr-x  9 www-data www-data  4096 Nov 24 19:00 wp-admin/
-rwxr-xr-x  1 www-data www-data   351 Feb  6  2020 wp-blog-header.php*
-rwxr-xr-x  1 www-data www-data  2323 Jun 14  2023 wp-comments-post.php*
-rwxr-xr-x  1 www-data www-data  3336 Oct 15 23:24 wp-config-sample.php*
drwxr-xr-x  5 www-data www-data  4096 Nov 24 19:00 wp-content/
-rwxr-xr-x  1 www-data www-data  5617 Aug  3 03:40 wp-cron.php*
drwxr-xr-x 30 www-data www-data 16384 Nov 24 19:00 wp-includes/
-rwxr-xr-x  1 www-data www-data  2502 Nov 27  2022 wp-links-opml.php*
-rwxr-xr-x  1 www-data www-data  3937 Mar 11  2024 wp-load.php*
-rwxr-xr-x  1 www-data www-data 51367 Oct  1 03:12 wp-login.php*
-rwxr-xr-x  1 www-data www-data  8543 Sep 19 06:37 wp-mail.php*
-rwxr-xr-x  1 www-data www-data 29032 Oct  1 01:08 wp-settings.php*
-rwxr-xr-x  1 www-data www-data 34385 Jun 20  2023 wp-signup.php*
-rwxr-xr-x  1 www-data www-data  5102 Oct 18 23:56 wp-trackback.php*
-rwxr-xr-x  1 www-data www-data  3246 Mar  2  2024 xmlrpc.php*

5.2 创建wordpress数据库以及wordpress用户

bash 复制代码
[root@huaweiyun:~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.40-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 创建数据库
mysql> create database wordpress;
Query OK, 1 row affected (0.01 sec)
# 创建wordpress数据库管理员
mysql> CREATE USER 'wordpressUser'@'localhost' IDENTIFIED BY '数据库密码';
Query OK, 0 rows affected (0.01 sec)
# 给wordpress创建一个账号,方便管理wordpress数据库,并输入密码
mysql> grant all privileges on wordpress.* to 'wordpressuser'@'localhost' with grant option;
Query OK, 0 rows affected (0.01 sec)
# 刷新权限,配置生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

5.3 重启Apache和mysql

bash 复制代码
[root@huaweiyun:~]# systemctl restart nginx
[root@huaweiyun:~]# systemctl restart mysql

1、输入域名或者ip,会出现以下页面,点击现在开始

2、输入数据库名、用户名以及密码(这里的输入的信息要与上面安装数据库时的信息一致)

3、接下来,会出现这个画面

找到这个文件,并打开

bash 复制代码
[root@huaweiyun:/var/www/html]# vim wp-config-sample.php

这里需要把手动创建文件wp-config.php

不然就会出现以下问题

bash 复制代码
[root@huaweiyun:/var/www/html/wordpress]# vim wp-config.php
[root@huaweiyun:/var/www/html/wordpress]# chown www-data.www-data wp-config.php
[root@huaweiyun:/var/www/html/wordpress]# chmod -R 755 wp-config.php
bash 复制代码
[root@huaweiyun:~]# systemctl restart mysql     # 重启数据库
[root@huaweiyun:~]# systemctl restart apache2     # 重启数据库

4、重启服务刷新页面之后,就安装成功了,设置账号密码等等

随后,可以自己在网上寻找主题,以下链接可以找找
https://blog.csdn.net/feiying0canglang/article/details/129671505

换主题操作文档https://www.yuque.com/applek/corepress/setup

相关推荐
MC皮蛋侠客37 分钟前
sqlalchemy异步方法使用
python·mysql
鳄鱼皮坡1 小时前
【linux系统】基础开发工具(yum、Vim)
linux·c++·ubuntu
qq_377572771 小时前
vim save
linux·vim
运维小文1 小时前
vim优化
linux·编辑器·vim
潇洒哥Kahn1 小时前
docker启动mysql 8.1
mysql·docker·容器
VVVVWeiYee1 小时前
新华三预赛考前突击
linux·服务器·网络·数据库·信息与通信
nn_302 小时前
UOS AI 2.0 发布,开启原生 AIOS 时代!
linux·运维·服务器·人工智能·科技
白羊@2 小时前
多模块应用、发布使用第三方库(持续更新中)
服务器·前端·网络·harmonyos·鸿蒙·openharmony·第三方库
阿哈832 小时前
Z240001 基于Java+MySQL+SpringBoot+Vue实现的酒店管理系统的设计与实现
java·spring boot·mysql
shelby_loo2 小时前
在 Ubuntu 下通过 Docker 部署 Samba 服务器
服务器·ubuntu·docker