使用LNMP搭建私有云存储

 第一步 

关闭安全软件 并再次检查是否已经关闭

[root@server ~]# setenforce  0

[root@server ~]# systemctl stop  firewalld

[root@server ~]# systemctl status firewalld
[root@server ~]# getenforce

 

第二步 

搭建LNMP环境

[root@server ~]# yum install nginx mariadb-server php* -y

如图所示安装完毕。

第三步  上传软件

使用xftp将nextcloud-25.0.1.zip软件压缩包上传到Linux的根目录,并解压缩

root@server /]# ls
[root@server /]# unzip /nextcloud-25.0.1.zip

第四步  设置nextcloud安装命令权限

 [root@server ~]# chmod -Rf 777 /nextcloud  ---修改其(用户所有者,所有组和其他人的)权限为可读可写可执行(rxw);-R递归修改。

[root@server ~]# cd /
[root@server /]# ll

 

第五步  设置数据库  

[root@server /]# systemctl start mariadb  
[root@server /]# mysql 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.25-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database nextcloud;   
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> create user 'nextcloud'@'localhost' identified by '123456';   
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> grant all on nextcloud.* to 'nextcloud'@'localhost';  
Query OK, 0 rows affected (0.002 sec)

 MariaDB [(none)]> exit
Bye
[root@server /]# systemctl restart mariadb    

 

第六步  配置nginx 

root@server /]# vim /etc/nginx/nginx.conf    

 server {
        listen       80;
        listen       [::]:80;
        server_name  192.168.240.131;
        root         /nextcloud;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

[root@server /]# systemctl restart nginx   

 

第七步  安装

  • 打开浏览器后输入服务器IP地址,进入nextcloud安装向导

  • 管理员的用户名即密码自定

  • 存储与数据库:选择MySQL/MariaDB,设置数据库用户为nextcloud,密码:123456,数据库名:nextcloud,主机名:localhost

 

 此时,只能自己进行上传和下载,但其他人不能访问,因此需进行内网穿透,使其他人和手机都能够访问。 

第八步  cpolar内网穿透

先进入到cpolar网站中,注册账号,然后下载Linux版本,记住其存储位置,然后将文件用xftp传入到Linux的根目录下,按照图示操作解压缩后,连接账户,再在端口80上启动HTTP隧道。

 

[root@server /]# unzip cpolar-stable-linux-amd64.zip   
Archive:  cpolar-stable-linux-amd64.zip
  inflating: cpolar                  
[root@server /]# ls 

 

[root@server /]# ./cpolar authtoken MzAyOTMwZTUtZmM4My00MzNkLTliZjItODBlMDY5NGQ3Zjcx
Authtoken saved to configuration file: /root/.cpolar/cpolar.yml
[root@server /]# ./cpolar http 80 

 

用手机和电脑浏览器分别访问此网站,但都不能

[root@server /]# find / -name config.php   
/nextcloud/config/config.php
[root@server /]# vim /nextcloud/config/config.php  

<?php
$CONFIG = array (
  'instanceid' => 'ocq1ur6x5wqr',
  'passwordsalt' => 'juaC+pECMKRO+CtRbUDpYYQWZWe/KB',
  'secret' => '8VlvNc3DX2dq8AC81T6wVLh+ahCPfdBs+8sX0IKManvA8Gqz',
  'trusted_domains' =>
  array (
          0 => '192.168.240.131',
          1 => '113bcee5.r29.cpolar.top',    ---添加此行内容
  )

最后一步  重启nginx,利用刚刚添加的HTTP信息所对应的网站进行访问 

[root@server /]# systemctl restart nginx  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值