近期给母上单位搞了个私有云,用来备份文件。
之前一直用的OwnCloud,但是在装之前Google了一圈正好看到了NextCloud,然后又读到了OwnCloud和NextCloud的区别。
发现OwnCloud现在已经逐渐只面向付费用户服务了,社区基本已经开始枯萎,很多提交的bug没有被及时的处理(没人管)
这时从OwnCloud的分出来的人成立了NextCloud,NextCloud基本上就是OwnCloud的一个fork,修复了13个bug,提高了稳定性。
然后当然是选择NextCloud啦~
!!** 截止发文时NextCloud最新stable版本为11.0.1,本文以此为准。
System Requirement
Memory requirements for running an Nextcloud server are greatly variable, depending on the numbers of users and files, and volume of server activity.
CPU, RAM, 存储没有硬性要求,基本取决于你的需求,你的需求越大,各项配置就要越高。
//内存最低128M,推荐512M及以上
官方推荐的软件配置为:
!!** 我个人极不推荐Debian,对于普通用户来说
- Red Hat Enterprise Linux 7 / Ubuntu 16.04 LTS
- MySQL/MariaDB
- PHP 7.0 +
- Apache 2.4 with mod_php
当然也支持其他平台:
- Server: Linux (Debian 7, SUSE Linux Enterprise Server 11 SP3 & 12, Red Hat Enterprise Linux/CentOS 6.5 and 7 (7 is 64-bit only), Ubuntu 14.04 LTS, 16.04 LTS)
- Web server: Apache 2 (mod_php, php-fpm) or Nginx (php-fpm)
- Databases: MySQL/MariaDB 5.5+; PostgreSQL; Oracle 11g (currently only possible if you contact us <https://nextcloud.com/enterprise> as part of a subscription)
- PHP 5.6 + required
- Hypervisors: Hyper-V, VMware ESX, Xen, KVM
- Desktop: Windows XP SP3 (EoL Q2 2015), Windows 7+, Mac OS X 10.7+ (64-bit only), Linux (CentOS 6.5, 7 (7 is 64-bit only), Ubuntu 12.04 LTS, 14.04 LTS, 14.10, Fedora 20, 21, openSUSE 12.3, 13, Debian 7 & 8).
- Mobile apps: iOS 7+, Android 4+
- Web browser: IE11+, Microsoft Edge, Firefox 14+, Chrome 18+, Safari 7+
!!** 没错,有虚拟机镜像可以直接deploy,但是我并没有选择,因为那样会很无聊ww
!!** 数据引擎只支持InnoDB,MyISAM并不支持。
Basic Environment Setup
!!** On the Ubuntu 16.04 LTS Server
Required:
- PHP (>= 5.6, 7.0 or 7.1)
- PHP module ctype
- PHP module dom
- PHP module GD
- PHP module iconv
- PHP module JSON
- PHP module libxml (Linux package libxml2 must be >=2.7.0)
- PHP module mb multibyte
- PHP module posix
- PHP module SimpleXML
- PHP module XMLWriter
- PHP module zip
- PHP module zlib
Database connectors (pick the one for your database:)
- PHP module sqlite (>= 3, usually not recommended for performance reasons)
- PHP module pdo_mysql (MySQL/MariaDB)
- PHP module pgsql (requires PostgreSQL >= 9.0)
Recommended packages:
- PHP module curl (highly recommended, some functionality, e.g. HTTP user authentication, depends on this)
- PHP module fileinfo (highly recommended, enhances file analysis performance)
- PHP module bz2 (recommended, required for extraction of apps)
- PHP module intl (increases language translation performance and fixes sorting of non-ASCII characters)
- PHP module mcrypt (increases file encryption performance)
- PHP module openssl (required for accessing HTTPS resources)
Required for specific apps:
- PHP module ldap (for LDAP integration)
- PHP module smbclient (SMB/CIFS integration, see SMB/CIFS)
- PHP module ftp (for FTP storage / external user authentication)
- PHP module imap (for external user authentication)
Recommended for specific apps (optional):
- PHP module exif (for image rotation in pictures app)
- PHP module gmp (for SFTP storage)
For enhanced server performance (optional) select one of the following memcaches:
- PHP module apcu (>= 4.0.6)
- PHP module memcached
- PHP module redis (>= 2.2.6, required for Transactional File Locking)
For preview generation (optional):
- PHP module imagick
- avconv or ffmpeg
- OpenOffice or LibreOffice
需要的,推荐的,等等已经在上面写出了,可以根据自己的需求来安装,这里仅讲述典型的NextCloud安装。
apt-get install apache2 mariadb-server libapache2-mod-php7.0
apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring
apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip
!!** libapache2-mod-php7.0中已经包括了bcmath bz2 calendar Core ctype date dba dom ereg exif fileinfo filter ftp gettext hash iconv libxml mhash openssl pcre Phar posix Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xmlreader xmlwriter zlib
!!**在安装MariaDB的过程中会让你设置root密码,请使用随机hash创建强密码并牢记该密码。
Tip: 可以使用OpenSSL来生成随机hash openssl rand -hex 10
关于MySQL/MariaDB的用户创建以及权限设置可以参考这里:https://blog.silversky.moe/archive/mysql-bash-add-user-privileges-settings
Download and Configure NextCloud
下载并验证
通过 https://nextcloud.com/install/#instructions-server 下载Server端文件
!!** 下载完成后使用MD5,SHA256或者gpg来验证文件,在 “Details and Download Options”选项中可以看到tar.bz2或者zip文件的MD5或者gpg key文件地址
- 我使用的时zip文件和MD5验证
cd /tmp
wget https://download.nextcloud.com/server/releases/nextcloud-11.0.1.zip
wget https://download.nextcloud.com/server/releases/nextcloud-11.0.1.zip.md5
md5sum -c nextcloud-11.0.1.zip.md5 < nextcloud-11.0.1.zip
- 如果没有错误的话,就可以解压开始配置了。
unzip nextcloud-11.0.1.zip
- 将解压出来的文件复制到/var/www文件夹
cp -r nextcloud /var/www
配置Apache
- 在/etc/apache2/sites-available文件夹下创建nextcloud.conf
cd /etc/apache2/sites-available
vim nextcloud.conf
- 写入:
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
- 创建symlink到/etc/apache2/sites-enabled
ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
额外的Apache设置
- 开启
mod_rewrite
:
a2enmod rewrite
- 开启
mod_headers
,mod_env
,mod_dir
,mod_mime
:
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
开启SSL (可选)
a2enmod ssl
a2ensite default-ssl
service apache2 reload
!!** Apache默认的SSL是自签证书,可以自己更换
设置目录权限
chown -R www-data:www-data /var/www/nextcloud/
然后你就可以访问 http://yourhostname/nextcloud 进行配置了
Note:
!!** 如果安装过程出现错误,并提示:
An unhandled exception has been thrown: exception ‘PDOException’ with message 'SQLSTATE[HY000]: General error: 1665 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.'
那么你需要按照这里的步骤来进行配置,我在安装过程中没有遇到这个问题,略。
!!** 如果需要Emoji支持的话,还需要对数据库进行一些设置。
!!** 注意如果使用Ubuntu或者Debian的话,这段配置请不要写在/etc/mysql/conf.d/mysql.conf中,否则mysql会出现错误
mysql: unknown variable 'innodb_large_prefix=on'
在创建Database的话请使用以下设置,如果已经创建的话,可以重新设置character和collate
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Ubuntu系统修改50-server.cnf, 在/etc/mysql/mariadb.conf.d 目录下
在[mysqld]下添加
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=true
Comments
2 responses to “Re:从零开始安装配置NextCloud私有云”
感觉我也要从owncloud叛变到nextcloud了,很多需要用的插件什么的现在都跑去叫nextcloudApp。
Owncloud还用Tomcat的时候我就用了,后来很久没用加上换服务器直接废了。后来母上公司需要备份Excel这些才去查,看到一些关于Nextcloud和Owncloud的讨论,还是选了Nextcloud
毕竟Owncloud已经开始走商业化道路了,对于普通用户来说是比较恶心的,bug和security updates都是先供应给付费用户