<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Eogan</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Eogan"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Eogan"/>
	<updated>2026-04-26T21:13:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15862</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15862"/>
		<updated>2019-04-02T13:35:06Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* How To Create a Self-Signed SSL Certificate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql postgresql postgresql-client}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
Install openssl:&lt;br /&gt;
{{cmd|apk add openssl}}&lt;br /&gt;
Generate your self signed certificate and its private key:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Edit your nginx configuration:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
ssl_certificate      /etc/ssl/certs/nginx-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl/private/nginx-selfsigned.key;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15849</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15849"/>
		<updated>2019-03-24T23:17:55Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* Other settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
Install openssl:&lt;br /&gt;
{{cmd|apk add openssl}}&lt;br /&gt;
Generate your self signed certificate and its private key:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Edit your nginx configuration:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
ssl_certificate      /etc/ssl/certs/nginx-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl/private/nginx-selfsigned.key;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15848</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15848"/>
		<updated>2019-03-24T23:10:10Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* How To Create a Self-Signed SSL Certificate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;ssl_certificate      /etc/ssl/certs/nginx-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl/private/nginx-selfsigned.key;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15847</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15847"/>
		<updated>2019-03-24T23:07:37Z</updated>

		<summary type="html">&lt;p&gt;Eogan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15846</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15846"/>
		<updated>2019-03-24T22:46:57Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* MariaDB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15845</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15845"/>
		<updated>2019-03-24T22:40:37Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* MariaDB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|mysql_install_db --user=mysql --datadir=/var/lib/m&lt;br /&gt;
ysql&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15844</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15844"/>
		<updated>2019-03-24T22:04:55Z</updated>

		<summary type="html">&lt;p&gt;Eogan: /* Nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|/etc/init.d/mariadb setup&lt;br /&gt;
/etc/init.d/mariadb start&lt;br /&gt;
/usr/bin/mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php7-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
server {&lt;br /&gt;
        listen ...&lt;br /&gt;
       }&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Include the following directive in {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
{{cat|/etc/nginx/nginx.conf|&lt;br /&gt;
http {&lt;br /&gt;
      ...&lt;br /&gt;
      include /etc/nginx/sites-enabled/*;&lt;br /&gt;
      ...&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Create directories for your websites:&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-enabled}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/sites-available/mysite.mydomain.com}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set user and group for php-fpm in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
user = nginx&lt;br /&gt;
group = www-data&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving serveral users make sure to tune the *&#039;&#039;children&#039;&#039; settings in {{path|/etc/php7/php-fpm.d/www.conf}}}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in {{path|/etc/php7/php-fpm.d/www.conf}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
env[HOSTNAME] = $HOSTNAME&lt;br /&gt;
env[PATH] = /usr/local/bin:/usr/bin:/bin&lt;br /&gt;
env[TMP] = /tmp&lt;br /&gt;
env[TMPDIR] = /tmp&lt;br /&gt;
env[TEMP] = /tmp&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make nginx user a member of the www-data group:&lt;br /&gt;
{{cmd|addgroup nginx www-data}}&lt;br /&gt;
&lt;br /&gt;
Enable your website:&lt;br /&gt;
{{cmd|ln -s ../sites-available/mysite.mydomain.com /etc/nginx/sites-enabled/mysite.mydomain.com}}&lt;br /&gt;
&lt;br /&gt;
The default configuration of nginx shows a 404 page. Therefore, we have to edit {{path|/etc/nginx/nginx.conf}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
# include /etc/nginx/conf.d/*.conf;&lt;br /&gt;
include /etc/nginx/sites-enabled/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start&lt;br /&gt;
rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add php-fpm7&lt;br /&gt;
rc-update add nginx}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-pdfviewer nextcloud-texteditor nextcloud-notifications nextcloud-videoplayer}}&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
Default configuration for php is limited to 2Mb file size. You might want to increase that size by editing the {{path|/etc/php/php.ini}} and change the following values to something that suits you:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 2M&lt;br /&gt;
post_max_size = 8M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Eogan</name></author>
	</entry>
</feed>