paapereira.xyz

Nextcloud Arch Linux installation

There are my notes for installing Nextcloud in Arch Linux in my home server.

Server installation

1sudo pacman -Syu apache php php-apache mariadb
2cower -d nextcloud
3sudo pacman -Syu php-gd php-intl php-mcrypt php-apcu

PHP configuration

1sudo nano /etc/php/php.ini

Uncomment the following modules:

Add the following to open_basedir:

/tmp:/usr/share/webapps/nextcloud:/dev/urandom

MariaDB setup

1sudo mysql_install_db -–user=mysql -–basedir=/usr -–datadir=/var/lib/mysql
2sudo systemctl enable mariadb.service
3sudo systemctl start mariadb.service
4sudo systemctl status mariadb.service
5sudo mysql_secure_installation

Create Nextcloud database

1mysql -u root -p
2  CREATE DATABASE IF NOT EXISTS nextcloud;
3  CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;
4  GRANT ALL PRIVILEGES ON nextcloud.* TO ‘username’@’localhost’ IDENTIFIED BY ‘password’;
5  quit

Apache setup

1sudo cp /etc/webapps/nextcloud/apache.example.conf /etc/httpd/conf/extra/nextcloud.conf
2sudo nano /etc/httpd/conf/httpd.conf

Comment the line:

`#LoadModule mpm_event_module modules/mod_mpm_event.so`

Uncomment the line:

`LoadModule mpm_prefork_module modules/mod_mpm_prefork.so`

After LoadModule dir_module modules/mod_dir.so, place the following module:

`LoadModule php7_module modules/libphp7.so`

At the end of the Include list place the following line:

`Include conf/extra/php7_module.conf`

At the end of the LoadModule list add the following line:

`AddHandler php7-script php`

At the bottom of /etc/httpd/conf/httpd.conf add the following line:

`Include conf/extra/nextcloud.conf`

Enable the following modules:

1sudo systemctl enable httpd.service
2sudo systemctl start httpd.service
3sudo systemctl status httpd.service

Switch to Cron from AJAX

1sudo pacman -S cronie
2sudo crontab -u http -e
`*/15  *  *  *  * php -f /usr/share/webapps/nextcloud/cron.php`
1sudo crontab -u http -l

Enable memcache

1sudo nano /etc/php/conf.d/apcu.ini
`extension=apcu.so`

Certificate

1sudo cp /etc/httpd/conf/server.crt /usr/share/ca-certificates/domain.com.crt
2sudo nano /etc/ca-certificates.conf
1domain.com.crt
1sudo update-ca-certificates

File location

1sudo mkdir /home/nas/nextcloud
2sudo nano /etc/fstab
1nas:/nfs/nextcloud  /home/nas/nextcloud nfs  users,noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,soft,intr,noatime,file_mode=0640,dir_mode=0750 0 0

Nextcloud config.php

1sudo nano /etc/webapps/nextcloud/config/config.php
 1  <?php
 2  $CONFIG = array (
 3	'instanceid' => 'XXXXXXXXXXXXXXXXXXXXX',
 4	'passwordsalt' => 'XXXXXXXXXXXXXXXX',
 5	'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
 6	'trusted_domains' =>
 7	array (
 8	  0 => 'server',
 9	  1 => 'my_domain.net',
10	),
11	'datadirectory' => '/home/nas/nextcloud',
12	'overwrite.cli.url' => 'https://server/nextcloud',
13	'dbtype' => 'mysql',
14	'version' => '9.1.1.5',
15	'dbname' => 'nextcloud',
16	'dbhost' => 'localhost',
17	'dbport' => '',
18	'dbtableprefix' => 'oc_',
19	'dbuser' => 'nextcloud',
20	'dbpassword' => 'XXXXXXXXXXXXXXXXXX',
21	'logtimezone' => 'UTC',
22	'installed' => true,
23	'memcache.local' => '\\OC\\Memcache\\APCu',
24	'mail_smtpmode' => 'smtp',
25	'mail_from_address' => 'nextcloud',
26	'mail_domain' => 'mail.com',
27	'mail_smtpauth' => 1,
28	'mail_smtphost' => 'smtp.mail.com',
29	'mail_smtpport' => '587',
30	'mail_smtpname' => 'your_mail@mail.com',
31	'mail_smtppassword' => 'XXXXXXXXXXXXXXXXXXXX',
32	'mail_smtpauthtype' => 'LOGIN',
33	'mail_smtpsecure' => 'tls',
34  );

Permissions

1sudo nano /root/nexcloud_strong_permissions.sh
 1  #!/bin/bash
 2  ocpath='/usr/share/webapps/nextcloud'
 3  htuser='http'
 4  htgroup='http'
 5  rootuser='root'
 6
 7  printf "Creating possible missing Directories\n"
 8  mkdir -p $ocpath/data
 9  mkdir -p $ocpath/assets
10  mkdir -p $ocpath/updater
11
12  printf "chmod Files and Directories\n"
13  find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
14  find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
15
16  printf "chown Directories\n"
17  chown -R ${rootuser}:${htgroup} ${ocpath}/
18  chown -R ${htuser}:${htgroup} ${ocpath}/apps/
19  chown -R ${htuser}:${htgroup} ${ocpath}/assets/
20  chown -R ${htuser}:${htgroup} ${ocpath}/config/
21  chown -R ${htuser}:${htgroup} ${ocpath}/data/
22  chown -R ${htuser}:${htgroup} ${ocpath}/themes/
23  chown -R ${htuser}:${htgroup} ${ocpath}/updater/
24
25  chmod +x ${ocpath}/occ
26
27  printf "chmod/chown .htaccess\n"
28  if [ -f ${ocpath}/.htaccess ]
29   then
30	chmod 0644 ${ocpath}/.htaccess
31	chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
32  fi
33  if [ -f ${ocpath}/data/.htaccess ]
34   then
35	chmod 0644 ${ocpath}/data/.htaccess
36	chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
37  fi
1$ sudo nano /root/nexcloud_upgrade_permissions.sh
1  #!/bin/bash
2
3  # Sets permissions of the Nextcloud instance for updating
4
5  ocpath='/usr/share/webapps/nextcloud'
6  htuser='http'
7  htgroup='http'
8
9  chown -R ${htuser}:${htgroup} ${ocpath}
1sudo +x /root/nexcloud_strong_permissions.sh
2sudo +x /root/nexcloud_upgrade_permissions.sh
3
4sudo /root/nexcloud_strong_permissions.sh
5sudo /root/nexcloud_upgrade_permissions.sh

Desktop installation

1cower -d nextcloud-client

First login

http://server/nextcloud

#Linux #Arch Linux #Tags/Nextcloud