安裝 nextcloud 12

nextcloud 係由 owncloud 滋生出嚟,事源有份參與開發 owncloud 的工程師不滿 owncloud 嘅原碼開放政策,一同離隊,另外成立公司再搞過,由於開源所以很快就聚集咗一群有心有力人士,搞得有聲有色,特別係 WebDAV API 方面做得比較好,仲有 C# 嘅 library 可以用,可以上 Xamarin 添,於是,我又學人跳槽。😀

首先,準備一隻 Ubuntu LAMP +SSH,我用 Ubuntu 16.0.4 :

用 apt-get update && apt-get upgrade 一下,然後安裝 php modules:

sudo apt-get install php-gd php-json php-mysql php-curl php-intl php-mcrypt php-imagick php-zip php-dom php-xml php-mbstring

去官網下載最新嘅 nextcloud:

wget https://download.nextcloud.com/server/releases/latest-12.tar.bz2

解壓,同時放喺 apache 之內:

sudo tar -C /var/www -xvjf latest-12.tar.bz2

同 own cloud 一樣,你要手動改一下啲 files 嘅 access rights,同時要加番啲未有嘅檔案夾。因為比較多句子,可以做一個 bash script,唔使打得咁麻煩:

sudo vi permission.sh

抄哩段 script:

#!/bin/bash
ocpath='/var/www/nextcloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

printf “Creating possible missing Directories\n”
mkdir -p $ocpath/data
mkdir -p $ocpath/updater

printf “chmod Files and Directories\n”
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf “chown Directories\n”
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf “chmod/chown .htaccess\n”
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi

執行:

sudo bash permisssion.sh

Output 大概跟這個相同:

Creating possible missing Directories
chmod Files and Directories
chown Directories
chmod/chown .htaccess

加個 website 嘅 config file,或者:

<VirtualHost *:80>
DocumentRoot “/var/www/nextcloud”
ServerName yours.domain.com

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<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
Satisfy Any

</Directory>

</VirtualHost>

我想用 root,於是就照用 default website,不過改咗少少:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/nextcloud
        ServerName yours.doamin.com

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

要 enable module rewrite:

sudo a2enmod rewrite

可以 reload 隻 apache,或者 restart:

sudo systemctl reload apache2

or

sudo service apache2 restart

最後就係去訪問你隻 nextcloud:

照答問題,完成最後步驟,create 第一個 user (admin user),同時 create 你個 nextcloud database!哩度係要答你安裝 LAMP 嘅時候你俾 MySQL 嘅 user name 同密碼:

唔好話俾我知你當時冇抄低。😜

*** 完 ***

P.S. mass copy 之後 rescan 啲檔案:

個 command 要喺你安裝咗 nextcloud 嘅 root 執行先有效,即係要先 cd 一下。