公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

服务端

# 1、安装nfs-utils 和 rpcbind

# yum -y install nfs-utils rpcbind

 

# 2、创建要共享的目录(可能要一步一步的创建)

# mkdir /data/report/nfs

 

# 3、修改/etc/exports 10.111.74.247 不是本机ip,是要共享的ip,对谁开放就是谁

# /data/report/nfs 10.111.74.247(rw,no_root_squash)

#参数no_root_squash的其作用是:NFS客户端使用共享目录的用户,如果是root 的话,所有的操作均在服务器端映射为root用户,拥有共享目录的root权限!

 

# 4、开启nfs

# systemctl start nfs

 

# 5、如果报错,可能要先开启rpcbind

# systemctl start rpcbind

 

# 6、查看共享目录

# showmount -e localhost

 

# 7、设置开机自启动

# systemctl enable rpcbind

# systemctl enable nfs-server.server

客户端

# 客户端安装在另外一台机器上,就是对谁开放的那个谁

 

# 1、安装nfs-utils

# yum -y intall nfs-utils

 

# 2、显示服务端可挂载的目录

# showmount -e 10.111.74.248

# 这个IP是服务端的IP

 

# 3、将服务端的/data/report/nfs 挂载到本地的 /data/report/nfs。实际上是互相共享,无论修改哪一边,另外一边也会相应的被修改

# mount -t nfs 10.111.74.248:/data/report/nfs /data/report/nfs

 

# 设置开机自动挂载

# vi /etc/fstab

 

# 这个IP是服务端的IP

# 10.111.74.248:/data/report/nfs/ /data/report/nfs/ nfs defaults,_rnetdev 1 1

文件服务器

# 一、安装PCRE

#

# 文档:菜鸟教程 https://www.runoob.com/linux/Nginx-install-setup.html

 

# 安装编译工具及库文件

# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

 

# 首先要安装 PCRE PCRE 作用是让 Nginx 支持 Rewrite 功能。

 

# cd /usr/local/src/

# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

 

# 解压

# tar zxvf pcre-8.35.tar.gz

 

# 进入安装包目录

# cd pcre-8.35

# ./configure

# make && make install

 

# 查看pcre版本

# pcre-config --version

 

# 二、安装Nginx

# cd /usr/local/src/

# wget http://nginx.org/download/nginx-1.6.2.tar.gz

# tar zxvf nginx-1.6.2.tar.gz

 

# 进入安装包目录

# cd nginx-1.6.2

 

# 编译安装

# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35

# make

# make install

 

# 查看nginx版本

# /usr/local/webserver/nginx/sbin/nginx -v

 

# 修改配置文件

vi /etc/nginx/conf.d/default.conf

 

# 内容

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log /var/log/nginx/host.access.log main;

location / {

root /usr/share/nginx/html;

index index.html index.htm;

}

# 添加这个

location ~ ^/report/ {

root /data;

#autoindex on;

}

# 添加这个

location ^~/opt/{

alias /data/report/nfs/opt/;

autoindex on;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

# proxy the php scripts to Apache listening on 127.0.0.1:80

#

#location ~ .php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

#location ~ .php$ {

# root html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /.ht {

# deny all;

#}

# }

 

# 就可以以ip的形式访问这个目录下的文件

# 例如: http://10.111.74.248/data/report/nfs/xxx/xxx.txt

# 例如: http://10.111.74.248:80/data/report/nfs/xxx/xxx.txt

 

# 非80 端口号监听

server {

listen 8080;

server_name localhost;

location / {

proxy_pass http://192.168.1.100:8081;

proxy_set_header Host $host:8080;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

 

Linux安装nfs文件服务器

分享到:
标签:文件服务器 nfs
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定