部署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服务器这里