单机环境LNMP一键包部署
基础环境
- 一台CentOS 7 2009 的虚拟机
- 点击此处查看快速配置虚拟机
版本选择
- 我这里选择lnmpv2.0正式版以及wordpress6.4.2中文版
- 包链接点击下载lnmpv2.0正式版 点击下载wordpress6.4.2中文版
- 点击查看wordpress官网系统要求
- 基于wordpress选择lnmp版本
- L=>Linux默认
- N=>Nginx 一键包默认安装最新版
- M=>MariaDB MariaDB 10.11.3
- P=>PHP PHP 8.2.6
查看相关注意事项
- 点击跳转官网查看
- MariaDB cmake需要升级到3以上
- 选择使用最简单的办法=>
yum
源安装 (点击跳转文档链接)
开始实践
一、基础环境准备 =>不做修改也行
- 关闭防火墙、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一键包部署
- yum 源安装Cmake3
yum install -y epel-release && yum install -y cmake3
- 下载lnmp包
curl -o /usr/local/lnmp2.0.tar.gz http://175.6.32.4:88/soft/lnmp/lnmp2.0.tar.gz
- 进入目录解压
cd /usr/local/ && tar -zxvf lnmp2.0.tar.gz && rm -f lnmp2.0.tar.gz
- 注意事项
- 貌似按照计划执行安装脚本就可以,但是这有一个小问题
#使用lnmp2.0.tar.gz 没有自带的镜像
#脚本自动下载mariadb包比较慢
解决办法:
-
使用lnmp-full.tar.gz 点击这里直接下载
- 这个包较大1.2个G
- 不推荐使用
-
单独下载所需要的mariadb包
- 在跑脚本时会出现下载链接
- 点击此处直接下载mariadb-10.11.3-linux-systemd-x86_64.tar.gz
- 建议使用magic
- 执行安装脚本
cd ./lnmp2.0 && ./install.sh
- 选择部署版本
# 选择上边事先选择好的
+------------------------------------------------------------------------+
| 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地址访问
3.网页查看本地环境
点击lnmp网页中查看本地环境的链接
- 点击探针 =>点击查看更多详细信息
- 点击这里 =>查看相关解释
-
点击phpinfo =>点击查看更多详细信息
-
点击了解phpMyAdmin => 一种流行的MySQL数据库管理工具(类似sqlYog),它提供了一个基于Web的界面来管理MySQL数据库。