使用 Fedora 31 和 Nextcloud 伺服器構建自己的雲
Nextcloud 是用於跨多個裝置儲存和同步資料的軟體套件。你可以從 https://github.com/nextcloud/server 瞭解有關 Nextcloud 伺服器的更多特性資訊。
本文通過幾個簡單的步驟演示瞭如何使用 Fedora 和 Nextcloud 構建個人雲。對於本教程,你將需要一臺獨立計算機或執行 Fedora 31 伺服器版的虛擬機器,還需要網際網路連線。
步驟 1:預先安裝條件
在安裝和配置 Nextcloud 之前,必須滿足一些預先條件。
首先,安裝 Apache Web 伺服器:
# dnf install httpd
接下來,安裝 PHP 和一些其他模組。確保所安裝的 PHP 版本符合 Nextcloud 的要求:
# 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 伺服器:
# systemctl enable --now httpd
接下來,允許 HTTP 流量穿過防火牆:
# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload
接下來,安裝 MariaDB 伺服器和客戶端:
# dnf install mariadb mariadb-server
然後啟用並啟動 MariaDB 伺服器
# systemctl enable --now mariadb
現在,MariaDB 正在執行,你可以執行 mysql_secure_installation
命令來保護它:
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL
MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP
CAREFULLY!
In order to log into MariaDB to secure it, we'll need the
current password for the root user. If you've just installed
MariaDB, and you haven't set the root password yet, the password
will be blank, so you should just press enter here.
Enter current password for root (enter for none): <ENTER>
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into
the MariaDB root user without the proper authorization.
Set root password? [Y/n] <ENTER>
New password: Your_Password_Here
Re-enter new password: Your_Password_Here
Password updated successfully!
Reloading privilege tables...
... Success!
By default, a MariaDB installation has an anonymous user,
allowing anyone to log into MariaDB without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother. You
should remove them before moving into a production environment.
Remove anonymous users? [Y/n] <ENTER>
... Success!
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at the
root password from the network.
Disallow root login remotely? [Y/n] <ENTER>
... Success!
By default, MariaDB comes with a database named 'test' that
anyone can access. This is also intended only for testing, and
should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] <ENTER>
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? [Y/n] <ENTER>
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your
MariaDB installation should now be secure.
Thanks for using MariaDB!
接下來,為你的 Nextcloud 例項建立獨立的使用者和資料庫:
# mysql -p
> create database nextcloud;
> create user 'nc_admin'@'localhost' identified by 'SeCrEt';
> grant all privileges on nextcloud.* to 'nc_admin'@'localhost';
> flush privileges;
> exit;
步驟 2:安裝 Nextcloud 伺服器
現在,你已滿足 Nextcloud 安裝的預先條件,請下載並解壓 Nextcloud 壓縮包:
# wget https://download.nextcloud.com/server/releases/nextcloud-17.0.2.zip
# unzip nextcloud-17.0.2.zip -d /var/www/html/
接下來,建立一個資料資料夾,並授予 Apache 對 nextcloud
目錄樹的讀寫訪問許可權:
# mkdir /var/www/html/nextcloud/data
# chown -R apache:apache /var/www/html/nextcloud
SELinux 必須配置為可與 Nextcloud 一起使用。基本命令如下所示,但在 nexcloud 安裝中還有很多其他的命令,釋出在這裡:Nextcloud SELinux 配置。
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?'
# restorecon -Rv '/var/www/html/nextcloud/'
步驟 3:配置 Nextcloud
可以使用它的 Web 介面或在命令列配置 Nextcloud。
使用 Web 介面
在你喜歡的瀏覽器中,訪問 http://your_server_ip/nextcloud 並輸入欄位:
使用命令列
在命令列中,只需輸入以下內容,使用你之前在 MariaDB 中建立的獨立 Nextcloud 使用者替換相應的值:
# 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 訪問。'trusted_domains' => array ( 0 => 'localhost', 1 => '*', ),
via: https://fedoramagazine.org/build-your-own-cloud-with-fedora-31-and-nextcloud-server/
作者:storyteller 選題:lujun9972 譯者:geekpi 校對:wxy
訂閱“Linux 中國”官方小程式來檢視
相關文章
- 使用Go和HCL構建您自己的DSLGo
- 雲伺服器搭建NextCloud個人雲盤伺服器Cloud
- 使用 .NET 7、Blazor 和 .NET MAUI 構建你自己的 Podcast AppBlazorUIASTAPP
- nextcloud個人雲搭建Cloud
- docker 構建自己的映象Docker
- 構建自己的 PHP 框架PHP框架
- 構建自己的AngularJS(1):Scope和DigestAngularJS
- 使用 Swift 和 Vapor 構建區塊鏈伺服器SwiftVapor區塊鏈伺服器
- Fedora 31 Beta 釋出
- Fedora 31 正式釋出
- 二、雲伺服器環境的構建+Jenkins伺服器Jenkins
- 阿里雲伺服器使用minikube構建開發服務阿里伺服器
- 構建自己的React UI元件庫: 構建首頁ReactUI元件
- 【Fizzday前言】使用composer構建自己的php框架PHP框架
- 如何使用Solidity和Hardhat構建你自己的NFT以及NFT交易市場Solid
- 使用騰訊雲建一個基於自己域名的網站網站
- 如何構建自己的雲資料庫?建立雲資料庫是否要收費?資料庫
- 將Fedora 31升級到Fedora 32的命令列方法簡介命令列
- Vue秩序白銀 —構建自己的VuexVue
- 構建自己的postgresql rpm包SQL
- 構建自己的知識體系
- Golang:使用 httprouter 構建 API 伺服器GolangHTTPAPI伺服器
- HongHu雲架構 - maven的構建架構Maven
- 使用 Micronaut和OpenFaaS 構建無伺服器Java 應用程式 - openvalue伺服器Java
- 探索使用 Golang 和 Webassembly 構建一個多人遊戲伺服器GolangWeb遊戲伺服器
- 使用Hudson搭建自動構建伺服器伺服器
- 構建自己的React:(4)Components and StateReact
- 如何構建自己的知識體系
- 如何構建自己的筆記系統?筆記
- php-構建自己的composer包PHP
- 有關雲架構建設和選型的思考架構
- 使用hadoop打造自己的雲Hadoop
- 構建自己知識體系
- 構建自己的簡單微服務架構(開源)微服務架構
- 如何使用Linux構建高效FTP伺服器LinuxFTP伺服器
- 使用 Kubernetes 和滴滴雲 Docker 倉庫構建 CI/CD 流水線Docker
- 使用Golang和MongoDB構建 RESTful APIGolangMongoDBRESTAPI
- 使用Golang和MongoDB構建微服務GolangMongoDB微服務