| 服务器类型 | 主机地址 | 主机域名 |
|---|---|---|
| web 服务器 | 192.168.25.136 | www.example.com |
| nfs 服务器 | 192.168.25.138 | nfs.example.com |
| chronyd 服务器 | 192.168.25.135 / ntp.aliyum.com | ntp.example.com |
| dns 服务器 | 192.168.25.135 | dns.example.com |
DNS
[root@dns ~]# systemctl stop firewalld
[root@dns ~]# setenforce 0
挂载
[root@dns ~]# mount /dev/sr0 /sr0
安装程序包
[root@dns ~]# dnf install bind -y
配置文件
[root@dns ~]# vim /etc/named.conf

正向解析

创建正向资源解析的文件
[root@dns ~]# cp -p /var/named/named.localhost /var/named/named.example
[root@dns ~]# vim /var/named/named.example
SOA是授权记录作用是对当前域的查询进行一个授权
NS记录是用来标记DNS主机但标记的是DNS主机的域名而不是IP地址
A记录用来解析IPV4记录

重启
[root@dns ~]# systemctl restart named
部署dns服务器内主机能够通过域名访解析
[root@dns ~]# vim /etc/resolv.conf

检测
[root@localhost ~]# nslookup www.example.com
Server: 192.168.25.135
Address: 192.168.25.135#53
Name: www.example.com
Address: 192.168.25.136
确保多台主机时区是一致的
[root@dns ~]# date
2026年 11月 20日 星期五 15:00:38 CST
如果不一致修改用: timedatectl set-timezone Asia/Shanghai
自己搭建时间服务器
[root@dns ~]# vim /etc/chrony.conf


重启服务
[root@dns ~]# systemctl restart chronyd
其他主机
[root@localhost ~]# vim /etc/chrony.conf

重启服务
[root@localhost ~]# systemctl restart chronyd
检测
[root@localhost ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.25.135 10 6 17 13 -1969ns[ -14us] +/- 117us

NFS服务器
通过nfs服务器共享网盘站点的资源文件(nextcloud包)
[root@nfs ~]# systemctl stop firewalld
[root@nfs ~]# setenforce 0
挂载
[root@nfs ~]# mount /dev/sr0 /sr0
安装
[root@nfs ~]# dnf install nfs-utils -y
配置文件
[root@nfs ~]# vim /etc/exports
/pub www.example.com(rw sync)
:wq
创建共享目录
[root@nfs ~]# mkdir /pub
[root@nfs ~]# cd /pub

[root@nfs pub]# ll
总用量 183092
-rw-r--r--. 1 root root 187483870 11月 22 18:49 nextcloud-28.0.10.tar.bz2
进行解压缩
[root@nfs pub]# tar -xvf nextcloud-28.0.10.tar.bz2

进行修改
[root@nfs pub]# vim /etc/exports
/pub/nextcloud www.example.com(rw sync)
:wq

修改权限
[root@nfs pub]# chmod 777 -R .
启动服务
[root@nfs pub]# systemctl restart nfs-server.service
测试
[root@www ~]# mount /dev/sr0 /sr0
[root@www ~]# dnf install nfs_utils -y
手动
[root@www ~]# mkdir /nfs
[root@www ~]# mount nfs.example.com:/pub/nextcloud /nfs

web服务器
LAMP
Linux 平台
nginx+httpd mysql/mariadb
PHP 应用程序 PHP 配置
[root@www ~]# systemctl stop firewalld
[root@www ~]# setenforce 0
安装
[root@www ~]# dnf install nginx -y
安装php程序
[root@www ~]# dnf install php* -y

配置文件
[root@www ~]# vim /etc/nginx/nginx.conf
[root@www ~]# vim /etc/nginx/default.d/
不用修改
部署数据库
[root@www ~]# dnf install mariadb-server -y
启动服务
[root@www ~]# systemctl restart mariadb php-fpm nginx
注:开机自启动
[root@www ~]# systemctl enable mariadb php-fpm
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
进入数据库
[root@www ~]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.16-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
创建一个库
MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.001 sec)
创建一个普通账户
MariaDB [(none)]> create user test@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)
修改权限进行授权
MariaDB [(none)]> grant all on nextcloud.* to test@'localhost';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Bye
将nfs和web界面所共享的文件进行连接
[root@www ~]# dnf install autofs -y
[root@www ~]# nginx ---> /usr/share/nginx/html/*.php
编辑配置文件
[root@www ~]# vim /etc/auto.master

[root@www ~]# vim /etc/auto.nfs
html -fstype=nfs,rw,sync nfs.example.com:/pub/nextcloud
:wq
启动服务
[root@www ~]# systemctl restart autofs
进行手动触发操作
[root@www ~]# cd /usr/share/nginx/html
[root@www html]#

再重新启动一下服务
[root@www html]# systemctl enable mariadb php-fpm nginx
用IP地址访问界面



通过自定义的本地DNS服务器去访问百度
[root@www html]# vim /etc/resolv.conf


cpolar内网穿透
安装
[root@www html]# curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
复制验证码
[root@www html]# cpolar authtoken MWQ0NzE5YjMtOGE4ZC00OGZlLWEwNTctZjE4YTQ0M2Q3MjQ5
启动
[root@www html]# systemctl enable cpolar; systemctl start cpolar
在网页输入:192.168.25.136:9200





可以通过Login -- Nextcloud访问
[root@nfs nextcloud]# cd config/
[root@nfs config]# ll
总用量 80
-rw-r-----. 1 apache apache 604 11月 22 21:51 config.php
-rwxrwxrwx. 1 nobody nobody 77273 9月 12 2024 config.sample.php
[root@nfs config]# vim config.php

可以正常加载


设置防火墙 firewalld
[root@dns ~]# systemctl restart firewalld
设置防火墙的规则:
允许所有客户端主机能够向当前主机建立dns的访问连接
[root@dns ~]# firewall-cmd --permanent --add-service=dns
success
允许所有客户端主机能够向当前主机建立时间的访问连接
[root@dns ~]# firewall-cmd --permanent --add-service=ntp
success
重载一下使规则立即生效
[root@dns ~]# firewall-cmd --reload
success
检测


设置selinux
[root@dns ~]# setenforce 1 --- 开启之后时间同步连接请求没有影响
只需要考虑防火墙的设置
[root@nfs config]# systemctl restart firewalld
[root@nfs config]# firewall-cmd --permanent --add-service=nfs
success
[root@nfs config]# firewall-cmd --reload
success
[root@nfs config]# setenforce 1
测试
[root@www html]# cd
[root@www ~]# cd /usr/share/nginx/html/
[root@www html]# ll
总用量 1232
drwxrwxrwx. 43 nobody nobody 4096 9月 12 2024 3rdparty
drwxrwxrwx. 50 nobody nobody 4096 9月 12 2024 apps
-rwxrwxrwx. 1 nobody nobody 23796 9月 12 2024 AUTHORS
-rwxrwxrwx. 1 nobody nobody 1906 9月 12 2024 composer.json
-rwxrwxrwx. 1 nobody nobody 3140 9月 12 2024 composer.lock
drwxrwxrwx. 2 nobody nobody 66 11月 23 00:03 config
-rwxrwxrwx. 1 nobody nobody 4124 9月 12 2024 console.php
-rwxrwxrwx. 1 nobody nobody 34520 9月 12 2024 COPYING
drwxrwxrwx. 24 nobody nobody 4096 9月 12 2024 core
-rwxrwxrwx. 1 nobody nobody 7061 9月 12 2024 cron.php
drwxrwx---. 4 apache apache 118 11月 22 21:51 data
drwxrwxrwx. 2 nobody nobody 12288 9月 12 2024 dist
-rwxrwxrwx. 1 nobody nobody 156 9月 12 2024 index.html
-rwxrwxrwx. 1 nobody nobody 4403 9月 12 2024 index.php
drwxrwxrwx. 6 nobody nobody 125 9月 12 2024 lib
-rwxrwxrwx. 1 nobody nobody 283 9月 12 2024 occ
drwxrwxrwx. 2 nobody nobody 55 9月 12 2024 ocs
drwxrwxrwx. 2 nobody nobody 23 9月 12 2024 ocs-provider
-rwxrwxrwx. 1 nobody nobody 7112 9月 12 2024 package.json
-rwxrwxrwx. 1 nobody nobody 1095869 9月 12 2024 package-lock.json
-rwxrwxrwx. 1 nobody nobody 3187 9月 12 2024 public.php
-rwxrwxrwx. 1 nobody nobody 5597 9月 12 2024 remote.php
drwxrwxrwx. 4 nobody nobody 133 9月 12 2024 resources
-rwxrwxrwx. 1 nobody nobody 26 9月 12 2024 robots.txt
-rwxrwxrwx. 1 nobody nobody 2452 9月 12 2024 status.php
drwxrwxrwx. 3 nobody nobody 35 9月 12 2024 themes
drwxrwxrwx. 2 nobody nobody 43 9月 12 2024 updater
-rwxrwxrwx. 1 nobody nobody 405 9月 12 2024 version.

[root@www html]# systemctl restart firewalld
[root@www html]# firewall-cmd --permanent --add-service=http
success
[root@www html]# firewall-cmd --permanent --add-port=9200/tcp
success
[root@www html]# firewall-cmd --reload
success
[root@www html]# setenforce 1

加载NFS系统
[root@www html]# setsebool httpd_use_nfs on