Nginx 实践案例(源码编译安装方式):利用LNMP搭建wordpress站点

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

​LNMP是Linux + Nginx + MySQL + PHP 四个系统的首字母缩写,相对于 LAMP(Linux + Apache + MySQL + PHP )来说的。曾经在虚拟主机建站界风靡一时,随着新的编程语言和容器技术、微服务等发展,慢慢没落了,尤其是PHP编程语言的使用量急剧下降了。​

​ WordPress是一款能让您建立出色网站、博客或应用程序的开源软件。它具有美观的设计,强大的功能,可以助您自由发挥心中所想。WordPress既是免费的,也是无价的​。

# 本实践过程中的系统及环境描述
L:Linux     https://mirrors.aliyun.com/centos/
N:Nginx     https://nginx.org/en/download.html
M:MySQL     https://dev.mysql.com/downloads/mysql/
P:PHP       http://php.net/downloads.php
Wordpress    https://cn.wordpress.org/latest-zh_CN.tar.gz
#部署规划:
192.168.250.47:Nginx php-fpm 运行web服务
192.168.250.48:运行MySQL数据库,Redis服务

1. 架构拓扑及主机说明

file

# 三台主机
1  1台  Linux+Nginx+PHP+WordPress (简称 LNP) 服务器 :
主机名:LNP-Server-IP47
CentOS 7.9
IP:192.168.250.47


2  1台 MySQL+Redis 服务器 :
主机名: MySQL-Redis-IP48
CentOS 8.4
IP:192.168.250.48/24

3  1台 client主机 :
WIN10-PC机

2. 准备 MySQL 数据库

# CentOS系统的优化,可以查以前的文章;按照架构图修改好主机名
[root@CentOS84-IP48 ]#hostnamectl set-hostname MySQL-Redis-IP48
[root@CentOS84-IP48 ]#exit

# yum 安装 mysql-server 数据库
[root@MySQL-Redis-IP48 ]#yum info mysql-server
Last metadata expiration check: 19:31:21 ago on Mon 28 Mar 2022 02:34:38 AM CST.
Available Packages
Name         : mysql-server
Version      : 8.0.26
[root@MySQL-Redis-IP48 ]#yum -y install mysql-server

# 启动服务并开启自启
[root@MySQL-Redis-IP48 ]#systemctl enable --now mysqld

# 进入数据库
[root@MySQL-Redis-IP48 ]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, 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.
# 创建 wordpress 库
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
# 创建wordpress的数据库账户名和密码
mysql> create user wordpress@'192.168.250.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
# 数据库授权
mysql> grant all on wordpress.* to wordpress@'192.168.250.%';
Query OK, 0 rows affected (0.01 sec)
# 本机登录并验证数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.01 sec)

mysql> use wordpress
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> quit
Bye
[root@MySQL-Redis-IP48 ]#

3. 网络验证MySQL服务

# 通过网络在另外一台机器上登录上面建好的数据库服务器
# 安装数据库客户端 mysql 包
[root@CentOS84-IP172-48 ]#yum -y install mysql

# 网络方式登录远程数据库
[root@CentOS84-IP172-48 ]#mysql -uwordpress -p123456 -h192.168.250.48
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| wordpress          |
+--------------------+
2 rows in set (0.00 sec)

mysql>

4. 配置 LNP 服务器

​基本任务: 编译安装和部署 php 支持 redis,并准备配置和启动服务文件,启动 php-fpm; 编译安装Nginx ,并准备配置和启动服务文件&

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值