Site Loader

随着国内各大网盘的相继关停,以及出于数据的安全性考虑,自建私有云网盘成了不二之选。

NextCloud是自由及开放源代码软件,是由ownCloud原先的开发者弗兰克·卡利切创建的ownCloud分支。

NextCloud在安装及使用方法与ownCloud有异曲同工之效。两者的历史关系大家可上网搜搜。

NextCloud除了可通过web访问,亦提供了桌面(Windows、MacOS、Linux)以及移动设备(Andriod、ISO)的客户端,可谓面面俱到。

  • 操作系统:Ubuntu 18.04 LTS 64Bit
  • NextCloud:NextCloud Server 15.0.4
  • 数据库:MariaDB
  • PHP版本:7.2
  • WebServer:Apache2
  • 硬件需求:可选择租用VPS、使用自有硬件等,视自身情况而定。

首先,安装好ubuntu18.04 LTS 64Bit,系统ISO资源请到www.ubuntu.com下载,系统安装方法这里不具体讲述。

系统安装好后,先执行系统更新命令,更新相应软件包。

为使系统有更快更好的更新体验,把系统的更新源更换为阿里巴巴镜像源,请参照《如何给Ubuntu更换数据源?》

sudo -s      //提取管理员权限
apt update   //更新获取最新软件包
apt upgrade  //更新升级所有软件包

安装Apache2

apt install apache2

安装完毕后,浏览输入服务器IP地址,出现如下页面,即表示Apahce2安装成功。

安装PHP7.2

apt install php7.2

安装MariaDB数据库

apt install mariadb-server

配置MariaDB用户密码及安全设置

##执行如下命令
------------------------------
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):  ##此处直接回车
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y    ##设定新密码
New password:
Re-enter new password:
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] y
 ... 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] y
 ... 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] y
 - 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] y
 ... 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!
------------------------------
##执行如下命令,让配置生效。
------------------------------
echo "update user set plugin='' where User='root'; flush privileges;" | mysql -u root -p mysql
------------------------------

Enter password: ##输入新设定密码 

安装相关软件包

apt install libapache2-mod-php7.2 php7.2-mysql php7.2-zip php7.2-curl php7.2-xml php7.2-mbstring php7.2-gd  php7.2-imagick php-memcache php-apcu php-intl unzip

下载nextcloud server

//进入www网站目录
cd /var/www

//下载nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-15.0.4.zip

解压nextcloud-15.0.4.zip

unzip nextcloud-15.0.4.zip

解压完毕后,在/var/www下将多出一个nextcloud目录。

把目录拥有者赋予Apche2的用户组及用户,注意加上-R选项。

chown -R www-data:www-data /var/www/nextcloud

修改Apache2默认虚拟目录文件000-default.conf

nano /etc/apache2/sites-available/000-default.conf

添加如下代码,并将DocumentRoot /var/www/html修改为DocumentRoot /var/www/nextcloud

        <Directory /var/www/nextcloud>
                Options FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from All
                Require all granted
        </Directory>

重启apache2服务

service apache2 restart