#NFS
###1. nfs简介
###1.1 nfs特点
NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源
在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样
nfs适用于Linux与Unix之间实现文件共享,不能实现Linux与Windows间的文件共享功能
nfs是运行在应用层的协议,其监听于2049/tcp和2049/udp套接字上
nfs服务只能基于IP进行认证
###1.2 nfs的应用场景
nfs有很多实际应用场景,以下是一些常用的场景:
多个机器共享一台CDROM或其他设备。这对于在多台机器中安装软件来说更加便宜与方便
在大型网络中,配置一台中心NFS服务器用来放置所有用户的home目录可能会带来便利。这些目录能被输出到网络以便用户不管在哪台工作站上登录,总能得到相同的home目录
不同客户端可在NFS上观看影视文件,节省本地空间
在客户端完成的工作数据,可以备份保存到NFS服务器上用户自己的路径下
###1.3 nfs的体系组成
nfs体系至少有两个主要部分:
一台nfs服务器
若干台客户机
nfs体系的架构图如下:
客户机通过TCP/IP网络远程访问存放在NFS服务器上的数据
在NFS服务器正式启用前,需要根据实际环境和需求,配置一些NFS参数
###2. nfs工作机制
nfs是基于rpc来实现网络文件系统共享的。所以我们先来说说rpc。
###2.1 RPC
RPC(Remote Procedure Call Protocol),远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。
RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据。在OSI网络通信模型中,RPC跨越了传输层和应用层。
RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。
rpc工作机制如上图所示,下面来描述一下它:
客户端程序发起一个RPC系统调用基于TCP协议发送给另一台主机(服务端)
服务端监听在某个套接字上,当收到客户端的系统调用请求以后,将收到的请求和其所传递的参数通过本地的系统调用执行一遍,并将结果返回给本地的服务进程
服务端的服务进程收到返回的执行结果后将其封装成响应报文,再通过rpc协议返回给客户端
客户端调用进程接收答复信息,获得进程结果,然后调用执行继续进行
###2.2 nfs工作机制
//NFS服务器端运行着四个进程:
nfsd
mountd
idmapd
portmapper
idmapd //实现用户帐号的集中映射,把所有的帐号都映射为NFSNOBODY,但是在访问时却能以本地用户的身份去访问
mountd //用于验证客户端是否在允许访问此NFS文件系统的客户端列表中,在则允许访问(发放一个令牌,持令牌去找nfsd),否则拒绝访问
//mountd的服务端口是随机的,由rpc服务(portmapper)提供随机端口号
nfsd //nfs的守护进程,监听在2049/tcp和2049/udp端口上
//不负责文件存储(由NFS服务器本地内核负责调度存储),用于理解客户端发起的rpc请求,并将其转交给本地内核,而后存储在指定的文件系统上
因为portmapper //NFS服务器的rpc服务,其监听于111/TCP和111/UDP套接字上,用于管理远程过程调用(RPC)
-
客户端发起查看file信息的指令(ls file)给内核,内核通过NFS模块得知此文件并不是本地文件系统中的文件,而是在远程NFS主机上的一个文件
-
客户端主机的内核通过RPC协议把查看file信息的指令(系统调用)封装成rpc请求通过TCP的111端口发送给NFS服务端主机的portmapper
-
NFS服务端主机的portmapper(RPC服务进程)告诉客户端说NFS服务端的mountd服务在某某端口上,你去找它验证
因为mountd在提供服务时必须要向portmapper注册一个端口号,所以portmapper是知道其工作于哪个端口的 -
客户端得知服务端的mountd进程端口号后,通过已知的服务端mountd端口号请求验证
-
mountd收到验证请求后验证发起请求的客户端是否在允许访问此NFS文件系统的客户端列表中,在则允许访问(发放一个令牌,持令牌去找nfsd),否则拒绝访问
-
验证通过后客户端持mountd发放的令牌去找服务端的nfsd进程,请求查看某文件
-
服务端的nfsd进程发起本地系统调用,向内核请求查看客户端要查看的文件的信息
-
服务端的内核执行nfsd请求的系统调用,并将结果返回给nfsd服务
-
nfsd进程收到内核返回的结果后将其封装成rpc请求报文并通过tcp/ip协议返回给客户端
###3. exports文件的格式
nfs的主配置文件是/etc/exports,在此文件中,可以定义NFS系统的输出目录(即共享目录)、访问权限和允许访问的主机等参数。该文件默认为空,没有配置输出任何共享目录,这是基于安全性的考虑,如此即使系统启动了NFS服务也不会输出任何共享资源。
exports文件中每一行提供了一个共享目录的设置,其命令格式为:
<输出目录> [客户端1(选项1,选项2,…)] [客户端2(选项1,选项2,…)]
其中,除输出目录是必选参数外,其他参数均是可选项。另外,格式中的输出目录和客户端之间、客户端与客户端之间都使用空格分隔,但客户端与选项之间不能有空格。
客户端是指网络中可以访问这个NFS共享目录的计算机。客户端的指定非常灵活,可为单个主机的IP或域名,亦可为某个子网或域中的主机等。
选项用来设置共享目录的访问权限、用户映射等。exports文件中的选项比较多,一般可分为三类:
- 访问权限选项(用于控制共享目录的访问权限)
- 用户映射选项
默认情况下,当客户端访问NFS服务器时,若远程访问的用户是root用户,则NFS服务器会将其映射成一个本地的匿名用户(该用户为nfsnobody),并将其所属的用户组也映射成匿名用户组(该用户组也为nfsnobody),如此有助于提高系统的安全性。 - 其他选项
访问权限选项:
访问权限选项 | 说明 |
---|---|
ro | 设置输出目录只读 |
rw | 设置输出目录可读写 |
用户映射选项: | |
用户映射选项 | 说明 |
:-------- | -------- |
all_squash | 将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody) |
no_all_squash | 不将远程访问的所有普通用户及所属用户组都映射为匿名用户或用户组(默认设置) |
root_squash | 将root用户及所属用户组都映射为匿名用户或用户组(默认设置) |
no_root_squash | 不将root用户及所属用户组都映射为匿名用户或用户组 |
anonuid=xxx | 将远程访问的所有用户都映射为匿名用户,并指定该匿名用户为本地用户帐户(UID=xxx) |
anongid=xxx | 将远程访问的所有用户组都映射为匿名用户组,并指定该匿名用户组为本地用户组(GID=xxx) |
常用的其他选项: | |
其他选项 | 说明 |
:-------- | -------- |
secure | 限制客户端只能从小于1024的TCP/IP端口连接NFS服务器(默认设置) |
insecure | 允许客户端从大于1024的TCP/IP端口连接NFS服务器 |
sync | 将数据同步写入内存缓冲区或磁盘中,效率较低,但可保证数据一致性 |
async | 将数据先保存在内存缓冲区中,必要时才写入磁盘 |
wdelay | 检查是否有相关的写操作,如果有则这些写操作一起执行,可提高效率(默认设置) |
no_wdelay | 若有写操作则立即执行,应与sync配置使用 |
subtree_check | 输出目录是一个子目录,则NFS服务器将检查其父目录的权限(默认设置) |
no_subtree_check | 即使输出目录是一个子目录,NFS服务亦不检查其父目录的权限,可提高效率 |
nohide | 若将一个目录挂载到另一个目录之上,则原来的目录通常就被隐藏起来或看起来像空的一样。要禁用这种行为,需启用hide选项 |
###4. nfs管理 | |
nfs安装: |
//安装
yum -y install nfs-utils
//启动
systemctl start rpcbind nfs-server
使用shoumount命令测试NFS服务器的输出目录状态:
//语法:showmount [选项] [NFS服务器名称或地址]
//常用的选项有:
-a //显示指定NFS服务器的所有客户端主机及其所连接的目录
-d //显示指定的NFS服务器中已被客户端连接的所有输出目录
-e //显示指定的NFS服务器上所有输出的共享目录
在客户端挂载NFS文件系统:
mount -t nfs SERVER:/path/to/sharedfs /path/to/mount_point
在客户端设置开机自动挂载nfs:编辑/etc/fstab文件,添加如下格式的内容
SERVER:/PATH/TO/EXPORTED_FS /mnt_point nfs defaults,_netdev 0 0
客户端挂载时可以使用的特殊选项:
rsize:其值是从服务器读取的字节数(缓冲)。默认为1024。若使用比较高的值,如8192,可以提高传输速度
wsize:其值是写入到服务器的字节数(缓冲)。默认为1024。若使用比较高的值,如8192,可以提高传输速度
exportfs //维护exports文件导出的文件系统表的专用工具
-a //输出在/etc/exports文件中所设置的所有目录
-r //重新读取/etc/exports文件中的设置,并使其立即生效,无需重启服务
-u //停止输出某一目录
-v //在输出目录时将目录显示到屏幕上
检查输出目录所使用的选项:
在配置文件/etc/exports中,即使在命令行中只设置了一两个选项,但在真正输出目录时,实际上还带有很多默认的选项。通过查看/var/lib/nfs/etab文件,可以看到具体使用了何选项
[root@localhost ~]# cat /var/lib/nfs/etab
#服务端
1:下载服务
[root@localhost ~]# yum -y install nfs-util*
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 20:01:49 ago on Tue Jul 19 22:28:50 2022.
Package nfs-utils-1:2.3.3-47.el8.x86_64 is already installed.
Dependencies resolved.
================================================================================================================
Package Architecture Version Repository Size
================================================================================================================
Upgrading:
nfs-utils x86_64 1:2.3.3-56.el8 baseos 514 k
Transaction Summary
================================================================================================================
Upgrade 1 Package
Total download size: 514 k
Downloading Packages:
nfs-utils-2.3.3-56.el8.x86_64.rpm 1.0 MB/s | 514 kB 00:00
----------------------------------------------------------------------------------------------------------------
Total 475 kB/s | 514 kB 00:01
CentOS Stream 8 - BaseOS 109 kB/s | 1.6 kB 00:00
Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/1
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Upgrading : nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Running scriptlet: nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Cleanup : nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Running scriptlet: nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Verifying : nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Verifying : nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Upgraded:
nfs-utils-1:2.3.3-56.el8.x86_64
Complete!
[root@localhost ~]# mkdir /public
[root@localhost ~]# vim /etc/exports
/public 192.168.181.160(ro)·····································
[root@localhost ~]# systemctl restart nfs-server.service rpcbind
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
2:
[root@localhost ~]# vim /etc/exports
[root@localhost ~]#
/public 192.168.181.160(rw)
~
[root@localhost ~]# exportfs -r
[root@localhost ~]#
3:
[root@localhost ~]# chmod 777 /public/
4:
[root@localhost ~]# chown -R nobody /public/
[root@localhost ~]#
5:
[root@localhost ~]# firewall-cmd --add-rich-rule 'rule family=ipv4 source address=192.168.181.0/24 service name=nfs accept' --permanent
success
[root@localhost ~]# firewall-cmd --add-rich-rule 'rule family=ipv4 source address=192.168.181.0/24 service name=rpc-bind accept' --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="192.168.181.0/24" service name="rpc-bind" accept
rule family="ipv4" source address="192.168.181.0/24" service name="nfs" accept
#客户端
1:下载服务
[root@localhost ~]# yum -y install nfs-util*
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 1 day, 0:16:43 ago on Tue Jul 19 18:15:02 2022.
Package nfs-utils-1:2.3.3-47.el8.x86_64 is already installed.
Dependencies resolved.
================================================================================================================
Package Architecture Version Repository Size
================================================================================================================
Upgrading:
nfs-utils x86_64 1:2.3.3-56.el8 baseos 514 k
Transaction Summary
================================================================================================================
Upgrade 1 Package
Total download size: 514 k
Downloading Packages:
nfs-utils-2.3.3-56.el8.x86_64.rpm 739 kB/s | 514 kB 00:00
----------------------------------------------------------------------------------------------------------------
Total 440 kB/s | 514 kB 00:01
CentOS Stream 8 - BaseOS 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/1
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Upgrading : nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Running scriptlet: nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Running scriptlet: nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Cleanup : nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Running scriptlet: nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Verifying : nfs-utils-1:2.3.3-56.el8.x86_64 1/2
Verifying : nfs-utils-1:2.3.3-47.el8.x86_64 2/2
Upgraded:
nfs-utils-1:2.3.3-56.el8.x86_64
Complete!
[root@localhost ~]# showmount -e 192.168.181.159
Export list for 192.168.181.159:
/public 192.168.181.160
[root@localhost ~]# mkdir /ccc
[root@localhost ~]# vim /etc/fstab
192.168.181.159:public /ccc nfs defaults 0 0
[root@localhost ~]# mount -a
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 9.6M 1.8G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/cs-root xfs 70G 6.0G 65G 9% /
/dev/mapper/lvo-vgo ext4 9.8G 37M 9.3G 1% /lvo
/dev/mapper/cs-home xfs 225G 1.7G 224G 1% /home
/dev/sda1 xfs 1014M 255M 760M 26% /boot
tmpfs tmpfs 371M 12K 371M 1% /run/user/42
tmpfs tmpfs 371M 0 371M 0% /run/user/0
192.168.181.159:/public nfs4 70G 5.9G 65G 9% /ccc
2:
[root@localhost ~]# cd /ccc/
[root@localhost ccc]# mkdir a
mkdir: cannot create directory 'a': Read-only file system
[root@localhost ccc]# ls
[root@localhost ccc]#
3:
[root@localhost ~]# cd /ccc/
[root@localhost ccc]# mkdir a
[root@localhost ccc]# ls
a
4:
[root@localhost ~]# ll -d /ccc/
drwxr-xr-x. 3 nobody root 15 Jul 20 18:48 /ccc/
[root@localhost ~]#
[root@localhost ccc]# mkdir qqq
[root@localhost ccc]# touch eee
[root@localhost ccc]# ls
a eee qqq
[root@localhost ccc]# rm -rf *
[root@localhost ccc]# ls
[root@localhost ccc]#
5:
[root@localhost ~]# cd /ccc/
[root@localhost ccc]# mkdir www
[root@localhost ccc]# touch rrr
[root@localhost ccc]# ls
rrr www
[root@localhost ccc]# rm -rf *
[root@localhost ccc]# ls
[root@localhost ccc]#
##httpd源码安装
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.6.5.tar.bz2
--2022-07-20 19:27:44-- https://downloads.apache.org/apr/apr-1.6.5.tar.bz2
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 855393 (835K) [application/x-bzip2]
Saving to: 'apr-1.6.5.tar.bz2'
apr-1.6.5.tar.bz2 100%[===========================================>] 835.34K 531KB/s in 1.6s
2022-07-20 19:27:47 (531 KB/s) - 'apr-1.6.5.tar.bz2' saved [855393/855393]
[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.bz2
--2022-07-20 19:27:57-- https://downloads.apache.org/httpd/httpd-2.4.54.tar.bz2
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7434530 (7.1M) [application/x-bzip2]
Saving to: 'httpd-2.4.54.tar.bz2'
httpd-2.4.54.tar.bz2 100%[===========================================>] 7.09M 2.50MB/s in 2.8s
2022-07-20 19:28:01 (2.50 MB/s) - 'httpd-2.4.54.tar.bz2' saved [7434530/7434530]
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.bz2
--2022-07-20 19:28:11-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.bz2
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 428595 (419K) [application/x-bzip2]
Saving to: 'apr-util-1.6.1.tar.bz2'
apr-util-1.6.1.tar.bz2 100%[===========================================>] 418.55K 5.34KB/s in 84s
2022-07-20 19:29:40 (4.97 KB/s) - 'apr-util-1.6.1.tar.bz2' saved [428595/428595]
解压,先解压依赖包在解压主包
[root@localhost usr]# tar xf apr-1.6.5.tar.bz2
[root@localhost usr]# cd apr-1.6.5/
[root@localhost apr-1.6.5]# vim configure
将此行注释或删除
解压apr-util包
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING: 'Makefile.in' seems to ignore the --datarootdir setting
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 644 /usr/apr-1.6.5/build/apr_common.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 644 /usr/apr-1.6.5/build/find_apr.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@localhost apr-1.6.5]# make && make install
解压apr-util包
[root@localhost usr]# tar xf apr-util-1.6.1.tar.bz2
[root@localhost usr]# cd apr-util-1.6.1/
[root@localhost apr-util-1.6.1]#
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@localhost apr-util-1.6.1]# make && make install
解压主包
[root@localhost usr]# tar xf httpd-2.4.54.tar.bz2
[root@localhost usr]# cd httpd-2.4.54/
[root@localhost httpd-2.4.54]#
Server Version: 2.4.54
Install prefix: /usr/local/apache
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@localhost httpd-2.4.54]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
mkdir /usr/local/apache/cgi-bin
Installing header files
mkdir /usr/local/apache/include
Installing build system files
mkdir /usr/local/apache/build
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory '/usr/httpd-2.4.54'
[root@localhost httpd-2.4.54]# make && make install
启动apache服务
[root@localhost httpd-2.4.54]# /usr/local/apache/bin/apachectl
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.54]#
浏览器访问
配置环境变量
[root@localhost httpd-2.4.54]# /usr/local/apache/bin/apachectl stop
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.54]# vim /etc/profile.d/apache.sh
export PATH=$PATH:/usr/local/apache/bin/
[root@localhost httpd-2.4.54]# source /etc/profile.d/apache.sh
[root@localhost httpd-2.4.54]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.54]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
[root@localhost httpd-2.4.54]#
创建软链接
[root@localhost httpd-2.4.54]# ln -s /usr/local/apache /usr/local/hello
[root@localhost httpd-2.4.54]# ll /usr/local/
total 0
drwxr-xr-x. 14 root root 164 Jul 14 16:51 apache
drwxr-xr-x. 6 root root 58 Jul 14 16:39 apr
drwxr-xr-x. 5 root root 43 Jul 14 16:45 apr-util
drwxr-xr-x. 2 root root 6 Jun 22 2021 bin
drwxr-xr-x. 2 root root 6 Jun 22 2021 etc
drwxr-xr-x. 2 root root 6 Jun 22 2021 games
lrwxrwxrwx. 1 root root 17 Jul 14 16:59 hello -> /usr/local/apache
drwxr-xr-x. 2 root root 6 Jun 22 2021 include
drwxr-xr-x. 2 root root 6 Jun 22 2021 lib
drwxr-xr-x. 3 root root 17 Jun 30 14:35 lib64
drwxr-xr-x. 2 root root 6 Jun 22 2021 libexec
drwxr-xr-x. 11 root root 151 Jul 14 15:52 nginx
drwxr-xr-x. 2 root root 6 Jun 22 2021 sbin
drwxr-xr-x. 5 root root 49 Jun 30 14:35 share
drwxr-xr-x. 2 root root 6 Jun 22 2021 src
[root@localhost httpd-2.4.54]#