使用Fedora 31和Nextcloud服务器构建自己的云

系统 Linux
本文通过几个简单的步骤演示了如何使用 Fedora 和 Nextcloud 构建个人云。对于本教程,你将需要一台独立计算机或运行 Fedora 31 服务器版的虚拟机,还需要互联网连接。

[[317725]]

Nextcloud 是用于跨多个设备存储和同步数据的软件套件。你可以从 https://github.com/nextcloud/server 了解有关 Nextcloud 服务器的更多特性信息。

本文通过几个简单的步骤演示了如何使用 Fedora 和 Nextcloud 构建个人云。对于本教程,你将需要一台独立计算机或运行 Fedora 31 服务器版的虚拟机,还需要互联网连接。

步骤 1:预先安装条件

在安装和配置 Nextcloud 之前,必须满足一些预先条件。

首先,安装 Apache Web 服务器:

  1. # dnf install httpd

接下来,安装 PHP 和一些其他模块。确保所安装的 PHP 版本符合 Nextcloud 的要求

  1. # dnf install php php-gd php-mbstring php-intl php-pecl-apcu php-mysqlnd php-pecl-redis php-opcache php-imagick php-zip php-process

安装 PHP 后,启用并启动 Apache Web 服务器:

  1. # systemctl enable --now httpd

接下来,允许 HTTP 流量穿过防火墙:

  1. # firewall-cmd --permanent --add-service=http
  2. # firewall-cmd --reload

接下来,安装 MariaDB 服务器和客户端:

  1. # dnf install mariadb mariadb-server

然后启用并启动 MariaDB 服务器

  1. # systemctl enable --now mariadb

现在,MariaDB 正在运行,你可以运行 mysql_secure_installation 命令来保护它:

  1. # mysql_secure_installation
  2.  
  3. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL
  4. MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP
  5. CAREFULLY!
  6.  
  7. In order to log into MariaDB to secure it, we'll need the
  8. current password for the root user. If you've just installed
  9. MariaDB, and you haven't set the root password yet, the password
  10. will be blank, so you should just press enter here.
  11.  
  12. Enter current password for root (enter for none): <ENTER>
  13. OK, successfully used password, moving on...
  14.  
  15. Setting the root password ensures that nobody can log into
  16. the MariaDB root user without the proper authorization.
  17.  
  18. Set root password? [Y/n] <ENTER>
  19. New password: Your_Password_Here
  20. Re-enter new password: Your_Password_Here
  21.  
  22. Password updated successfully!
  23.  
  24. Reloading privilege tables...
  25. ... Success!
  26.  
  27. By default, a MariaDB installation has an anonymous user,
  28. allowing anyone to log into MariaDB without having to have
  29. a user account created for them. This is intended only for
  30. testing, and to make the installation go a bit smoother. You
  31. should remove them before moving into a production environment.
  32.  
  33. Remove anonymous users? [Y/n] <ENTER>
  34. ... Success!
  35.  
  36. Normally, root should only be allowed to connect from
  37. 'localhost'. This ensures that someone cannot guess at the
  38. root password from the network.
  39.  
  40. Disallow root login remotely? [Y/n] <ENTER>
  41. ... Success!
  42.  
  43. By default, MariaDB comes with a database named 'test' that
  44. anyone can access. This is also intended only for testing, and
  45. should be removed before moving into a production environment.
  46.  
  47. Remove test database and access to it? [Y/n] <ENTER>
  48.  
  49. - Dropping test database...
  50. ... Success!
  51.  
  52. - Removing privileges on test database...
  53. ... Success!
  54.  
  55. Reloading the privilege tables will ensure that all changes
  56. made so far will take effect immediately.
  57.  
  58. Reload privilege tables now? [Y/n] <ENTER>
  59. ... Success!
  60.  
  61. Cleaning up...
  62.  
  63. All done! If you've completed all of the above steps, your
  64. MariaDB installation should now be secure.
  65.  
  66. Thanks for using MariaDB!

接下来,为你的 Nextcloud 实例创建独立的用户和数据库:

  1. # mysql -p
  2. > create database nextcloud;
  3. > create user 'nc_admin'@'localhost' identified by 'SeCrEt';
  4. > grant all privileges on nextcloud.* to 'nc_admin'@'localhost';
  5. > flush privileges;
  6. > exit;

步骤 2:安装 Nextcloud 服务器

现在,你已满足 Nextcloud 安装的预先条件,请下载并解压 Nextcloud 压缩包

  1. # wget https://download.nextcloud.com/server/releases/nextcloud-17.0.2.zip
  2. # unzip nextcloud-17.0.2.zip -d /var/www/html/

接下来,创建一个数据文件夹,并授予 Apache 对 nextcloud 目录树的读写访问权限:

  1. # mkdir /var/www/html/nextcloud/data
  2. # chown -R apache:apache /var/www/html/nextcloud

SELinux 必须配置为可与 Nextcloud 一起使用。基本命令如下所示,但在 nexcloud 安装中还有很多其他的命令,发布在这里:Nextcloud SELinux 配置

  1. # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
  2. # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
  3. # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?'
  4. # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini'
  5. # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?'
  6. # restorecon -Rv '/var/www/html/nextcloud/'

步骤 3:配置 Nextcloud

可以使用它的 Web 界面或在命令行配置 Nextcloud。

使用 Web 界面

在你喜欢的浏览器中,访问 http://your_server_ip/nextcloud 并输入字段:

 

使用命令行

在命令行中,只需输入以下内容,使用你之前在 MariaDB 中创建的独立 Nextcloud 用户替换相应的值:

  1. # sudo -u apache php occ maintenance:install --data-dir /var/www/html/nextcloud/data/ --database "mysql" --database-name "nextcloud" --database-user "nc_admin" --database-pass "DB_SeCuRe_PaSsWoRd" --admin-user "admin" --admin-pass "Admin_SeCuRe_PaSsWoRd"

最后几点

  • 我使用的是 http 协议,但是 Nextcloud 也可以在 https 上运行。我可能会在以后的文章中写一篇有关保护 Nextcloud 的文章。
  • 我禁用了 SELinux,但是如果配置它,你的服务器将更加安全。
  • Nextcloud 的建议 PHP 内存限制为 512M。要更改它,请编辑 /etc/php.ini 配置文件中的 memory_limit 变量,然后重新启动 httpd 服务。
  • 默认情况下,只能使用 http://localhost/ URL 访问 Web 界面。如果要允许使用其他域名访问,你可编辑 /var/www/html/nextcloud/config/config.php 来进行此操作* 字符可用于绕过域名限制,并允许任何解析为服务器 IP 的 URL 访问。

    1. 'trusted_domains' =>
    2. array (
    3. 0 => 'localhost',
    4. 1 => '*',
    5. ),

 

责任编辑:庞桂玉 来源: Linux中国
相关推荐

2010-03-01 17:51:11

Fedora funa

2009-12-28 17:23:54

Fedora Samb

2010-08-30 20:13:25

DHCP服务器

2010-02-24 13:55:18

Fedora vsFT

2011-07-20 10:13:28

2011-03-29 15:30:20

Zabbix服务器

2012-07-06 15:48:59

华为服务器

2022-03-14 15:10:20

云服务器物理服务器性能

2010-01-12 09:32:20

2009-12-28 15:30:35

Fedora HAL

2018-02-23 15:18:22

云服务器独立服务器差异

2010-03-31 10:05:40

CentOS Samb

2010-08-05 13:40:06

NFS服务器

2010-08-26 22:07:38

DHCP服务器

2010-07-27 13:53:23

NFS服务器

2018-10-24 12:15:06

无服务器软件方式

2010-09-14 14:36:04

fedora12 tf

2012-02-27 15:44:12

存储服务器宝通

2020-04-09 14:23:44

PythonMarkdown编辑器

2012-11-28 09:33:56

私有云架构私有云构建虚拟数据中心
点赞
收藏

51CTO技术栈公众号