[工具] Shell 自动化部署 LNMP + SSL 平台 (CentOS Linux 8 版)

介绍

基本信息

作者:朱明宇
名称:自动化部署 LNMP + SSL 平台
作用:自动化安装 LNMP + SSL,即通过 Linux、Nginx、MariaDB、PHP、php-fpm、SSL,实现 HTTPS

使用方法

1. 将网站的网页数据备份、网站的 SSL 公钥、网站的 SSL 私钥、网站的数据库备份和本脚本,5 个文件放在同一目录下
2. 如果没有网站的数据库备份则将网页数据备份、网站的 SSL 公钥、网站的 SSL 私钥和本脚本,4 个文件放在同一目录下
3. 在此脚本的分割线内写入相应的内容
4. 服务器都要开启 SELinux
5. 给此脚本添加执行权限
6. 执行此脚本:./<此脚本>

脚本分割线里的变量

1. webdomain=”eternalcenter.com” #网站的域名,注意不要在前面加任何前缀
2. webtar=”eternalcenter-backup-*.tar.gz”网站的网页数据备份,如果没有这个备份,可以下载一个开源的 WordPress 网页程序
3. webcrt=”eternalcenter.com.crt” #网站 SSL 的公钥,可以自己创建也可以在 FreeSSL 上申请
4. webkey=”eternalcenter.com.key” #网站 SSL 的私钥,可以自己创建也可以在 FreeSSL 上申请
5. sqlbackup=”eternalcenter-backup-*.sql” #网站数据库数据备份,如果没有这个备份(数据库是全量备份),则这里可以为空
6. db=”ec” #网站在数据库中库
7. dbuser=”ec” #网站在数据库中的用户
8. dbuserpw=”eternalcenter” #网站在数据库中的用户密码
9. dbrootpw=”eternalcenter” #数据库的 root 密码

注意

1. 服务器的系统需要是 CentOS 8 版本
2. 服务器系统要配置好可用的软件源
3. 服务器要能够连接外网

脚本

#!/bin/bash

####################### Separator ########################
webdomain="eternalcenter.com"
webtar="eternalcenter-backup-*.tar.gz"
webcrt="eternalcenter.com.crt"
webkey="eternalcenter.com.key"
sqlbackup="eternalcenter-backup-*.sql"
db="ec"
dbuser="ec"
dbuserpw="eternalcenter"
dbrootpw="eternalcenter"
####################### Separator ########################

#Determine whether SELinux is on
getenforce | grep Enforcing
if [ $? -ne 0 ];then
	echo "SELinux is not set to enforcing mode and cannot continue"
	exit 2
fi

#Determine whether the required file exists
ls $webtar
if [ $? -ne 0 ];then
	echo "No web page data backup, unable to continue"
	exit 2
fi

ls $webcrt
if [ $? -ne 0 ];then
	echo "Cannot continue without site public key"
	exit 2
fi

ls $webkey
if [ $? -ne 0 ];then
	echo "Unable to continue without site private key"
	exit 2
fi

#Update system
yum clean all
yum repolist
yum makecache
yum -y update

#Make sure the required software is installed
yum -y install tar
yum -y install firewalld

#Deploying Nginx
yum -y install nginx

echo 'worker_processes  1;

events {
    worker_connections  1024;
}

http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  60;
    client_body_timeout 20s;
    client_header_timeout 10s;
    send_timeout 30s;

    server {
        listen       80;
        limit_req zone=one burst=5;
        server_name www.eternalcenter.com eternalcenter.com;

        rewrite ^/(.*)$ https://eternalcenter.com/$1 permanent;
      
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        }

    server {
        listen       443 ssl;
        server_name www.eternalcenter.com eternalcenter.com;

        if ($request_method !~ ^(GET|POST)$){
        return 444;
        }

        ssl_certificate      /etc/nginx/ssl/eternalcenter.com.crt;
        ssl_certificate_key  /etc/nginx/ssl/eternalcenter.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/$fastcgi_script_name;
            include fastcgi_params;
        } 

        location / {
        root html;
        index index.php index.html index.htm;

        if (-f $request_filename/index.html){rewrite (.) $1/index.html break;}
        if (-f $request_filename/index.php){rewrite (.) $1/index.php;}
        if (!-f $request_filename){rewrite (.) /index.php;}
        
        }

        location ~ ^/\.user\.ini {
        deny all;
        }
    
        location ~*\.(jpd|jpeg|gif|png|css|js|ico|xml)$ {
        expires 30d;
        }

        error_page  404              /404.html;

        }

        gzip on;
	gzip_min_length 1000;
	gzip_comp_level 4;
	gzip_types text/plain test/css application/json application/x-javascript text/xml application/xml
	application/xml+rss text/javascripts;

	client_header_buffer_size 1k;
	large_client_header_buffers 4 4k;

	open_file_cache max=2000 inactive=20s;
	open_file_cache_valid  60s;
	open_file_cache_min_uses 5;
	open_file_cache_errors off;

}' > /etc/nginx/nginx.conf

sed -i "s/server_name www.eternalcenter.com eternalcenter.com;/server_name www.$webdomain $webdomain;/" /etc/nginx/nginx.conf
sed -i "s@rewrite ^/(.*)$ https://eternalcenter.com/\$1 permanent@rewrite ^/(.*)$ https://$webdomain/\$1 permanent@" /etc/nginx/nginx.conf;
sed -i "s/eternalcenter.com.crt/$webcrt/" /etc/nginx/nginx.conf
sed -i "s/eternalcenter.com.key/$webkey/" /etc/nginx/nginx.conf

mkdir /etc/nginx/ssl
mv $webcrt /etc/nginx/ssl
mv $webkey /etc/nginx/ssl
chcon -t httpd_config_t /etc/nginx/ssl/$webcrt
chcon -t httpd_config_t /etc/nginx/ssl/$webkey
chcon -t httpd_config_t /etc/nginx/ssl/

rm -rf /usr/share/nginx/html/*
tar -xvf $webtar -C /usr/share/nginx/html/ && rm -rf $webtar
chcon -t httpd_sys_content_t -R /usr/share/nginx/html/*

yum -y install sendmail
yum -y install policycoreutils
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
setsebool -P httpd_can_sendmail 1
setsebool -P httpd_can_connect_ftp 1
setsebool -P httpd_unified 1
setsebool -P httpd_enable_cgi 1
setsebool -P httpd_builtin_scripting 1
setsebool -P mysql_connect_http 1

systemctl start nginx
systemctl enable nginx

#Deploy MariaDB
yum -y install mariadb mariadb-server

grep "^log_bin=" /etc/my.cnf.d/mariadb-server.cnf
if [ $? -ne 0 ];then
	sed -i '/^datadir/a log_bin=ec' /etc/my.cnf.d/mariadb-server.cnf
fi

grep "^binlog_format=" /etc/my.cnf.d/mariadb-server.cnf
if [ $? -ne 0 ];then
	sed -i '/^datadir/a binlog_format=\"mixed\"' /etc/my.cnf.d/mariadb-server.cnf
fi

grep "^server_id=" /etc/my.cnf.d/mariadb-server.cnf
if [ $? -ne 0 ];then
	sed -i '/^datadir/a server_id=51' /etc/my.cnf.d/mariadb-server.cnf
fi

sed -i 's/^plugin-load-add=auth_gssapi.so/#plugin-load-add=auth_gssapi.so/' /etc/my.cnf.d/auth_gssapi.cnf

sed -i '/^user=.*/d' /etc/my.cnf.d/mariadb-server.cnf
sed -i "/\[mysqld\]/a user=mysql" /etc/my.cnf.d/mariadb-server.cnf

sed -i '/^bind-address=.*/d' /etc/my.cnf.d/mariadb-server.cnf
sed -i "/\[mysqld\]/a bind-address=127.0.0.1" /etc/my.cnf.d/mariadb-server.cnf

chown -R mysql /var/lib/mysql

systemctl start mariadb
systemctl enable mariadb

ls $sqlbackup
if [ $? -ne 0 ];then
        mysql -uroot -e "create database $db;"
        mysql -uroot -e "create user \"$dbuser\"@\"localhost\" identified by \"$dbuserpw\";"
        mysql -uroot -e "grant all privileges on $db.* to \"$dbuser\"@\"localhost\" identified by \"$dbuserpw\";"
        mysql -uroot -e "set password for 'root'@'localhost'=password(\"$dbrootpw\")"
else
        mysql -uroot -e "create database $db;"
        mysql -uroot $db < $sqlbackup
	mysql -uroot -e "create user \"$dbuser\"@\"localhost\" identified by \"$dbuserpw\";"
	mysql -uroot -e "grant all privileges on $db.* to \"$dbuser\"@\"localhost\" identified by \"$dbuserpw\";"
	mysql -uroot -e "set password for 'root'@'localhost'=password(\"$dbrootpw\")"
	rm -rf $sqlbackup
fi
	
systemctl restart mariadb

#Deploy PHP
yum -y install php php-fpm php-mysqlnd php-gd php-mbstring php-opcache php-json php-xml php-xmlrpc php-pecl-zip
useradd php-fpm -s /sbin/nologin
chown -R php-fpm:php-fpm /usr/share/nginx/html

sed -i /"^user =.*"/d /etc/php-fpm.conf
sed -i /"^group =.*"/d /etc/php-fpm.conf
sed -i /"^listen =.*"/d /etc/php-fpm.conf
sed -i /"^[www]"/d /etc/php-fpm.conf
sed -i /"^pm = .*"/d /etc/php-fpm.conf
sed -i /"^pm.start_servers = .*"/d /etc/php-fpm.conf
sed -i /"^pm.min_spare_servers = .*"/d /etc/php-fpm.conf
sed -i /"^pm.max_spare_servers = .*"/d /etc/php-fpm.conf
sed -i /"^pm.max_children = .*"/d /etc/php-fpm.conf
sed -i /"^pm.max_requests = .*"/d /etc/php-fpm.conf
sed -i /"^request_terminate_timeout = .*"/d /etc/php-fpm.conf

echo '[www]' >> /etc/php-fpm.conf
echo 'user = php-fpm' >> /etc/php-fpm.conf
echo 'group = php-fpm' >> /etc/php-fpm.conf
echo 'listen = 127.0.0.1:9000' >> /etc/php-fpm.conf
echo 'pm = dynamic' >> /etc/php-fpm.conf
echo 'pm.start_servers = 2' >> /etc/php-fpm.conf
echo 'pm.min_spare_servers = 2' >> /etc/php-fpm.conf
echo 'pm.max_spare_servers = 4' >> /etc/php-fpm.conf
echo 'pm.max_children = 4' >> /etc/php-fpm.conf
echo 'pm.max_requests = 1024' >> /etc/php-fpm.conf
echo 'request_terminate_timeout = 300' >> /etc/php-fpm.conf

systemctl start php-fpm
systemctl enable php-fpm

#Improve system performance
grep "^* soft nofile" /etc/security/limits.conf
if [ $? -ne 0 ];then
	echo '* soft nofile 1024' >> /etc/security/limits.conf
fi

grep "^* hard nofile" /etc/security/limits.conf
if [ $? -ne 0 ];then
	echo '* hard nofile 1024' >> /etc/security/limits.conf
fi

#Open firewall
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --reload

#Limit log space
echo "/var/log/mariadb/mariadb.log {
        create 600 mysql mysql
        notifempty
	daily
        rotate 3
        missingok
        compress
    postrotate
	# just if mysqld is really running
        if [ -e /run/mariadb/mariadb.pid ]
        then
           kill -1 $(</run/mariadb/mariadb.pid)
        fi
    endscript
}" > /etc/logrotate.d/mariadb

echo "/var/log/nginx/*log {
    create 0664 nginx root
    size 1024M
    rotate 1
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}" > /etc/logrotate.d/nginx

echo "/var/log/php-fpm/*log {
    size 100M
    rotate 1
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /bin/kill -SIGUSR1 `cat /run/php-fpm/php-fpm.pid 2>/dev/null` 2>/dev/null || true
    endscript
}" > /etc/logrotate.d/php-fpm

echo "/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    size 100M
    rotate 1
    missingok
    sharedscripts
    postrotate
        /usr/bin/systemctl kill -s HUP rsyslog.service >/dev/null 2>&1 || true
    endscript
}" > /etc/logrotate.d/syslog

#Delete this script
scriptwhere=`readlink -f "$0"`
rm -rf $scriptwhere

#Restart the system
reboot

[内容] Linux case 条件判断

内容一:case 语句的格式

case <variable> in
<variable value 1>)
<the command to execute when the variable is this value>;;
<variable value 2>)
<the command to execute when the variable is this value>;;
<variable value 3>)
<the command to execute when the variable is this value>;;
*)
<the command to execute when the variable value is other>;;
esca

内容二:case 语句的使用案例

2.1 直接使用 case 语句的案例

#!/bin/bash

read -p "Which one do you like better, eternalcenter eternalcentre ec-x : " name

case $name in
eternalcenter)
    echo "Do you realy like $name better? eternalcenter?" ;;
eternalcentre)
    echo "Do you realy like $name better? eternalcentre?" ;;
ec-x)
    echo "Do you realy like $name better? ec-x?" ;;
*)
    echo "So you don't like them all ." ;;
esac

2.2 用变量作为条件判断使用 case 语句的案例

#!/bin/bash

read -p "Which one do you like better, eternalcenter eternalcentre ec-x : " name

Variable1=eternalcenter
Variable2=eternalcentre
Variable3=ec-x

case $name in
$Variable1)
    echo "Do you realy like $name better? eternalcenter?" ;;
$Variable2)
    echo "Do you realy like $name better? eternalcentre?" ;;
$Variable3)
    echo "Do you realy like $name better? ec-x?" ;;
*)
    echo "So you don't like them all ." ;;
esac

[命令] Linux 命令 cut (显示文本的列) (转载)

cut命令

cut是一个选取命令,就是将一段数据经过分析取出我们想要的。
语法:Usage: cut OPTION... [FILE]...

选项:
-b,--bytes=LIST:仅显示行中指定直接范围的内容;
-c,--characters=LIST:仅显示行中指定范围的字符;
-d,--delimiter=DELIM:指定字段的分隔符,默认的字段分隔符为“TAB”;
-f,--fields=LIST:显示指定字段的内容;
-n:与“-b”选项连用,不分割多字节字符;
--complement:选项提取指定字段之外的列;
--out-delimiter=<字段分隔符>:指定输出内容是的字段分割符;

补充扩展:
cut命令可以将一串字符作为列来显示,字符字段的记法:
N-:从第N个字节、字符、字段到结尾;
N-M:从第N个字节、字符、字段到第M个(包括M在内)字节、字符、字段;
-M:从第1个字节、字符、字段到第M个(包括M在内)字节、字符、字段。
上面是记法,结合下面选项将每个范围的字节、字符指定为字段:
-b 表示字节;
-c 表示字符;
-f 表示定义字段;

注:cut是竖着切(竖着分割)

[root@iZwz9bhan5nqzh979qokrkZ ~]# cat a.txt 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

实例一:

[root@iZwz9bhan5nqzh979qokrkZ ~]# cat a.txt 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

取出第一列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 1 a.txt 
root
bin
daemon
adm
lp

取出第一列和第三列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 1,3 a.txt 
root:0
bin:1
daemon:2
adm:3
lp:4

取出第一列至第三列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 1-3 a.txt 
root:x:0
bin:x:1
daemon:x:2
adm:x:3
lp:x:4

取出第四列和之前的所有列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f -4  a.txt 
root:x:0:0
bin:x:1:1
daemon:x:2:2
adm:x:3:4
lp:x:4:7

取出第四列和之后的所有列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 4-  a.txt 
0:root:/root:/bin/bash
1:bin:/bin:/sbin/nologin
2:daemon:/sbin:/sbin/nologin
4:adm:/var/adm:/sbin/nologin
7:lp:/var/spool/lpd:/sbin/nologin

总结:
-d     分界符
-f 1-3 第1列至第3列
-f 1,3 第1列和第3列
-f -3  第3列和之前的内容
-f 3-  第3列号和之后的内容


实例二:

取出除第一列之外的所有列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 1 --complement a.txt 
x:0:0:root:/root:/bin/bash
x:1:1:bin:/bin:/sbin/nologin
x:2:2:daemon:/sbin:/sbin/nologin
x:3:4:adm:/var/adm:/sbin/nologin
x:4:7:lp:/var/spool/lpd:/sbin/nologin

取出除第一列和第三列之外的所有列
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -d ":" -f 1,3 --complement a.txt 
x:0:root:/root:/bin/bash
x:1:bin:/bin:/sbin/nologin
x:2:daemon:/sbin:/sbin/nologin
x:4:adm:/var/adm:/sbin/nologin
x:7:lp:/var/spool/lpd:/sbin/nologin


实例三:

打印第一个字符到第三个字符
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -c 1-3 a.txt 
roo
bin
dae
adm
lp:

打印前面两个字符
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -c -2 a.txt 
ro
bi
da
ad
lp

打印第五个字符及后面所有的字符
[root@iZwz9bhan5nqzh979qokrkZ ~]# cut -c 5- a.txt 
:x:0:0:root:/root:/bin/bash
x:1:1:bin:/bin:/sbin/nologin
on:x:2:2:daemon:/sbin:/sbin/nologin
x:3:4:adm:/var/adm:/sbin/nologin
:4:7:lp:/var/spool/lpd:/sbin/nologin
————————————————
版权声明:本文为CSDN博主「东城绝神」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_37814112/java/article/details/80492032

注明:所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来

CC 4.0 BY-SA 版权协议网址:https://creativecommons.org/licenses/by-sa/4.0/deed.z

站主补充:cut 命令不显示特殊符号

# cut -b2- test.txt

(补充:这里以不显示 test.txt 的特殊符号为例)

[工具] Shell 批量实现多个远程服务器执行命令 (单条命令版)

介绍:

基本信息

作者:朱明宇
名称:批量实现多个远程服务器执行命令 (单条命令版)
作用:批量实现多个远程服务器执行命令 (单条命令版)

使用方法

1. 将此脚本和清单 $list 文件放在同一目录下
2. 清单 $list 里每一个远程服务器名或 IP 地址占用 1 行
3. 在此脚本的分割线内写入相应的内容
4. 给此脚本添加执行权限
5. 执行此脚本

脚本分割线里的变量

1. execute=”top -bn 1 | head -1″ #指定要执行的命令
2. list=servers.txt #指定服务器清单

注意

执行脚本的用户要在远程服务器中有同名用户,此用户拥有免密钥 sudo su 权限,且能被本服务器免密钥 ssh

脚本:

#!/bin/bash

####################### Separator ########################

execute="top -bn 1 | head -1"
list=servers.txt

####################### Separator ########################

echo "WARNING: before execute this, please execute \"screen -S update\" command first"

read -p "will execute $execute on servers in $list, if you agree please input y : " b
echo "you input $b"

if [ "$b" != "y" ];then
        echo "you don't agree so exit now"
        exit 0
fi

num=0

for i in `awk '{print $1}' $list`
do
        let num++
        echo "$num $i"
        ssh -t $i "sudo -u root su - root -c \"$execute\""
        echo "$i has been done"
        echo
done

[实验] LNMP 平台的搭建 (openSUSE Leap 15 版)

步骤一:LNMP 简介

LNMP 是一个实现网站服务的方法,它由 4 样东西组成:
1) Linux 系统
2) Nginx 网页服务
3) MariaDB 数据库
4) PHP 网页程序

步骤二:系统环境要求

1) 服务器的系统需要是 openSUSE 15 版本
2) 服务器要关闭防火墙
3) 服务器系统要配置好可用的软件源(最好是软件数量最多的官方版本)

步骤三:搭建 LNMP

3.1 Nginx 网页服务

3.1.1 安装 Nginx 网页服务
# zypper -n install nginx
3.1.2 配置 Nginx 网页服务的配置文件
3.1.2.1 删除原有的 Nginx 服务的配置文件
# rm /etc/nginx/nginx.conf
3.1.2.2 创建新的 Nginx 网页服务的配置文件
# cp /etc/nginx/nginx.conf.default /etc/nginx.conf
3.1.2.3 配置 Nginx 网页服务的配置文件
# vi /etc/nginx/nginx.conf

将其中的:

......
        location / {
            root   html;
            index  index.html index.htm;
        }
......
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
......

修改为:

......
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
......
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #   fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }
......

(补充:这里以让 Nginx 将对于 PHP 的请求传递到本机的 9000 端口为例)

3.1.3 启动 Nginx 网页服务
# systemctl start nginx

3.2 MariaDB 数据库

3.2.1 安装 MariaDB 数据库
# zypper -n install mariadb mariadb-server
3.2.2 启动 MariaDB 数据库
# systemctl start mariadb

3.3 PHP 环境和连接服务

3.3.1 安装 PHP 环境和连接服务
# zypper -n install php7 php7-fpm php7-mysql php7-gd php7-mbstring php7-opcache php7-json php7-xmlrpc php7-zlib
3.3.2 创建提供 PHP 连接服务的用户
# useradd php-fpm -s /sbin/nologin
3.3.3 配置 PHP 连接服务的配置文件
# vi /etc/php-fpm.conf

将以下内容:

......
user = nouser
group = nouser
......

修改为:

......
user = php-fpm
group = users
listen = 127.0.0.1:9000
......


补充:这里以
1) 以 php-fpm 用户和 users 用户组的身份启动 php-fpm
2) 让 php-fpm 监听本地 9000 端口为例

步骤四:后续工作

1) 给 MariaDB 数据库设置用于存储网页数据的用户和密码
2) 将 PHP 网页程序放到 Nginx 的网页目录下(/srv/www/htdocs)
3) 给 PHP 网页程序设置用于连接 MariaDB 数据库的用户和密码

步骤五:测试 LNMP 平台

使用浏览器访问服务器 IP 地址就可以看到对应 PHP 网页了