一、安装LNMP环境

1.修改主机名

[root@samba ~]# hostnamectl set-hostname lnmp [root@samba ~]# hostnamectl Static hostname: lnmp Icon name: computer-vm Chassis: vm Machine ID: 06c97bdf0e6c4a89898aa7d58c6be2cc Boot ID: b05f421c261c4a26b5e5d5b67566c826 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64 [root@samba ~]# bash

2.将提供的软件包上传到虚拟机的/root目录下

lnmp1.6-full.tar.gz和wordpress-4.7.3-zh_CN.zip
image.png

3.解压完成后,执行安装脚本

[root@lnmp ~]# cd lnmp1.6-full [root@lnmp lnmp1.6-full]# ./install.sh

安装时间会较长

4.使用浏览器输入虚拟机IP查看安装成功页面

image.png

二、部署WordPress应用

1进入mysql数据库进行基础配置

如果出现错误1045,则参考:https://cloud.tencent.com/developer/article/1188636#:~:text=ERROR%201045%20%2828000%29%3A%20Access%20denied%20for,user%20%27root%27%40%27localhost%27%20%28using%20password%3A%20YES%29%E3%80%82%20MySQL%E5%AE%89%E8%A3%85%E6%97%B6%E9%BB%98%E8%AE%A4%E7%9A%84%E7%94%A8%E6%88%B7%E6%98%AFroot%EF%BC%8C%E8%BF%99%E9%87%8C%E7%9A%84root%E6%98%AF%E6%8C%87%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E7%94%A8%E6%88%B7%EF%BC%8Croot%E5%AF%86%E7%A0%81%E4%B8%80%E8%88%AC%E5%9C%A8%E5%88%9D%E5%A7%8B%E5%8C%96MySQL%E6%97%B6%E5%AD%98%E6%94%BE%E5%9C%A8%E4%BD%A0%E7%9A%84%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E4%B8%AD%EF%BC%8C%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E7%9A%84%E5%AD%98%E6%94%BE%E8%B7%AF%E5%BE%84%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87my.cnf%E6%96%87%E4%BB%B6%E8%BF%9B%E8%A1%8C%E8%87%AA%E5%AE%9A%E4%B9%89%E3%80%82

[root@lnmp ~]# mysql -uroot -pyourpassword Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.62-log Source distribution

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

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)

mysql> grant all privileges on . to root@localhost identified by ‘yourpassword’ with grant option; Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on . to root@”%” identified by ‘yourpassword’ with grant option; Query OK, 0 rows affected (0.00 sec)

mysql> Ctrl-C — exit! Aborted

2.解压WordPress压缩包并配置文件

[root@lnmp ~]# unzip wordpress-4.7.3-zh_CN.zip [root@lnmp ~]# cd /home/wwwroot/default [root@lnmp default]# rm -rf index.html [root@lnmp default]#cd /root/wordpress [root@lnmp wordpress]# cp -rvf /home/wwwroot/default [root@lnmp wordpress]# cd /home/wwwroot/default/ [root@lnmp default]# chmod 777

3.备份配置文件并编辑

[root@lnmp default]# cp wp-config-sample.php wp-config.php [root@lnmp default]# vi wp-config.php // MySQL 设置 - 具体信息来自您正在使用的主机 // /* WordPress数据库的名称 / define(‘DB_NAME’, ‘wordpress’);

/* MySQL数据库用户名 / define(‘DB_USER’, ‘root’);

/* MySQL数据库密码 / define(‘DB_PASSWORD’, ‘yourpassword’);

/* MySQL主机 / define(‘DB_HOST’, ‘127.0.0.1’);

/* 创建数据表时默认的文字编码 / define(‘DB_CHARSET’, ‘utf8’);

/* 数据库整理类型。如不确定请勿更改 / define(‘DB_COLLATE’, ‘’);

4.更改完毕后浏览器输入虚拟机IP进入

进行必要配置后安装即可
image.png