项目实战-使用LNMP搭建私有云存储
准备工作
恢复快照,关闭安全软件
[root@server ~]# setenforce 0
[root@server ~]# systemctl stop firewalld
搭建LNMP环境
[root@server ~]# yum install nginx mariadb-server php* -y
# 并开启nginx服务并设置开机自启
[root@Cyber4K ~]# systemctl start nginx
[root@Cyber4K ~]# systemctl enable nginx
下载软件并上传软件
Nextcloud - Open source content collaboration platform
# 使用xftp将软件压缩包上传到Linux的根目录,并解压缩
[root@Cyber4K /]# ls
[root@Cyber4K /]# unzip latest.zip
设置nextcloud安装命令权限
[root@server /]# chmod -Rf 777 /nextcloud
设置数据库并重启数据库
[root@server /]# systemctl start mariadb # 启动数据库
[root@server /]# mysql
# 数据库设置
MariaDB [(none)]> create database nextcloud; # 创建数据库
MariaDB [(none)]> create user 'nextcloud'@'localhost' identified by '123456'; # 创建用户及密码
MariaDB [(none)]> grant all on nextcloud.* to 'nextcloud'@'localhost';
# 设置权限
MariaDB [(none)]> exit # 退出
[root@server /]# systemctl restart mariadb
配置nginx
server {
listen 80;
listen [::]:80;
server_name 192.168.11.130;
root /nextcloud;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
重启nginx服务
[root@Cyber4K /]# systemctl restart nginx
安装nextcloud安装向导
- 打开浏览器后输入服务器IP地址,进入nextcloud安装向导
- 管理员的用户名即密码自定
- 存储与数据库:选择MySQL/MariaDB,设置数据库用户为nextcloud,密码:123456,数据库名:nextcloud,主机名:localhost
进行内网穿透操作
使用花生壳平台(记得实名认证)贝锐花生壳管理 - 首页
# 粘贴至命令行下载
[root@Cyber4K /]# wget "https://dl.oray.com/hsk/linux/phddns_5.3.0_amd64.rpm" -O phddns_5.3.0_amd64.rpm
[root@Cyber4K /]# ls
phddns_5.3.0_amd64.rpm
# 安装rpm包
[root@Cyber4K /]# rpm -ivh phddns_5.3.0_amd64.rpm
# 启动花生壳linux端
[root@Cyber4K /]# phddns start
推荐使用SN码登录
认证成功页面
访问域名后发现问题,如下图所示
cpolar的域名信任
#请联系您的管理员。如果您就是管理员,请参照 config.sample.php 中的示例编辑 config/config.php 中的“trusted_domains”设置
# 通过网页反馈并在linux中参考示例中的config.sample.php
[root@Cyber4K /]# find / -name "config.sample.php"
/nextcloud/config/config.sample.php
# 进入文件并参考
[root@Cyber4K /]# vim /nextcloud/config/config.sample.php
#请联系您的管理员。如果您就是管理员,请参照 config.sample.php 中的示例编辑 config/config.php 中的“trusted_domains”设置
# 查看特定文件并按照网页反馈来修改配置文件(如下图所示来补充!!!)
[root@Cyber4K /]# vim /nextcloud/config/config.php
<?php
$CONFIG = array (
'instanceid' => 'oc31oe7hpq1z',
'passwordsalt' => 'RktFf6mY3c7nQz8FrTb9nj9BHJg7H5',
'secret' => '5yKuq5Oh3YdCysUC0e8YX2GFUVqdFrcgjUnoSFiEv8s4HvHm',
'trusted_domains' =>
array (
0 => '192.168.11.130',
1 => 'zwah80641185.vicp.fun',
),
'datadirectory' => '/nextcloud/data',
'dbtype' => 'mysql',
'version' => '31.0.2.1',
'overwrite.cli.url' => 'https://zwah80641185.vicp.fun:443',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => '123456',
'installed' => true,
'overwritehost' => 'zwah80641185.vicp.fun:443',
'overwriteprotocol' => 'https',
);
# 保存后退出并测试,如下图所示
# 所补充内容有: 1 => 'zwah80641185.vicp.fun', 'overwrite.cli.url' => 'https://zwah80641185.vicp.fun:443', 'overwritehost' => 'zwah80641185.vicp.fun:443', 'overwriteprotocol' => 'https',
下图为修改好配置文件,正常登录。