栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

在centos7环境下搭建网盘服务

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在centos7环境下搭建网盘服务

1、查看Linux版本信息
[root@nieyu ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
2、安装epel企业源拓展
#查看是否存在epel

[root@nieyu ~]# rpm -qa epel-release
epel-release-7-11.noarch     #表示存在

#不存在执行下列命令

[root@nieyu ~]# yum install epel-release -y
3、安装配置Nginx服务

1. 安装软件包

[root@nieyu ~]# yum install nginx -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                 | 5.3 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                 | 3.6 kB  00:00:00     
extras                                                                               | 2.9 kB  00:00:00     
updates                                                                              | 2.9 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 nginx.x86_64.1.1.20.1-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

============================================================================================================
 Package                架构                    版本                            源                     大小
============================================================================================================
正在安装:
 nginx                  x86_64                  1:1.20.1-2.el7                  epel                  586 k

事务概要
============================================================================================================
安装  1 软件包

总计:586 k
安装大小:1.7 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:nginx-1.20.1-2.el7.x86_64                                                             1/1 
  验证中      : 1:nginx-1.20.1-2.el7.x86_64                                                             1/1 

已安装:
  nginx.x86_64 1:1.20.1-2.el7                                                                               

完毕!

2. 开启服务和配置开机自启动

[root@nieyu ~]# systemctl start nginx.service  //启动服务
[root@nieyu ~]# systemctl enable nginx.service //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

3. 检测80端口是否开放

[root@nieyu ~]# netstat -lntup | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4770/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      4770/nginx: master 

80端口必须开放不然无法访问Nginx的服务

4. 测试访问

//创建首页文件

[root@nieyu ~]# echo "nieyu" > /usr/share/nginx/html/index.html 
[root@nieyu ~]# cat /usr/share/nginx/html/index.html
nieyu
//查询虚拟机ip ens33网卡ip为:192.168.31.128

[root@nieyu ~]# ifconfig
ens33: flags=4163  mtu 1500
        inet 192.168.31.128  netmask 255.255.255.0  broadcast 192.168.31.255
        inet6 fe80::bd65:8b71:d9aa:ddb0  prefixlen 64  scopeid 0x20
        ether 00:0c:29:25:62:4d  txqueuelen 1000  (Ethernet)
        RX packets 65840  bytes 68370655 (65.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12849  bytes 1589179 (1.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33:0: flags=4163  mtu 1500
        inet 192.168.31.125  netmask 255.255.255.0  broadcast 192.168.31.255
        ether 00:0c:29:25:62:4d  txqueuelen 1000  (Ethernet)

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 104 (104.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 104 (104.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        在centos7测试

[root@nieyu ~]# curl 127.0.0.1
nieyu

     在客户机测试访问192.168.31.128/index.html

5.配置Nginx支持网盘的配置文件

[root@nieyu ~]# cd /etc/nginx/   //打开配置文件目录
[root@nieyu nginx]# cp nginx.conf nginx.ori   //备份配置原有配置文件为nginx.ori
[root@nieyu nginx]# >nginx.conf       //清空原有配置文件
[root@nieyu nginx]# vim nginx.conf    //编辑新的配置文件

//按“i”进入编辑模式,粘贴如下代码

###start
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
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 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
server {
 listen 80;
 server_name kod.oldboyedu.com;
 root         /usr/share/nginx/html;
 index index.php index.html;
 location ~ .php$ {
   root         /usr/share/nginx/html;
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_param script_FILENAME $document_root$fastcgi_script_name;
   include fastcgi_params;
 }
}
}
###end

//shift+: 输入“wq”,保存退出

5、重启Nginx服务

[root@nieyu nginx]# systemctl restart nginx.service 

6、安装PHP

//依次安装软件包
yum install php php-devel php-fpm php-mysql php-common -y
yum install php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear -y
yum install php-xml php-xmlrpc php-mbstring -y
yum install php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel -y

7、开启PHP服务与设置开机重启

[root@nieyu ~]# systemctl start php-fpm.service      //启动服务
[root@nieyu ~]# systemctl enable php-fpm.service    //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@nieyu ~]# netstat -lntup |grep php    //查看服务确认开启
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      5312/php-fpm: maste 

8、测试php服务

//创建文件
[root@nieyu html]# touch phpinfo.php
//编辑文件
[root@nieyu html]# vim phpinfo.php 
//编辑输出phpinfo

        在客户机测试:192.168.31.128/phpinfo.php(测试完后最好删除测试文件,安全)

9、搭建网盘

[root@nieyu html]# cd /usr/share/nginx/html/    #进入服务器目录

//下载网盘源码
[root@nieyu html]# wget http://static.kodcloud.com/update/download/kodexplorer4.40.zip

--2021-10-16 18:58:47--  http://static.kodcloud.com/update/download/kodexplorer4.40.zip
正在解析主机 static.kodcloud.com (static.kodcloud.com)... 140.249.61.184
正在连接 static.kodcloud.com (static.kodcloud.com)|140.249.61.184|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:13894810 (13M) [application/octet-stream]
正在保存至: “kodexplorer4.40.zip”

100%[==================================================================>] 13,894,810  1.70MB/s 用时 6.1s   

2021-10-16 18:58:54 (2.18 MB/s) - 已保存 “kodexplorer4.40.zip” [13894810/13894810])

[root@nieyu html]# ls
404.html  50x.html  en-US  icons  img  index.html  kodexplorer4.40.zip  nginx-logo.png  poweredby.png
//解压安装包
[root@nieyu html]# unzip kodexplorer4.40.zip 

 10、配置网站权限

//更改用户和用户组
[root@nieyu html]# chown -R nginx.nginx /usr/share/nginx/html/
//更改权限(一般网站权限不能配置为777,但是此网站源码要求必须配置,不然无法使用)
[root@nieyu html]# chmod -R 777 /usr/share/nginx/html/

11、关闭安全服务

[root@nieyu html]# setenforce 0    //暂时关闭
[root@nieyu html]# getenforce     //查询结果,表示暂时关闭
Permissive
[root@nieyu html]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config //永久关闭
[root@nieyu html]# grep "SELINUX=disabled" /etc/selinux/config //查询结果
SELINUX=disabled

12、在客户机测试网盘页面

        设置完管理员密码

        默认管理员用户:admin

        输入密码:xxxxxx

可以使用

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/334263.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号