第二十九天作业
1.把/var/html/www目录里面项目 每天压缩备份一次 实战--并使用定时任务 每天零点做备份
思路
/var/html/www 备份目录
/var/html/ 备份到目标目录
方式一:
1.利用crontab -e 添加下面这行
0 0 * * * tar zcvfP /var/html/www_$(date +\%F).tar.gz /html/www/
0 0 * * * tar zcvfP /var/html/www_$(date +\%F).tar.gz /html/www/ > /dev/null 2>&1
tips:注意一般我们都是将备份日志文件给到黑洞目录,原因是不想让他占用空间,当然你可以加,也可以不加这行的,我个人添加的这行
2.测试
查看是否备份成功
cd /var/html
方式二:
利用脚本+定时任务+邮件通知
这一步是我自己加的,你可以不做,可省略,看需求
邮件配置
邮件
linux服务器---企业邮箱163 -----运维人员(QQ邮箱)
准备:
安装postfix yum -y install postfix
安装mailx yum install mailx -y
启用postfix systemctl enable postfix
systemctl start postfix
关闭防火墙 systemctl stop firewalld
selinux getenforce 0
systemctl stop firewalld
getenforce 0
systemctl enable postfix
systemctl restart postfix
systemctl status postfix
1.配置163企业邮箱
2.编写linux服务邮件相关配置文件
[root@master ~]# vi /etc/mail.rc
set smtp-auth-user=用户名@163.com
set smtp-auth-password=客户端授权密码
set smtp-auth=login
set from=15178374440@163.com 你自己的账户
set smtp=smtp.163.com 填写配置的邮箱
set smtp-auth-user=15178374440@163.com 自己的账户
set smtp-auth-password=SQRLLCVNTQXQHAQX 授权码唯一 (为了安全所以这个是无效的授权码)
set smtp-auth=login 自动登录
[root@master ~]# vim /etc/mail.rc
把下面这个粘贴进去,如果粘贴格式有问题 ,可以用:set paste 模式确保粘贴不会出现问题
set from=15178374440@163.com
set smtp=smtp.163.com
set smtp-auth-user=15178374440@163.com
set smtp-auth-password=SQRLLCVNTQXQHAQX
set smtp-auth=login
[root@master ~]# systemctl restart postfix.service
3.发送邮件测试
echo "系统有异常问题,请检查系统" |mail -s "异常警告" 15178374440@163.com
echo "nginx服务挂了" | mailx -s "预警" 15178374440@163.com
cat /etc/hosts | mailx -s "Hosts File Content" 15178374440@163.com
cat /etc/hosts | mailx -s "Hosts File Content" 3078499367@qq.com
也可以目录信息发送到邮箱里
上面是配置邮件的,你可以不配置,省略就看下一步
实现第二种方法:脚本
下面就是脚本配置了
1.选定一个目录创建脚本
/usr/local/bin/
cd /usr/loca/bin/
vi bakcup.sh
添加下面这行
#!/bin/bash
SOURCE_DIR="/html/www/"
BACKUP_DIR="/var/html/"
TODAY=$(date +%F)
BACKUP_FILE="${BACKUP_DIR}www_${TODAY}.tar.gz"
tar zcvfP "${BACKUP_FILE}" "${SOURCE_DIR}"
if [ $? -eq 0 ]; then
echo "备份${SOURCE_DIR}至${BACKUP_FILE}成功,备份时间:$(date)" | mail -s "每日备份报告:成功" 15178374440@163.com
else
echo "备份${SOURCE_DIR}失败,备份时间:$(date)" | mail -s "每日备份报告:失败" 15178374440@163.com
fi
echo "Backup of ${SOURCE_DIR} completed at $(date)" >> /var/log/backup.log
tips:
脚本注解:
这是一个简单的bash shell脚本,其主要目的是备份`/html/www/`目录下的文件,并在备份完成后通过电子邮件发送备份结果通知。以下是脚本各部分的详细解释:
1. `#!/bin/bash`:这是shebang行,告诉系统使用bash shell来执行此脚本。
2. 定义变量:
- `SOURCE_DIR="/html/www/"`:定义备份源目录。
- `BACKUP_DIR="/var/html/"`:定义备份目标目录,备份文件将存储于此。
- `TODAY=$(date +%F)`:使用`date`命令获取当前日期,并将格式化后的日期赋值给变量`TODAY`,格式为年-月-日。
3. 执行备份命令:
- `tar zcvfP "${BACKUP_FILE}" "${SOURCE_DIR}"`:使用`tar`命令创建一个gzip压缩的归档文件,包含了`SOURCE_DIR`目录下的所有文件和子目录。`${BACKUP_FILE}`是备份文件的路径和名称,由`BACKUP_DIR`和`TODAY`变量拼接而成,格式为`/var/html/www_年-月-日.tar.gz`。
4. 判断备份是否成功:
- `if [ $? -eq 0 ]; then ... else ... fi`:`$?`是一个特殊的bash变量,它表示上一条命令的退出状态码。如果`tar`命令执行成功(退出状态码为0),则执行“then”块内的语句;否则执行“else”块内的语句。
5. 成功与失败情况的邮件通知:
- 当备份成功时,通过`mail`命令发送一封标题为“每日备份报告:成功”的邮件,邮件内容为备份成功的消息以及备份时间,发送给指定的邮箱地址`15178374440@163.com`。
- 当备份失败时,发送一封标题为“每日备份报告:失败”的邮件,邮件内容为备份失败的消息以及备份时间,同样发送给`15178374440@163.com`。
6. 日志记录:
- `echo "Backup of ${SOURCE_DIR} completed at $(date)" >> /var/log/backup.log`:无论备份成功与否,都将备份完成的相关信息追加到日志文件`/var/log/backup.log`中。
注意:虽然脚本中包含了邮件通知功能,但由于默认的`mail`命令通常无法直接通过SMTP服务器发送邮件,所以在实际环境中,你可能需要配置mail客户端(如`mailx`、`ssmtp`或`msmtp`)以通过163邮箱的SMTP服务器发送邮件,并在邮件客户端配置中填写正确的SMTP服务器、端口、用户名和密码信息。
如果你先实现邮件通知那就要配置邮件服务,如果不想实现,可以删除邮件通知那行的
2.给执行权限
chmod +x backup.sh
3.添加定时任务(根据自己需求来)
crontab -e
添加下面这行
0 0 * * * /usr/local/bin/backup.sh
tips:
crontab定时配置文件提示:分 时 日 月 周
4.测试看执行效果
bash backup.sh
这时如果你配置了邮件的话,可以去看邮件有没有,如果没有,看终端的信息就可以了
具体演示执行效果
第一种:
[root@web ~]# cd /var/html/
[root@web html]# ls
www_2024-03-21.tar.gz
[root@web html]# cd /html/www/
[root@web www]# ls
1 12 16 2 23 27 30 34 38 41 45 49 52 56 6 63 67 70 74 78 81 85 89 92 96
10 13 17 20 24 28 31 35 39 42 46 5 53 57 60 64 68 71 75 79 82 86 9 93 97
100 14 18 21 25 29 32 36 4 43 47 50 54 58 61 65 69 72 76 8 83 87 90 94 98
11 15 19 22 26 3 33 37 40 44 48 51 55 59 62 66 7 73 77 80 84 88 91 95 99
[root@web www]# tar zcvfP /var/html/www_$(date +\%F).tar.gz /html/www/
/html/www/
/html/www/1
/html/www/2
/html/www/3
/html/www/4
/html/www/5
/html/www/6
/html/www/7
/html/www/8
/html/www/9
/html/www/10
/html/www/11
/html/www/12
/html/www/13
/html/www/14
/html/www/15
/html/www/16
/html/www/17
/html/www/18
/html/www/19
/html/www/20
/html/www/21
/html/www/22
/html/www/23
/html/www/24
/html/www/25
/html/www/26
/html/www/27
/html/www/28
/html/www/29
/html/www/30
/html/www/31
/html/www/32
/html/www/33
/html/www/34
/html/www/35
/html/www/36
/html/www/37
/html/www/38
/html/www/39
/html/www/40
/html/www/41
/html/www/42
/html/www/43
/html/www/44
/html/www/45
/html/www/46
/html/www/47
/html/www/48
/html/www/49
/html/www/50
/html/www/51
/html/www/52
/html/www/53
/html/www/54
/html/www/55
/html/www/56
/html/www/57
/html/www/58
/html/www/59
/html/www/60
/html/www/61
/html/www/62
/html/www/63
/html/www/64
/html/www/65
/html/www/66
/html/www/67
/html/www/68
/html/www/69
/html/www/70
/html/www/71
/html/www/72
/html/www/73
/html/www/74
/html/www/75
/html/www/76
/html/www/77
/html/www/78
/html/www/79
/html/www/80
/html/www/81
/html/www/82
/html/www/83
/html/www/84
/html/www/85
/html/www/86
/html/www/87
/html/www/88
/html/www/89
/html/www/90
/html/www/91
/html/www/92
/html/www/93
/html/www/94
/html/www/95
/html/www/96
/html/www/97
/html/www/98
/html/www/99
/html/www/100
[root@web www]# ls
1 12 16 2 23 27 30 34 38 41 45 49 52 56 6 63 67 70 74 78 81 85 89 92 96
10 13 17 20 24 28 31 35 39 42 46 5 53 57 60 64 68 71 75 79 82 86 9 93 97
100 14 18 21 25 29 32 36 4 43 47 50 54 58 61 65 69 72 76 8 83 87 90 94 98
11 15 19 22 26 3 33 37 40 44 48 51 55 59 62 66 7 73 77 80 84 88 91 95 99
[root@web www]# cd ..
[root@web html]# ls
www
[root@web html]# cd www/
[root@web www]# ls
1 12 16 2 23 27 30 34 38 41 45 49 52 56 6 63 67 70 74 78 81 85 89 92 96
10 13 17 20 24 28 31 35 39 42 46 5 53 57 60 64 68 71 75 79 82 86 9 93 97
100 14 18 21 25 29 32 36 4 43 47 50 54 58 61 65 69 72 76 8 83 87 90 94 98
11 15 19 22 26 3 33 37 40 44 48 51 55 59 62 66 7 73 77 80 84 88 91 95 99
[root@web www]# cd /var/html/
[root@web html]# ls
www_2024-03-21.tar.gz
[root@web html]# crontab -e
0 0 * * * tar zcvfP /var/html/www_$(date +\%F).tar.gz /html/www/ > /dev/null 2>&1
[root@web html]# ls
www_2024-03-21.tar.gz
邮件配置演示(可以不做)
具体过程演示
[root@web ~]# yum -y install postfix
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Updating:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
===========================================================================================================
Upgrade 1 Package
Total download size: 2.4 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
postfix-2.10.1-9.el7.x86_64.rpm | 2.4 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 2:postfix-2.10.1-9.el7.x86_64 1/2
Cleanup : 2:postfix-2.10.1-6.el7.x86_64 2/2
Verifying : 2:postfix-2.10.1-9.el7.x86_64 1/2
Verifying : 2:postfix-2.10.1-6.el7.x86_64 2/2
Updated:
postfix.x86_64 2:2.10.1-9.el7
Complete!
[root@web ~]# yum install mailx -y
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package mailx.x86_64 0:12.5-19.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
mailx x86_64 12.5-19.el7 base 245 k
Transaction Summary
===========================================================================================================
Install 1 Package
Total download size: 245 k
Installed size: 466 k
Downloading packages:
mailx-12.5-19.el7.x86_64.rpm | 245 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mailx-12.5-19.el7.x86_64 1/1
warning: /etc/mail.rc created as /etc/mail.rc.rpmnew
Verifying : mailx-12.5-19.el7.x86_64 1/1
Installed:
mailx.x86_64 0:12.5-19.el7
Complete!
[root@web ~]# systemctl stop firewalld
[root@web ~]# getenforce 0
Disabled
[root@web ~]# systemctl enable postfix
[root@web ~]# systemctl restart postfix
[root@web ~]# systemctl status postfix
postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
Active: active (running) since Thu 2024-03-21 11:33:18 CST; 11s ago
Process: 12325 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
Process: 12341 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 12338 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 12335 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 12413 (master)
CGroup: /system.slice/postfix.service
├─12413 /usr/libexec/postfix/master -w
├─12414 pickup -l -t unix -u
└─12415 qmgr -l -t unix -u
Mar 21 11:33:18 web systemd[1]: Starting Postfix Mail Transport Agent...
Mar 21 11:33:18 web postfix/postfix-script[12411]: starting the Postfix mail system
Mar 21 11:33:18 web postfix/master[12413]: daemon started -- version 2.10.1, configuration /etc/postfix
Mar 21 11:33:18 web systemd[1]: Started Postfix Mail Transport Agent.
[root@web ~]# echo "系统有异常问题,请检查系统" |mail -s "异常警告" 15178374440@163.com
[root@web ~]# echo "nginx服务挂了" | mailx -s "预警" 15178374440@163.com
这条命令是别的邮箱给添加进去,这样你可以发送到别的邮箱了,当然你不加也可以的
[root@web ~]# cat /etc/hosts | mailx -s "Hosts File Content" 3078499367@qq.com
[root@web ~]# echo "nginx服务挂了" | mailx -s "预警" 3078499367@qq.com
总结:现在你的服务端的邮件服务器就是163邮箱服务了,任何你发出去的邮箱都是163为邮件服务发送出去的
第二种方法具体演示
[root@web ~]# cd /usr/local/bin/
[root@web bin]# ls
backup.sh
[root@web bin]# vi backup.sh
添加这行
#!/bin/bash
# 定义备份源目录和备份目标目录
SOURCE_DIR="/html/www/"
BACKUP_DIR="/var/html/"
TODAY=$(date +%F)
BACKUP_FILE="${BACKUP_DIR}www_${TODAY}.tar.gz"
# 执行备份命令
tar zcvfP "${BACKUP_FILE}" "${SOURCE_DIR}"
# 判断备份是否成功
if [ $? -eq 0 ]; then
echo "备份${SOURCE_DIR}至${BACKUP_FILE}成功,备份时间:$(date)" | mail -s "每日备份报告:成功" 15178374440@163.com
else
echo "备份${SOURCE_DIR}失败,备份时间:$(date)" | mail -s "每日备份报告:失败" 15178374440@163.com
fi
# 可选:输出日志
echo "Backup of ${SOURCE_DIR} completed at $(date)" >> /var/log/backup.log
[root@web bin]# chmod +x backup.sh
[root@web bin]# ls
backup.sh
[root@web bin]# ll
total 4
-rwxr-xr-x 1 root root 655 Mar 21 12:51 backup.sh
[root@web bin]# crontab -e
添加这行(根据自己的需要,设置什么时间备份执行脚本)
0 0 * * * /usr/local/bin/backup.sh
[root@web bin]# bash backup.sh
/html/www/
/html/www/1
/html/www/2
/html/www/3
/html/www/4
/html/www/5
/html/www/6
/html/www/7
/html/www/8
/html/www/9
/html/www/10
/html/www/11
/html/www/12
/html/www/13
/html/www/14
/html/www/15
/html/www/16
/html/www/17
/html/www/18
/html/www/19
/html/www/20
/html/www/21
/html/www/22
/html/www/23
/html/www/24
/html/www/25
/html/www/26
/html/www/27
/html/www/28
/html/www/29
/html/www/30
/html/www/31
/html/www/32
/html/www/33
/html/www/34
/html/www/35
/html/www/36
/html/www/37
/html/www/38
/html/www/39
/html/www/40
/html/www/41
/html/www/42
/html/www/43
/html/www/44
/html/www/45
/html/www/46
/html/www/47
/html/www/48
/html/www/49
/html/www/50
/html/www/51
/html/www/52
/html/www/53
/html/www/54
/html/www/55
/html/www/56
/html/www/57
/html/www/58
/html/www/59
/html/www/60
/html/www/61
/html/www/62
/html/www/63
/html/www/64
/html/www/65
/html/www/66
/html/www/67
/html/www/68
/html/www/69
/html/www/70
/html/www/71
/html/www/72
/html/www/73
/html/www/74
/html/www/75
/html/www/76
/html/www/77
/html/www/78
/html/www/79
/html/www/80
/html/www/81
/html/www/82
/html/www/83
/html/www/84
/html/www/85
/html/www/86
/html/www/87
/html/www/88
/html/www/89
/html/www/90
/html/www/91
/html/www/92
/html/www/93
/html/www/94
/html/www/95
/html/www/96
/html/www/97
/html/www/98
/html/www/99
/html/www/100
可以看到已经成功了
做了邮件通知的,可以去看一下邮箱的
邮件通知测试
2.实战 查找 7天之前备份项目 删掉
+7 超过七天内被访问过的所有文件
-7 最近七天内被访问过的所有文件
7 恰好在七天前被访问过的所有文件
find /backup/ -type f -mtime +7 -exec rm -f {} \;
find /backup/ -type f -mtime +7 -name "www_*" -exec rm -f {} \;
find /bakcup -type f -mtime +7 |xargs rm -rf
+7 超过七天内被访问过的所有文件
-7 最近七天内被访问过的所有文件
7 恰好在七天前被访问过的所有文件
find回顾
find语法
根据文件名称查找 find / -type f -name "*.txt"
根据文件大小查找 find / -type f -size +100k
根据日期查找 find / -type f -mtime +30
根据权限查找 find / -type f -perm 777
根据属主属组查找 find / -type f -user root
搜索最近七天内被访问过的所有文件
find . -type f -atime -7
搜索恰好在七天前被访问过的所有文件
find . -type f -atime 7
搜索超过七天内被访问过的所有文件
find . -type f -atime +7
根据文件或者正则表达式进行匹配
列出当前目录及子目录下所有文件和文件夹
find .
在/home目录下查找以.txt结尾的文件名
find /home -name "*.txt"
同上,但忽略大小写
find /home -iname "*.txt"
当前目录及子目录下查找所有以.txt和.pdf结尾的文件
find . \( -name "*.txt" -o -name "*.pdf" \)
或
find . -name "*.txt" -o -name "*.pdf"
匹配文件路径或者文件
find /usr/ -path "*local*"
基于正则表达式匹配文件路径
find . -regex ".*\(\.txt\|\.pdf\)$"
同上,但忽略大小写
find . -iregex ".*\(\.txt\|\.pdf\)$"
否定参数
找出/home下不是以.txt结尾的文件
find /home ! -name "*.txt"
根据文件类型进行搜索
find . -type 类型参数
类型参数列表:
f 普通文件
l 符号连接
d 目录
c 字符设备
b 块设备
s 套接字
p Fifo
基于目录深度搜索
向下最大深度限制为3
find . -maxdepth 3 -type f
搜索出深度距离当前目录至少2个子目录的所有文件
find . -mindepth 2 -type f
根据文件时间戳进行搜索
find . -type f 时间戳
UNIX/Linux文件系统每个文件都有三种时间戳:
访问时间(-atime/天,-amin/分钟):用户最近一次访问时间。
修改时间(-mtime/天,-mmin/分钟):文件最后一次修改时间。
变化时间(-ctime/天,-cmin/分钟):文件数据元(例如权限等)最后一次修改时间。
搜索最近七天内被访问过的所有文件
find . -type f -atime -7
搜索恰好在七天前被访问过的所有文件
find . -type f -atime 7
搜索超过七天内被访问过的所有文件
find . -type f -atime +7
搜索访问时间超过10分钟的所有文件
find . -type f -amin +10
找出比file.log修改时间更长的所有文件
find . -type f -newer file.log
根据文件大小进行匹配
find . -type f -size 文件大小单元
文件大小单元:
b —— 块(512字节)
c —— 字节
w —— 字(2字节)
k —— 千字节
M —— 兆字节
G —— 吉字节
搜索大于10KB的文件
find . -type f -size +10k
搜索小于10KB的文件
find . -type f -size -10k
搜索等于10KB的文件
find . -type f -size 10k
删除匹配文件
删除当前目录下所有.txt文件
find . -type f -name "*.txt" -delete
根据文件权限/所有权进行匹配
当前目录下搜索出权限为777的文件
find . -type f -perm 777
找出当前目录下权限不是644的php文件
find . -type f -name "*.php" ! -perm 644
找出当前目录用户tom拥有的所有文件
find . -type f -user tom
找出当前目录用户组sunk拥有的所有文件
find . -type f -group sunk
借助-exec选项与其他命令结合使用
找出当前目录下所有root的文件,并把所有权更改为用户tom
find .-type f -user root -exec chown tom {} \;
上例中,{} 用于与-exec选项结合使用来匹配所有文件,然后会被替换为相应的文件名。
找出自己家目录下所有的.txt文件并删除
find $HOME/. -name "*.txt" -ok rm {} \;
上例中,-ok和-exec行为一样,不过它会给出提示,是否执行相应的操作。
查找当前目录下所有.txt文件并把他们拼接起来写入到all.txt文件中
find . -type f -name "*.txt" -exec cat {} \;> all.txt
将30天前的.log文件移动到old目录中
find . -type f -mtime +30 -name "*.log" -exec cp {} old \;
找出当前目录下所有.txt文件并以“File:文件名”的形式打印出来
find . -type f -name "*.txt" -exec printf "File: %s\n" {} \;
因为单行命令中-exec参数中无法使用多个命令,以下方法可以实现在-exec之后接受多条命令
-exec ./text.sh {} \;
搜索但跳出指定的目录
查找当前目录或者子目录下所有.txt文件,但是跳过子目录sk
find . -path "./sk" -prune -o -name "*.txt" -print
find其他技巧收集
要列出所有长度为零的文件
find . -empty
工作需求 3: 部署nfs 存储,在nginx 服务器 把nfs共享目录 挂载到 nginx 发布目录 实战演示 (工作经常用到重点掌握 ) 写出操作笔记 方便工作直接参考
解题思路:
1.至少需要两台设备 NFS服务端(文件共享) nginx服务端(网站)
2.在nginx服务端上,通过网络挂载到NFS 服务端共享的目录
3.将 NFS 服务器挂载到nginx的发布目录
最终实现:以后NFS服务器如果有任何更新了,nginx那边也会跟着更新的,一般都是nginx的资源比如图片之类的,放在自己的服务器上占内存,所以需要一个NFS文件共享服务器分担nginx的内存压力,用户访问网站的时候,尤其是图片一些内容,不走nginx这里了,走NFS服务器这里
必须熟知的nginx安装方式
#nginx安装方式和配置路径
第一种:yum
yum安装的Nginx配置路径、发布路径(默认网页根目录)和日志路径如下:
配置路径:
默认配置文件路径:/etc/nginx/nginx.conf
网站级别的配置文件通常位于:/etc/nginx/conf.d/目录下,可以根据需要创建单独的配置文件。
发布路径(默认网页根目录):
默认发布目录:/usr/share/nginx/html
日志路径:
错误日志:/var/log/nginx/error.log
访问日志:/var/log/nginx/access.log
第二种:编译安装
编辑安装nginx路径具体看自己解压到那个目录了
yum -y install pcre-devel openssl-devel zlib-devel gcc
groupadd nginx
useradd -g nginx -s /sbin/nologin nginx
切换到解压后的nginx目录中执行:
wget http://nginx.org/download/nginx-1.18.0.tar.gz
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx
--with-http_ssl_module --with-http_stub_status_module
make make install
编译安装这里每次起手都需要路径启动,一般我们可以定义软连接
sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
不知道命令安装路径的可以用which查一下
启动nginx:/usr/local/nginx/sbin/nginx
关闭nginx:/usr/local/nginx/sbin/nginx -s stop
检查nginx 是否异常:/usr/local/nginx/sbin/nginx -t
重启nginx: nginx -s reload
测试环境
虚拟机
ip:10.0.1.0
网关:10.0.1.2
子网掩码:255.255.255.0
nfs服务器:10.0.1.115
nginx服务器:10.0.1.116
1.部署nfs服务端
nfs服务端 10.0.1.115
yum install -y nfs-utils
mkdir /data
vim /etc/exports
/data 10.0.1.0/24(rw,sync,no_root_squash,no_all_squash)
启动并查看进程是否运行
systemctl start nfs
systemctl start rpcbind
systemctl status nfs
systemctl status rpcbind
如有需要停止,可输入
systemctl stop nfs
systemctl stop rpcbind
systemctl enable rpcbind
systemctl enable nfs
检查 NFS 服务器端是否有目录共享
showmount -e 10.0.1.115
/data 共享目录
10.0.0.0/24 授权ip网段
(rw,sync,no_root_squash,no_all_squash)
tips:
rw:读写
sync:同步写入内存和硬盘
no_root_squash:root身份访问
no_all_squash:所有用户不能转换匿名用户
2.部署nginx服务端
yum install -y nfs-utils
yum install -y nginx
如果你没有安装nginx的话安装一下
检查一下有没有共享
showmount -e 10.0.1.115
mkdir -p /html/www
mount -t nfs 10.0.1.115:/data /html/www
df -h
3.将nfs服务端挂载到nginx的发布目录
cd /etc/nginx
vi nginx.conf
tips:由于这里我是用yum安装的,所以是这个目录,如果是编译安装,那么编译安装的话,就看你自己的解压和安装路径了,可以用which 或者ps aux |grep nginx
这样看进程的方式查看路径寻找
修改这个位置:
把你自己nginx设置的共享目录填上去,我这里是/html/www 如果你设置的是其他名字那就换成你自己设置的
server {
listen 80;
listen [::]:80;
server_name _;
root /html/www;
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /html/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /html/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
具体效果演示
1.部署nfs服务端
nfs服务端 10.0.1.115
[root@nfs ~]# yum install -y nfs-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyuncs.com
* extras: mirrors.aliyuncs.com
* updates: mirrors.aliyuncs.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:02
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be installed
--> Processing Dependency: libtirpc >= 0.2.4-0.7 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: gssproxy >= 0.7.0-3 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: rpcbind for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: quota for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libnfsidmap for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libevent for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: keyutils for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libevent-2.0.so.5()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Running transaction check
---> Package gssproxy.x86_64 0:0.7.0-30.el7_9 will be installed
--> Processing Dependency: libini_config >= 1.3.1-31 for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libverto-module-base for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libref_array.so.1(REF_ARRAY_0.1.1)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3(INI_CONFIG_1.2.0)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3(INI_CONFIG_1.1.0)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libref_array.so.1()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libcollection.so.2()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libbasicobjects.so.0()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
---> Package keyutils.x86_64 0:1.5.8-3.el7 will be installed
---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed
---> Package libnfsidmap.x86_64 0:0.25-19.el7 will be installed
---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed
---> Package quota.x86_64 1:4.01-19.el7 will be installed
--> Processing Dependency: quota-nls = 1:4.01-19.el7 for package: 1:quota-4.01-19.el7.x86_64
--> Processing Dependency: tcp_wrappers for package: 1:quota-4.01-19.el7.x86_64
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be installed
--> Running transaction check
---> Package libbasicobjects.x86_64 0:0.1.1-32.el7 will be installed
---> Package libcollection.x86_64 0:0.7.0-32.el7 will be installed
---> Package libini_config.x86_64 0:1.3.1-32.el7 will be installed
--> Processing Dependency: libpath_utils.so.1(PATH_UTILS_0.2.1)(64bit) for package: libini_config-1.3.1-32.el7.x86_64
--> Processing Dependency: libpath_utils.so.1()(64bit) for package: libini_config-1.3.1-32.el7.x86_64
---> Package libref_array.x86_64 0:0.1.5-32.el7 will be installed
---> Package libverto-libevent.x86_64 0:0.2.5-4.el7 will be installed
---> Package quota-nls.noarch 1:4.01-19.el7 will be installed
---> Package tcp_wrappers.x86_64 0:7.6-77.el7 will be installed
--> Running transaction check
---> Package libpath_utils.x86_64 0:0.2.1-32.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
Installing for dependencies:
gssproxy x86_64 0.7.0-30.el7_9 updates 111 k
keyutils x86_64 1.5.8-3.el7 base 54 k
libbasicobjects x86_64 0.1.1-32.el7 base 26 k
libcollection x86_64 0.7.0-32.el7 base 42 k
libevent x86_64 2.0.21-4.el7 base 214 k
libini_config x86_64 1.3.1-32.el7 base 64 k
libnfsidmap x86_64 0.25-19.el7 base 50 k
libpath_utils x86_64 0.2.1-32.el7 base 28 k
libref_array x86_64 0.1.5-32.el7 base 27 k
libtirpc x86_64 0.2.4-0.16.el7 base 89 k
libverto-libevent x86_64 0.2.5-4.el7 base 8.9 k
quota x86_64 1:4.01-19.el7 base 179 k
quota-nls noarch 1:4.01-19.el7 base 90 k
rpcbind x86_64 0.2.0-49.el7 base 60 k
tcp_wrappers x86_64 7.6-77.el7 base 78 k
Transaction Summary
===========================================================================================================
Install 1 Package (+15 Dependent packages)
Total download size: 1.5 M
Installed size: 4.3 M
Downloading packages:
(1/16): gssproxy-0.7.0-30.el7_9.x86_64.rpm | 111 kB 00:00:00
(2/16): libbasicobjects-0.1.1-32.el7.x86_64.rpm | 26 kB 00:00:00
(3/16): libcollection-0.7.0-32.el7.x86_64.rpm | 42 kB 00:00:00
(4/16): libevent-2.0.21-4.el7.x86_64.rpm | 214 kB 00:00:00
(5/16): libini_config-1.3.1-32.el7.x86_64.rpm | 64 kB 00:00:00
(6/16): libnfsidmap-0.25-19.el7.x86_64.rpm | 50 kB 00:00:00
(7/16): libpath_utils-0.2.1-32.el7.x86_64.rpm | 28 kB 00:00:00
(8/16): libref_array-0.1.5-32.el7.x86_64.rpm | 27 kB 00:00:00
(9/16): libtirpc-0.2.4-0.16.el7.x86_64.rpm | 89 kB 00:00:00
(10/16): keyutils-1.5.8-3.el7.x86_64.rpm | 54 kB 00:00:00
(11/16): libverto-libevent-0.2.5-4.el7.x86_64.rpm | 8.9 kB 00:00:00
(12/16): quota-nls-4.01-19.el7.noarch.rpm | 90 kB 00:00:00
(13/16): quota-4.01-19.el7.x86_64.rpm | 179 kB 00:00:00
(14/16): rpcbind-0.2.0-49.el7.x86_64.rpm | 60 kB 00:00:00
(15/16): tcp_wrappers-7.6-77.el7.x86_64.rpm | 78 kB 00:00:00
(16/16): nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm | 413 kB 00:00:00
-----------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 1.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libbasicobjects-0.1.1-32.el7.x86_64 1/16
Installing : libref_array-0.1.5-32.el7.x86_64 2/16
Installing : libcollection-0.7.0-32.el7.x86_64 3/16
Installing : libevent-2.0.21-4.el7.x86_64 4/16
Installing : libtirpc-0.2.4-0.16.el7.x86_64 5/16
Installing : rpcbind-0.2.0-49.el7.x86_64 6/16
Installing : libverto-libevent-0.2.5-4.el7.x86_64 7/16
Installing : 1:quota-nls-4.01-19.el7.noarch 8/16
Installing : tcp_wrappers-7.6-77.el7.x86_64 9/16
Installing : 1:quota-4.01-19.el7.x86_64 10/16
Installing : keyutils-1.5.8-3.el7.x86_64 11/16
Installing : libnfsidmap-0.25-19.el7.x86_64 12/16
Installing : libpath_utils-0.2.1-32.el7.x86_64 13/16
Installing : libini_config-1.3.1-32.el7.x86_64 14/16
Installing : gssproxy-0.7.0-30.el7_9.x86_64 15/16
Installing : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 16/16
Verifying : libtirpc-0.2.4-0.16.el7.x86_64 1/16
Verifying : gssproxy-0.7.0-30.el7_9.x86_64 2/16
Verifying : 1:quota-4.01-19.el7.x86_64 3/16
Verifying : libpath_utils-0.2.1-32.el7.x86_64 4/16
Verifying : libnfsidmap-0.25-19.el7.x86_64 5/16
Verifying : libevent-2.0.21-4.el7.x86_64 6/16
Verifying : keyutils-1.5.8-3.el7.x86_64 7/16
Verifying : libverto-libevent-0.2.5-4.el7.x86_64 8/16
Verifying : tcp_wrappers-7.6-77.el7.x86_64 9/16
Verifying : libcollection-0.7.0-32.el7.x86_64 10/16
Verifying : 1:quota-nls-4.01-19.el7.noarch 11/16
Verifying : libref_array-0.1.5-32.el7.x86_64 12/16
Verifying : libbasicobjects-0.1.1-32.el7.x86_64 13/16
Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 14/16
Verifying : libini_config-1.3.1-32.el7.x86_64 15/16
Verifying : rpcbind-0.2.0-49.el7.x86_64 16/16
Installed:
nfs-utils.x86_64 1:1.3.0-0.68.el7.2
Dependency Installed:
gssproxy.x86_64 0:0.7.0-30.el7_9 keyutils.x86_64 0:1.5.8-3.el7
libbasicobjects.x86_64 0:0.1.1-32.el7 libcollection.x86_64 0:0.7.0-32.el7
libevent.x86_64 0:2.0.21-4.el7 libini_config.x86_64 0:1.3.1-32.el7
libnfsidmap.x86_64 0:0.25-19.el7 libpath_utils.x86_64 0:0.2.1-32.el7
libref_array.x86_64 0:0.1.5-32.el7 libtirpc.x86_64 0:0.2.4-0.16.el7
libverto-libevent.x86_64 0:0.2.5-4.el7 quota.x86_64 1:4.01-19.el7
quota-nls.noarch 1:4.01-19.el7 rpcbind.x86_64 0:0.2.0-49.el7
tcp_wrappers.x86_64 0:7.6-77.el7
Complete!
[root@nfs ~]# yum -y install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyuncs.com
* extras: mirrors.aliyuncs.com
* updates: mirrors.aliyuncs.com
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.20.1-10.el7 will be installed
--> Processing Dependency: nginx-filesystem = 1:1.20.1-10.el7 for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Running transaction check
---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
---> Package nginx-filesystem.noarch 1:1.20.1-10.el7 will be installed
---> Package openssl11-libs.x86_64 1:1.1.1k-7.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
nginx x86_64 1:1.20.1-10.el7 epel 588 k
Installing for dependencies:
centos-indexhtml noarch 7-9.el7.centos base 92 k
gperftools-libs x86_64 2.6.1-1.el7 base 272 k
nginx-filesystem noarch 1:1.20.1-10.el7 epel 24 k
openssl11-libs x86_64 1:1.1.1k-7.el7 epel 1.5 M
Transaction Summary
===========================================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 2.4 M
Installed size: 6.7 M
Downloading packages:
(1/5): centos-indexhtml-7-9.el7.centos.noarch.rpm | 92 kB 00:00:00
(2/5): nginx-filesystem-1.20.1-10.el7.noarch.rpm | 24 kB 00:00:00
(3/5): nginx-1.20.1-10.el7.x86_64.rpm | 588 kB 00:00:00
(4/5): gperftools-libs-2.6.1-1.el7.x86_64.rpm | 272 kB 00:00:00
(5/5): openssl11-libs-1.1.1k-7.el7.x86_64.rpm | 1.5 MB 00:00:00
-----------------------------------------------------------------------------------------------------------
Total 2.4 MB/s | 2.4 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:openssl11-libs-1.1.1k-7.el7.x86_64 1/5
Installing : 1:nginx-filesystem-1.20.1-10.el7.noarch 2/5
Installing : centos-indexhtml-7-9.el7.centos.noarch 3/5
Installing : gperftools-libs-2.6.1-1.el7.x86_64 4/5
Installing : 1:nginx-1.20.1-10.el7.x86_64 5/5
Verifying : gperftools-libs-2.6.1-1.el7.x86_64 1/5
Verifying : centos-indexhtml-7-9.el7.centos.noarch 2/5
Verifying : 1:nginx-filesystem-1.20.1-10.el7.noarch 3/5
Verifying : 1:nginx-1.20.1-10.el7.x86_64 4/5
Verifying : 1:openssl11-libs-1.1.1k-7.el7.x86_64 5/5
Installed:
nginx.x86_64 1:1.20.1-10.el7
Dependency Installed:
centos-indexhtml.noarch 0:7-9.el7.centos gperftools-libs.x86_64 0:2.6.1-1.el7
nginx-filesystem.noarch 1:1.20.1-10.el7 openssl11-libs.x86_64 1:1.1.1k-7.el7
Complete!
[root@nfs ~]# vi /etc/exports
[root@nfs ~]# systemctl restart rpcbind
[root@nfs ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@nfs ~]# showmount -e 10.0.1.115
clnt_create: RPC: Program not registered
[root@nfs ~]# mkdir /data
[root@nfs ~]# showmount -e 10.0.1.115
clnt_create: RPC: Program not registered
[root@nfs ~]# ls
anaconda-ks.cfg ifcfg-eno16777736 it01
[root@nfs ~]# mkdir data
[root@nfs ~]# ls
anaconda-ks.cfg data ifcfg-eno16777736 it01
[root@nfs ~]# showmount -e 10.0.1.115
clnt_create: RPC: Program not registered
[root@nfs ~]# systemctl stop rpcbind
Warning: Stopping rpcbind.service, but it can still be activated by:
rpcbind.socket
[root@nfs ~]# systemctl start rpcbind
[root@nfs ~]# systemctl start nfs
[root@nfs ~]# showmount -e 10.0.1.115
Export list for 10.0.1.115:
/data 10.0.1.0/24
[root@nfs ~]# cd /data
[root@nfs data]# ls
2.部署nginx服务端
nginx服务端ip:10.0.1.116
[root@web ~]# yum install -y nfs-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:02
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:15
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be installed
--> Processing Dependency: libtirpc >= 0.2.4-0.7 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: gssproxy >= 0.7.0-3 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: rpcbind for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: quota for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libnfsidmap for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libevent for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: keyutils for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Processing Dependency: libevent-2.0.so.5()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64
--> Running transaction check
---> Package gssproxy.x86_64 0:0.7.0-30.el7_9 will be installed
--> Processing Dependency: libini_config >= 1.3.1-31 for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libverto-module-base for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libref_array.so.1(REF_ARRAY_0.1.1)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3(INI_CONFIG_1.2.0)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3(INI_CONFIG_1.1.0)(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libref_array.so.1()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libini_config.so.3()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libcollection.so.2()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
--> Processing Dependency: libbasicobjects.so.0()(64bit) for package: gssproxy-0.7.0-30.el7_9.x86_64
---> Package keyutils.x86_64 0:1.5.8-3.el7 will be installed
---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed
---> Package libnfsidmap.x86_64 0:0.25-19.el7 will be installed
---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed
---> Package quota.x86_64 1:4.01-19.el7 will be installed
--> Processing Dependency: quota-nls = 1:4.01-19.el7 for package: 1:quota-4.01-19.el7.x86_64
--> Processing Dependency: tcp_wrappers for package: 1:quota-4.01-19.el7.x86_64
---> Package rpcbind.x86_64 0:0.2.0-49.el7 will be installed
--> Running transaction check
---> Package libbasicobjects.x86_64 0:0.1.1-32.el7 will be installed
---> Package libcollection.x86_64 0:0.7.0-32.el7 will be installed
---> Package libini_config.x86_64 0:1.3.1-32.el7 will be installed
--> Processing Dependency: libpath_utils.so.1(PATH_UTILS_0.2.1)(64bit) for package: libini_config-1.3.1-32.el7.x86_64
--> Processing Dependency: libpath_utils.so.1()(64bit) for package: libini_config-1.3.1-32.el7.x86_64
---> Package libref_array.x86_64 0:0.1.5-32.el7 will be installed
---> Package libverto-libevent.x86_64 0:0.2.5-4.el7 will be installed
---> Package quota-nls.noarch 1:4.01-19.el7 will be installed
---> Package tcp_wrappers.x86_64 0:7.6-77.el7 will be installed
--> Running transaction check
---> Package libpath_utils.x86_64 0:0.2.1-32.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
nfs-utils x86_64 1:1.3.0-0.68.el7.2 updates 413 k
Installing for dependencies:
gssproxy x86_64 0.7.0-30.el7_9 updates 111 k
keyutils x86_64 1.5.8-3.el7 base 54 k
libbasicobjects x86_64 0.1.1-32.el7 base 26 k
libcollection x86_64 0.7.0-32.el7 base 42 k
libevent x86_64 2.0.21-4.el7 base 214 k
libini_config x86_64 1.3.1-32.el7 base 64 k
libnfsidmap x86_64 0.25-19.el7 base 50 k
libpath_utils x86_64 0.2.1-32.el7 base 28 k
libref_array x86_64 0.1.5-32.el7 base 27 k
libtirpc x86_64 0.2.4-0.16.el7 base 89 k
libverto-libevent x86_64 0.2.5-4.el7 base 8.9 k
quota x86_64 1:4.01-19.el7 base 179 k
quota-nls noarch 1:4.01-19.el7 base 90 k
rpcbind x86_64 0.2.0-49.el7 base 60 k
tcp_wrappers x86_64 7.6-77.el7 base 78 k
Transaction Summary
===========================================================================================================
Install 1 Package (+15 Dependent packages)
Total download size: 1.5 M
Installed size: 4.3 M
Downloading packages:
libbasicobjects-0.1.1-32.el7.x FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/libbasicobjects-0.1.1-32.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
Trying other mirror.
libevent-2.0.21-4.el7.x86_64.r FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/libevent-2.0.21-4.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
Trying other mirror.
(1/16): libini_config-1.3.1-32.el7.x86_64.rpm | 64 kB 00:00:00
gssproxy-0.7.0-30.el7_9.x86_64 FAILED
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/Packages/gssproxy-0.7.0-30.el7_9.x86_64.rpm: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
keyutils-1.5.8-3.el7.x86_64.rp FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/keyutils-1.5.8-3.el7.x86_64.rpm: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
libcollection-0.7.0-32.el7.x86 FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/libcollection-0.7.0-32.el7.x86_64.rpm: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
(2/16): libpath_utils-0.2.1-32.el7.x86_64.rpm | 28 kB 00:00:00
(3/16): libtirpc-0.2.4-0.16.el7.x86_64.rpm | 89 kB 00:00:00
(4/16): libverto-libevent-0.2.5-4.el7.x86_64.rpm | 8.9 kB 00:00:00
(5/16): libref_array-0.1.5-32.el7.x86_64.rpm | 27 kB 00:00:00
(6/16): quota-nls-4.01-19.el7.noarch.rpm | 90 kB 00:00:00
(7/16): rpcbind-0.2.0-49.el7.x86_64.rpm | 60 kB 00:00:00
(8/16): quota-4.01-19.el7.x86_64.rpm | 179 kB 00:00:00
(9/16): libbasicobjects-0.1.1-32.el7.x86_64.rpm | 26 kB 00:00:00
(10/16): tcp_wrappers-7.6-77.el7.x86_64.rpm | 78 kB 00:00:00
(11/16): keyutils-1.5.8-3.el7.x86_64.rpm | 54 kB 00:00:00
(12/16): libcollection-0.7.0-32.el7.x86_64.rpm | 42 kB 00:00:00
(13/16): libevent-2.0.21-4.el7.x86_64.rpm | 214 kB 00:00:00
(14/16): gssproxy-0.7.0-30.el7_9.x86_64.rpm | 111 kB 00:00:00
(15/16): nfs-utils-1.3.0-0.68.el7.2.x86_64.rpm | 413 kB 00:00:01
libnfsidmap-0.25-19.el7.x86_64 FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/libnfsidmap-0.25-19.el7.x86_64.rpm: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
(16/16): libnfsidmap-0.25-19.el7.x86_64.rpm | 50 kB 00:00:00
-----------------------------------------------------------------------------------------------------------
Total 146 kB/s | 1.5 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : libbasicobjects-0.1.1-32.el7.x86_64 1/16
Installing : libref_array-0.1.5-32.el7.x86_64 2/16
Installing : libcollection-0.7.0-32.el7.x86_64 3/16
Installing : libevent-2.0.21-4.el7.x86_64 4/16
Installing : libtirpc-0.2.4-0.16.el7.x86_64 5/16
Installing : rpcbind-0.2.0-49.el7.x86_64 6/16
Installing : libverto-libevent-0.2.5-4.el7.x86_64 7/16
Installing : 1:quota-nls-4.01-19.el7.noarch 8/16
Installing : tcp_wrappers-7.6-77.el7.x86_64 9/16
Installing : 1:quota-4.01-19.el7.x86_64 10/16
Installing : keyutils-1.5.8-3.el7.x86_64 11/16
Installing : libnfsidmap-0.25-19.el7.x86_64 12/16
Installing : libpath_utils-0.2.1-32.el7.x86_64 13/16
Installing : libini_config-1.3.1-32.el7.x86_64 14/16
Installing : gssproxy-0.7.0-30.el7_9.x86_64 15/16
Installing : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 16/16
Verifying : libtirpc-0.2.4-0.16.el7.x86_64 1/16
Verifying : gssproxy-0.7.0-30.el7_9.x86_64 2/16
Verifying : 1:quota-4.01-19.el7.x86_64 3/16
Verifying : libpath_utils-0.2.1-32.el7.x86_64 4/16
Verifying : libnfsidmap-0.25-19.el7.x86_64 5/16
Verifying : libevent-2.0.21-4.el7.x86_64 6/16
Verifying : keyutils-1.5.8-3.el7.x86_64 7/16
Verifying : libverto-libevent-0.2.5-4.el7.x86_64 8/16
Verifying : tcp_wrappers-7.6-77.el7.x86_64 9/16
Verifying : libcollection-0.7.0-32.el7.x86_64 10/16
Verifying : 1:quota-nls-4.01-19.el7.noarch 11/16
Verifying : libref_array-0.1.5-32.el7.x86_64 12/16
Verifying : libbasicobjects-0.1.1-32.el7.x86_64 13/16
Verifying : 1:nfs-utils-1.3.0-0.68.el7.2.x86_64 14/16
Verifying : libini_config-1.3.1-32.el7.x86_64 15/16
Verifying : rpcbind-0.2.0-49.el7.x86_64 16/16
Installed:
nfs-utils.x86_64 1:1.3.0-0.68.el7.2
Dependency Installed:
gssproxy.x86_64 0:0.7.0-30.el7_9 keyutils.x86_64 0:1.5.8-3.el7
libbasicobjects.x86_64 0:0.1.1-32.el7 libcollection.x86_64 0:0.7.0-32.el7
libevent.x86_64 0:2.0.21-4.el7 libini_config.x86_64 0:1.3.1-32.el7
libnfsidmap.x86_64 0:0.25-19.el7 libpath_utils.x86_64 0:0.2.1-32.el7
libref_array.x86_64 0:0.1.5-32.el7 libtirpc.x86_64 0:0.2.4-0.16.el7
libverto-libevent.x86_64 0:0.2.5-4.el7 quota.x86_64 1:4.01-19.el7
quota-nls.noarch 1:4.01-19.el7 rpcbind.x86_64 0:0.2.0-49.el7
tcp_wrappers.x86_64 0:7.6-77.el7
Complete!
[root@web ~]# yum install -y nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.20.1-10.el7 will be installed
--> Processing Dependency: nginx-filesystem = 1:1.20.1-10.el7 for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.1-10.el7.x86_64
--> Running transaction check
---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
---> Package nginx-filesystem.noarch 1:1.20.1-10.el7 will be installed
---> Package openssl11-libs.x86_64 1:1.1.1k-7.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
nginx x86_64 1:1.20.1-10.el7 epel 588 k
Installing for dependencies:
centos-indexhtml noarch 7-9.el7.centos base 92 k
gperftools-libs x86_64 2.6.1-1.el7 base 272 k
nginx-filesystem noarch 1:1.20.1-10.el7 epel 24 k
openssl11-libs x86_64 1:1.1.1k-7.el7 epel 1.5 M
Transaction Summary
===========================================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 2.4 M
Installed size: 6.7 M
Downloading packages:
(1/5): nginx-filesystem-1.20.1-10.el7.noarch.rpm | 24 kB 00:00:00
(2/5): centos-indexhtml-7-9.el7.centos.noarch.rpm | 92 kB 00:00:00
(3/5): nginx-1.20.1-10.el7.x86_64.rpm | 588 kB 00:00:01
(4/5): gperftools-libs-2.6.1-1.el7.x86_64.rpm | 272 kB 00:00:02
(5/5): openssl11-libs-1.1.1k-7.el7.x86_64.rpm | 1.5 MB 00:00:03
-----------------------------------------------------------------------------------------------------------
Total 669 kB/s | 2.4 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:openssl11-libs-1.1.1k-7.el7.x86_64 1/5
Installing : 1:nginx-filesystem-1.20.1-10.el7.noarch 2/5
Installing : centos-indexhtml-7-9.el7.centos.noarch 3/5
Installing : gperftools-libs-2.6.1-1.el7.x86_64 4/5
Installing : 1:nginx-1.20.1-10.el7.x86_64 5/5
Verifying : gperftools-libs-2.6.1-1.el7.x86_64 1/5
Verifying : centos-indexhtml-7-9.el7.centos.noarch 2/5
Verifying : 1:nginx-filesystem-1.20.1-10.el7.noarch 3/5
Verifying : 1:nginx-1.20.1-10.el7.x86_64 4/5
Verifying : 1:openssl11-libs-1.1.1k-7.el7.x86_64 5/5
Installed:
nginx.x86_64 1:1.20.1-10.el7
Dependency Installed:
centos-indexhtml.noarch 0:7-9.el7.centos gperftools-libs.x86_64 0:2.6.1-1.el7
nginx-filesystem.noarch 1:1.20.1-10.el7 openssl11-libs.x86_64 1:1.1.1k-7.el7
Complete!
[root@web ~]# showmount -e 10.0.1.115
Export list for 10.0.1.115:
/data 10.0.1.0/24
[root@web ~]# mkdir -p /html/www
[root@web ~]# mount -t nfs 10.0.1.115:/data /html/www
[root@web ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 474M 0 474M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.6M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 1.8G 49G 4% /
/dev/sda1 497M 155M 343M 32% /boot
/dev/mapper/centos-home 148G 33M 148G 1% /home
tmpfs 98M 0 98M 0% /run/user/0
10.0.1.115:/data 50G 2.2G 48G 5% /html/www
3.将nfs服务端挂载到nginx的发布目录
nginx服务端设置
ip:10.0.1.116
[root@web ~]# cd /etc/nginx/
conf.d/ fastcgi_params.default nginx.conf uwsgi_params.default
default.d/ koi-utf nginx.conf.default win-utf
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
[root@web ~]# cd /etc/nginx/
[root@web nginx]# ls
conf.d fastcgi_params mime.types scgi_params win-utf
default.d fastcgi_params.default mime.types.default scgi_params.default
fastcgi.conf koi-utf nginx.conf uwsgi_params
fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
[root@web nginx]# vi nginx.conf
1 # For more information on configuration, see:
2 # * Official English Documentation: http://nginx.org/en/docs/
3 # * Official Russian Documentation: http://nginx.org/ru/docs/
4
5 user nginx;
6 worker_processes auto;
7 error_log /var/log/nginx/error.log;
8 pid /run/nginx.pid;
9
10 # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
11 include /usr/share/nginx/modules/*.conf;
12
13 events {
14 worker_connections 1024;
15 }
16
17 http {
18 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
19 '$status $body_bytes_sent "$http_referer" '
20 '"$http_user_agent" "$http_x_forwarded_for"';
21
22 access_log /var/log/nginx/access.log main;
23
24 sendfile on;
25 tcp_nopush on;
26 tcp_nodelay on;
27 keepalive_timeout 65;
28 types_hash_max_size 4096;
29
30 include /etc/nginx/mime.types;
31 default_type application/octet-stream;
32
33 # Load modular configuration files from the /etc/nginx/conf.d directory.
34 # See http://nginx.org/en/docs/ngx_core_module.html#include
35 # for more information.
36 include /etc/nginx/conf.d/*.conf;
37
38 server {
39 listen 80;
40 listen [::]:80;
41 server_name _;
42 root /html/www;
43
44 # Load configuration files for the default server block.
45 include /etc/nginx/default.d/*.conf;
46
47 error_page 404 /404.html;
48 location = /404.html {
49 }
50
51 error_page 500 502 503 504 /50x.html;
52 location = /50x.html {
53 }
54 }
55
56 # Settings for a TLS enabled server.
57 #
58 # server {
59 # listen 443 ssl http2;
60 # listen [::]:443 ssl http2;
61 # server_name _;
62 # root /usr/share/nginx/html;
63 #
64 # ssl_certificate "/etc/pki/nginx/server.crt";
65 # ssl_certificate_key "/etc/pki/nginx/private/server.key";
66 # ssl_session_cache shared:SSL:1m;
67 # ssl_session_timeout 10m;
68 # ssl_ciphers HIGH:!aNULL:!MD5;
69 # ssl_prefer_server_ciphers on;
70 #
71 # # Load configuration files for the default server block.
72 # include /etc/nginx/default.d/*.conf;
73 #
74 # error_page 404 /404.html;
75 # location = /40x.html {
76 # }
77 #
78 # error_page 500 502 503 504 /50x.html;
79 # location = /50x.html {
80 # }
81 # }
82
83 }
tips:如果遇到页面打不开,可以先查看状态nginx服务端的状态
1.看nginx是否运行
2.防火墙是否关闭
3.selinux是否关闭
4.其他进程已占用 -pkillall pkill -9 杀掉其他进程
5.nginx端口占用 关闭其他端口 或者改个端口 在listen这个位置改一下其他端口
6.如果是403 一般是没有权限 我自己碰到的是我的nginx网站目录没有文件。所以访问是403 创建一个网页文件就可以了,或者生产环境中,把网站的备份包拷贝进去解压一下,应该就可以了
[root@web ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2024-03-21 15:48:32 CST; 30s ago
Process: 1507 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 1504 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1502 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Mar 21 15:48:31 web nginx[1507]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 21 15:48:31 web nginx[1507]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 21 15:48:31 web nginx[1507]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 21 15:48:32 web nginx[1507]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 21 15:48:32 web nginx[1507]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 21 15:48:32 web nginx[1507]: nginx: [emerg] still could not bind()
Mar 21 15:48:32 web systemd[1]: nginx.service: control process exited, code=exited status=1
Mar 21 15:48:32 web systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Mar 21 15:48:32 web systemd[1]: Unit nginx.service entered failed state.
Mar 21 15:48:32 web systemd[1]: nginx.service failed.
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# pkill 1453
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# pkill -9 1453
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# systemctl stop nginx
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# pkill -9 1448
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# pkill -9 1452
[root@web ~]# ss -tulpn |grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1453,fd=6),("nginx",pid=1452,fd=6),("nginx",pid=1448,fd=6))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=1453,fd=7),("nginx",pid=1452,fd=7),("nginx",pid=1448,fd=7))
[root@web ~]# pkill nginx
[root@web ~]# ss -tulpn |grep :80
[root@web ~]# systemctl start nginx
[root@web ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2024-03-21 15:52:26 CST; 7s ago
Process: 1560 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 1557 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1555 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 1562 (nginx)
CGroup: /system.slice/nginx.service
├─1562 nginx: master process /usr/sbin/nginx
├─1563 nginx: worker process
└─1564 nginx: worker process
Mar 21 15:52:26 web systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 21 15:52:26 web nginx[1557]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 21 15:52:26 web nginx[1557]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 21 15:52:26 web systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@web ~]# cd /html/www/
[root@web www]# ls
[root@web www]# echo laoliu > index.html
[root@web www]# ls
index.html
[root@web www]# rm -rf *
测试
写入一个网页文件,做个展示
[root@web www]# echo laoliu666 > index.html
[root@web www]# ls
index.html
[root@web www]#
效果图
403报错图
总结
以后NFS服务器如果有任何更新了,nginx那边也会跟着更新的,一般都是nginx的资源比如图片之类的,放在自己的服务器上占内存,所以需要一个NFS文件共享服务器分担nginx的内存压力,用户访问网站的时候,尤其是图片一些内容,不走nginx这里了,走NFS服务器这里
标签:www,x86,nginx,第二十九,html,64,el7
From: https://www.cnblogs.com/nwq1101/p/18088018