搭建 LAMP 環境部署 Nextcloud 私人網盤
前言
Nextcloudd 是一個開源的、基於本地的文件共享和協作平台,它允許您保存文件並通過多個設備(如PC、智能手機和平板電腦)訪問它們。
同樣的我們可以自己購買一個雲服務器,部署一個屬於自己的私人網盤,用來存儲一些圖片,文件等東西,以后需要可以從私人網盤上下載,就會比其他的例如百度網盤快很多
首關閉防火牆和selinux
[root@localhost ~]# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# sed -i "/^SELINUX/cSELINUX=disabled" /etc/selinux/config
[root@localhost ~]# setenforce 0
安裝依賴包
[root@localhost ~]# yum install -y epel-release yum-utils unzip curl wget bash-completion policycoreutils-python mlocate bzip2
安裝 web 服務和數據庫服務
[root@localhost ~]# yum install -y httpd mariadb-server mariadb
啟動 web 服務和數據庫服務,並設置開機自啟
[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now mariadb
安裝php7.2(部署netxtcloud必須使用php7以上的版本)
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.Ajn7R7: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:webtatic-release-7-3 ################################# [100%]
[root@localhost ~]# yum install -y php72w php72w-cli php72w-common php72w-curl php72w-gd php72w-mbstring php72w-mysqlnd php72w-process php72w-xml php72w-zip php72w-opcache php72w-pecl-apcu php72w-intl php72w-pecl-redis
設置數據庫管理員密碼
[root@localhost ~]# mysqladmin -u root password 'your_password' # your_password 是需要自己設置的密碼
進入數據庫,給Nextcloud創建數據庫,並授權
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 246
Server version: 10.3.17-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;
MariaDB [(none)]> grant all on nextcloud.* to "root"@"localhost";
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
+--------------------+
4 rows in set (0.003 sec)
MariaDB [(none)]> exit
Bye
上傳nextcloud壓縮包
訪問Nextcloud官網:https://nextcloud.com/install/#instructions-server
點擊下載到本地
- 也可以使用:
wget https://download.nextcloud.com/server/releases/nextcloud-19.0.3.zip
- 但是這種方式很慢,推薦先下載到本地,再上傳到機器上
上傳完成后,將文件解壓縮到/var/www/html/目錄下
[root@localhost ~]# unzip nextcloud-16.0.3.zip -d /var/www/html/
接着,創建一個目錄來存儲管理用戶數據
[root@localhost ~]# mkdir -p /var/www/html/nextcloud/data
修改NextCloud的目錄權限,以便Apache用戶可以向其中添加數據
[root@localhost ~]# chown -R apache:apache /var/www/html/nextcloud/
通過 web 界面安裝 nextcloud 瀏覽器訪問:ip/nextcloud
- 安裝完成可能會無法登陸,會話窗口輸入用戶名和密碼沒反應
[root@localhost ~]# chown -R apache.apache /var/lib/php/session
[root@localhost ~]# systemctl restart htpd