LNMP一键包部署从入门到精通之lnmp单机环境部署

单机环境LNMP一键包部署

基础环境

  • 一台CentOS 7 2009 的虚拟机
  • 点击此处查看快速配置虚拟机

版本选择

  1. 我这里选择lnmpv2.0正式版以及wordpress6.4.2中文版
  2. 包链接点击下载lnmpv2.0正式版 点击下载wordpress6.4.2中文版
  3. 点击查看wordpress官网系统要求
  4. 基于wordpress选择lnmp版本
    • L=>Linux默认
    • N=>Nginx 一键包默认安装最新版
    • M=>MariaDB MariaDB 10.11.3
    • P=>PHP PHP 8.2.6

查看相关注意事项

  1. 点击跳转官网查看
  2. MariaDB cmake需要升级到3以上

image-20240117190542667

  • 选择使用最简单的办法=>yum源安装 (点击跳转文档链接)

开始实践

一、基础环境准备 =>不做修改也行

  1. 关闭防火墙、selinux、修改主机名
systemctl disable firewalld --now && setenforce 0 && hostnamectl set-hostname lnmpwordpress && su
  • 这里是临时关闭防火墙,若要永久关闭请使用下边命令并重启生效
sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config && reboot
# 如果不熟悉流编程器也以使用vi/vim编辑器进行修改=>将SELINUX=后的改为disabled

二、lnmp一键包部署

  1. yum 源安装Cmake3
yum install -y epel-release && yum install -y  cmake3
  1. 下载lnmp包
curl -o /usr/local/lnmp2.0.tar.gz http://175.6.32.4:88/soft/lnmp/lnmp2.0.tar.gz 
  1. 进入目录解压
cd /usr/local/ && tar -zxvf lnmp2.0.tar.gz && rm -f lnmp2.0.tar.gz
  1. 注意事项
    • 貌似按照计划执行安装脚本就可以,但是这有一个小问题
#使用lnmp2.0.tar.gz 没有自带的镜像
#脚本自动下载mariadb包比较慢

解决办法:

image-20240306172439911

  1. 执行安装脚本
cd ./lnmp2.0 && ./install.sh
  1. 选择部署版本
# 选择上边事先选择好的

+------------------------------------------------------------------------+
|          LNMP V2.0 for CentOS Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|        A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux       |
+------------------------------------------------------------------------+
|           For more information please visit https://lnmp.org           |
+------------------------------------------------------------------------+
You have 11 options for your DataBase install.
1: Install MySQL 5.1.73
2: Install MySQL 5.5.62 (Default)
3: Install MySQL 5.6.51
4: Install MySQL 5.7.42
5: Install MySQL 8.0.33
6: Install MariaDB 5.5.68
7: Install MariaDB 10.4.29
8: Install MariaDB 10.5.20
9: Install MariaDB 10.6.13
10: Install MariaDB 10.11.3
0: DO NOT Install MySQL/MariaDB
Enter your choice (1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or 0): 10
You will install MariaDB 10.11.3
Using Generic Binaries [y/n]: 
# 这里n是使用源码包 y是使用二进制包 默认即可
You will install MySQL 5.7.42 from Source.
===========================
Please setup root password of MySQL.
Please enter: Abc@1234
MySQL root password: Abc@1234
===========================
Do you want to enable or disable the InnoDB Storage Engine?
Default enable,Enter your choice [Y/n]:
No input,The InnoDB Storage Engine will enable.
===========================
You have 9 options for your PHP install.
1: Install PHP 5.2.17
2: Install PHP 5.3.29
3: Install PHP 5.4.45
4: Install PHP 5.5.38
5: Install PHP 5.6.40 (Default)
6: Install PHP 7.0.33
7: Install PHP 7.1.33
8: Install PHP 7.2.34
9: Install PHP 7.3.33
10: Install PHP 7.4.33
11: Install PHP 8.0.28
12: Install PHP 8.1.19
13: Install PHP 8.2.6
Enter your choice (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): 13
You will install PHP 8.2.6
===========================
You have 3 options for your Memory Allocator install.
1: Don't install Memory Allocator. (Default)
2: Install Jemalloc
3: Install TCMalloc
Enter your choice (1, 2 or 3):
No input,You will not install Memory Allocator.

Press any key to install...or Press Ctrl+c to cancel
# 耐心等待即可
============================== Check install ==============================
Checking ...
Nginx: OK
MariaDB: OK
PHP: OK
PHP-FPM: OK
Clean Web Server src directory...
+------------------------------------------------------------------------+
|          LNMP V2.0 for CentOS Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|           For more information please visit https://lnmp.org           |
+------------------------------------------------------------------------+
|    lnmp status manage: lnmp {start|stop|reload|restart|kill|status}    |
+------------------------------------------------------------------------+
|  phpMyAdmin: http://IP/phpmyadmin/                                     |
|  phpinfo: http://IP/phpinfo.php                                        |
|  Prober:  http://IP/p.php                                              |
+------------------------------------------------------------------------+
|  Add VirtualHost: lnmp vhost add                                       |
+------------------------------------------------------------------------+
|  Default directory: /home/wwwroot/default                              |
+------------------------------------------------------------------------+
|  MySQL/MariaDB root password: Abc@1234                          |
+------------------------------------------------------------------------+
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
nginx (pid 124575) is running...
php-fpm is runing!
/etc/init.d/mariadb: line 383: log_success_msg: command not found
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port             
LISTEN     0      128          *:3306                     *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:22                       *:*
LISTEN     0      128       [::]:3306                  [::]:*
LISTEN     0      128       [::]:22                    [::]:*
Install lnmp takes 8 minutes.
Install lnmp V2.0 completed! enjoy it.
# 这就安装完成了

到此lnmp部署完成 点击查看官方文档

注意

脚本会自动关闭防火墙。

重启防火墙和selinux后不影响

systemctl start firewalld --now && setenforce 1
 curl -I http://192.168.162.106:80
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 06 Mar 2024 09:43:57 GMT
Content-Type: text/html
Content-Length: 3196
Last-Modified: Wed, 06 Mar 2024 09:40:42 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "65e83a1a-c7c"
Accept-Ranges: bytes

三、检查lnmp各服务状态以及Nginx网页

1. 检查lnmp状态
systemctl status nginx && systemctl status mariadb && systemctl status php-fpm
  • 下边状态正确
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2024-01-19 11:49:25 CST; 1h 4min ago
 Main PID: 124575 (nginx)
   CGroup: /system.slice/nginx.service
           ├─124575 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           ├─124576 nginx: worker process
           ├─124577 nginx: worker process
           ├─124578 nginx: worker process
           └─124579 nginx: worker process

Jan 19 11:49:25 lnmpwordpress systemd[1]: Starting The NGINX HTTP and reverse proxy server...
Jan 19 11:49:25 lnmpwordpress systemd[1]: Started The NGINX HTTP and reverse proxy server.
● mariadb.service - MariaDB Server
   Loaded: loaded (/etc/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2024-01-19 11:49:26 CST; 1h 4min ago
 Main PID: 124743 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─124743 /bin/sh /usr/local/mariadb/bin/mysqld_safe --datadir=/usr/local/mariadb/var --pid-file=/usr/local/maria...
           └─124940 /usr/local/mariadb/bin/mariadbd --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/var --plugin-...

Jan 19 11:49:25 lnmpwordpress systemd[1]: Starting MariaDB Server...
Jan 19 11:49:26 lnmpwordpress mariadb[124622]: Starting MariaDB.240119 11:49:26 mysqld_safe Logging to '/usr/local/mar...err'.
Jan 19 11:49:26 lnmpwordpress mariadb[124622]: 240119 11:49:26 mysqld_safe Starting mariadbd daemon with databases fro...b/var
Jan 19 11:49:26 lnmpwordpress mariadb[124622]: /etc/init.d/mariadb: line 262: log_success_msg: command not found
Jan 19 11:49:26 lnmpwordpress systemd[1]: Started MariaDB Server.
Hint: Some lines were ellipsized, use -l to show in full.
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/etc/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2024-01-19 11:49:27 CST; 1h 4min ago
 Main PID: 125007 (php-fpm)
   CGroup: /system.slice/php-fpm.service
           ├─125007 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
           ├─125013 php-fpm: pool www
           ├─125014 php-fpm: pool www
           ├─125015 php-fpm: pool www
           ├─125016 php-fpm: pool www
           ├─125017 php-fpm: pool www
           ├─125018 php-fpm: pool www
           ├─125019 php-fpm: pool www
           ├─125020 php-fpm: pool www
           ├─125021 php-fpm: pool www
           └─125022 php-fpm: pool www

Jan 19 11:49:27 lnmpwordpress systemd[1]: Started The PHP FastCGI Process Manager.

2. 查看lnmp网页信息
  • 浏览器输入虚拟机IP地址访问

image-20240119130036016

3.网页查看本地环境

点击lnmp网页中查看本地环境的链接

  • 点击探针 =>点击查看更多详细信息
  • 点击这里 =>查看相关解释

image-20240119135324444

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开心-开心急了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值