[轉載自 https://www.linuxidc.com/Linux/2018-11/155310.htm]
該方法是在linxu公社中發布的。感謝作者!
本人親測,此方法可行,我在手機、電腦上都可連接打開,使用正常。
越來越多的雲盤一不開心就關閉,大公司的網盤也不靠譜啊,為了解決這些問題,我們可以搭建一個自己的個人網盤(私有雲盤),常用的開源框架包括ownCloud,Seafile,Nextcloud,本文介紹的是在CentOS 7下基於Nextcloud教你如何搭建一個私有雲。
Nextcloud簡介
Nextcloud是一套用於創建網絡硬盤/雲盤以存放文件的客戶端-服務器軟件,功能與Dropbox類似,但是Nextcloud完全開源並且免費,每個人都可以在VPS上安裝並運行它,並且讓用戶能夠完全掌控自己的數據。
Nextcloud是ownCloud的一個分支(衍生版),由ownCloud的開發展弗蘭克·卡里切創建,由其他開發團隊成員開發維護,完全開源並且免費。
首先我們要安裝一個Apache服務器
[linuxidc@localhost ~]$ sudo yum install httpd -y
然后啟動Apache服務
[linuxidc@localhost ~]$ systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
執行如下命令,看狀態
systemctl status httpd.service
80端口被占用了
原來是Nginx暫用80端口,現在我們來查看進程號
[linuxidc@localhost ~]$ ps -ef|grep nginx
root 1446 1 0 09:55 ? 00:00:00 nginx: master process /usr/sbin/nginx
nginx 1449 1446 0 09:55 ? 00:00:00 nginx: worker process
linuxidc 4787 4734 0 10:07 pts/0 00:00:00 grep --color=auto nginx
殺死Nginx進程。
[linuxidc@localhost ~]$ sudo kill -QUIT 1287
重新啟動Apache
[linuxidc@localhost ~]$ systemctl restart httpd
#chkconfig firewalld off 我們這里選擇永久的關閉防火牆,需要重啟后才會生效哦!(#service iptables start 及時生效,重啟后失效)
開放80/tcp端口
# firewall-cmd –zone=public –add-port=80/tcp –permanent
刷新瀏覽器,可以看到頁面,證明成功
為了方便先替換一下下載的源
# yum install http://repo.webtatic.com/yum/el7/x86_64/RPMS/webtatic-release-7-3.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
緊接着開始安裝php
輸入#php -v 查看版本,出現版本信息證明安裝成功。
[linuxidc@localhost ~]$ php -v
PHP 7.2.11 (cli) (built: Oct 10 2018 10:00:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
安裝MariaDB數據庫服務器
[linuxidc@localhost ~]$ sudo yum install mariadb-server mariadb -y
啟動MariaDB數據庫
[linuxidc@localhost ~]$ systemctl start mariadb
設置開機啟動
[linuxidc@localhost ~]$ systemctl enable mariadb
完成以上步驟我們的基礎環境就基本的搭建好了,然后我們就可以安裝nextclound。
首先我們安裝phpMyAdmin來管理數據庫。
進入下載路徑把phpMyAdmin-4.8.3-all-languages.tar.gz下載到/var/www/html/ 路徑下面
[linuxidc@localhost html]$ sudo wget https://files.phpmyadmin.net/phpMyAdmin/4.8.3/phpMyAdmin-4.8.3-all-languages.tar.gz
[linuxidc@localhost html]$ sudo tar -zxvf phpMyAdmin-4.8.3-all-languages.tar.gz
yum install php70w-mbstring php70w-mysql
可以直接使用yum命令來安裝apache的mod_php模塊:yum install mod_php71w
# systemctl restart httpd
然后輸入你的IP/phpMyAdmin
# mysqladmin -u root password '你的密碼',我們添加一個root用戶。登陸進去
我們新建一個數據庫linuxidc
然后點擊第二個SQL
輸入
CREATE USER '自己設用戶名'@'localhost' IDENTIFIED BY '自己設密碼'
CREATE USER 'linux'@'localhost' IDENTIFIED BY 'linuxidc'
選中自己的創建的賬戶,把所有權限都賦予給它。這樣我們終於可以可以安裝nextclound了。
下載東西當然選擇官網啦,百度都能出來。為了方便我們還是把地址放出來一下下吧 https://download.nextcloud.com/server/releases/nextcloud-14.0.3.zip
同樣上傳到/var/www/html解壓出來(這個步驟就不貼圖出來了,和上面上傳phpadmin安裝包一個方法)
[linuxidc@localhost ~]$ sudo mv nextcloud /var/www/html
[sudo] linuxidc 的密碼:
[linuxidc@localhost ~]$ cd /var/www/html
[linuxidc@localhost html]$ sudo chown apache nextcloud -Rf
[linuxidc@localhost html]$ sudo chmod 770 nextcloud -Rf
同時給nextcloud目錄權限
#setenfoece 0 關閉selinux(這個方法只是臨時關閉,重啟失效,永久關閉可以編輯/etc/selinux/config,找到SELINUX=enforcing,將它改為SELINUX=disabled)這一步不操作回出現內部服務器錯誤的提示。操作完重啟系統.
參考
CentOS 7.5關閉FireWall 和SELinux圖文詳解 https://www.linuxidc.com/Linux/2018-11/155311.htm
輸入ip\nextclound 選擇存儲&數據庫,用戶和密碼用我們自己創建的
OK.完成。