<?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=Moonlies</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=Moonlies"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Moonlies"/>
	<updated>2026-04-26T15:53:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=15514</id>
		<title>Nginx with PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=15514"/>
		<updated>2018-11-26T14:59:08Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Configuration of PHP5 */ added, where to add ENV variables&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Nginx}}&lt;br /&gt;
&lt;br /&gt;
== PHP5 Installation ==&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php5 with modules run:&lt;br /&gt;
{{cmd|apk add php5-fpm php5-mcrypt php5-soap php5-openssl php5-gmp php5-pdo_odbc php5-json php5-dom php5-pdo php5-zip php5-mysql php5-mysqli php5-sqlite3 php5-apcu php5-pdo_pgsql php5-bcmath php5-gd php5-xcache php5-odbc php5-pdo_mysql php5-pdo_sqlite php5-gettext php5-xmlreader php5-xmlrpc php5-bz2 php5-memcache php5-mssql php5-iconv php5-pdo_dblib php5-curl php5-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration of PHP5 ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration. You can do this e.g. in [https://stackoverflow.com/questions/35325856/where-to-set-system-default-environment-variables-in-alpine-linux /etc/profile.d/php5.sh].&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php5/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php5/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP5 ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php5/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php5/php-fpm.conf&lt;br /&gt;
vi /etc/php5/php.ini}}&lt;br /&gt;
&lt;br /&gt;
== PHP7 Installation ==&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php7 with modules run:&lt;br /&gt;
{{cmd|apk add php7-fpm php7-mcrypt php7-soap php7-openssl php7-gmp php7-pdo_odbc php7-json php7-dom php7-pdo php7-zip php7-mysqli php7-sqlite3 php7-apcu php7-pdo_pgsql php7-bcmath php7-gd php7-odbc php7-pdo_mysql php7-pdo_sqlite php7-gettext php7-xmlreader php7-xmlrpc php7-bz2 php7-iconv php7-pdo_dblib php7-curl php7-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration of PHP7 ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration. You can do this e.g. in [https://stackoverflow.com/questions/35325856/where-to-set-system-default-environment-variables-in-alpine-linux /etc/profile.d/php7.sh].&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php7/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php7/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php7/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php7/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP7 ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm7 default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php7/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php7/php-fpm.conf&lt;br /&gt;
vi /etc/php7/php.ini}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server]]&lt;br /&gt;
[[Category:PHP]]&lt;/div&gt;</summary>
		<author><name>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=15513</id>
		<title>Nginx with PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=15513"/>
		<updated>2018-11-26T14:58:11Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Configuration of PHP7 */ added note where to add ENV variables.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Nginx}}&lt;br /&gt;
&lt;br /&gt;
== PHP5 Installation ==&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php5 with modules run:&lt;br /&gt;
{{cmd|apk add php5-fpm php5-mcrypt php5-soap php5-openssl php5-gmp php5-pdo_odbc php5-json php5-dom php5-pdo php5-zip php5-mysql php5-mysqli php5-sqlite3 php5-apcu php5-pdo_pgsql php5-bcmath php5-gd php5-xcache php5-odbc php5-pdo_mysql php5-pdo_sqlite php5-gettext php5-xmlreader php5-xmlrpc php5-bz2 php5-memcache php5-mssql php5-iconv php5-pdo_dblib php5-curl php5-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration of PHP5 ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration.&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php5/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php5/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP5 ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php5/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php5/php-fpm.conf&lt;br /&gt;
vi /etc/php5/php.ini}}&lt;br /&gt;
&lt;br /&gt;
== PHP7 Installation ==&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php7 with modules run:&lt;br /&gt;
{{cmd|apk add php7-fpm php7-mcrypt php7-soap php7-openssl php7-gmp php7-pdo_odbc php7-json php7-dom php7-pdo php7-zip php7-mysqli php7-sqlite3 php7-apcu php7-pdo_pgsql php7-bcmath php7-gd php7-odbc php7-pdo_mysql php7-pdo_sqlite php7-gettext php7-xmlreader php7-xmlrpc php7-bz2 php7-iconv php7-pdo_dblib php7-curl php7-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration of PHP7 ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration. You can do this e.g. in [https://stackoverflow.com/questions/35325856/where-to-set-system-default-environment-variables-in-alpine-linux /etc/profile.d/php7.sh].&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php7/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php7/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php7/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php7/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php7/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php7/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP7 ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm7 start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm7 default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php7/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php7/php-fpm.conf&lt;br /&gt;
vi /etc/php7/php.ini}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server]]&lt;br /&gt;
[[Category:PHP]]&lt;/div&gt;</summary>
		<author><name>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Nextcloud&amp;diff=15440</id>
		<title>Talk:Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Nextcloud&amp;diff=15440"/>
		<updated>2018-08-12T12:55:40Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: fixed opcache and path issues&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are a few missing steps that turn into warnings in the UI&lt;br /&gt;
&lt;br /&gt;
* enabling APCu or another cache&lt;br /&gt;
  (set in a apcu.ini AND config.php)&lt;br /&gt;
&lt;br /&gt;
Is there a reason why php5-fpm is recommended instead of php7-fpm?&lt;br /&gt;
Php5 isn&#039;t supported by many applications anymore and will soon become deprecated.&lt;/div&gt;</summary>
		<author><name>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15439</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15439"/>
		<updated>2018-08-12T12:54:38Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Configure and use Nextcloud */ opcache&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&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&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&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 /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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /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 /etc/php7/php-fpm.d/www.conf}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in /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 member of 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 /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 package:&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>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15438</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15438"/>
		<updated>2018-08-12T11:15:44Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Nginx */ edit nginx.conf&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&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&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&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 /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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /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 /etc/php7/php-fpm.d/www.conf}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in /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 member of 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 /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 package:&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;
== 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>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15437</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15437"/>
		<updated>2018-08-12T11:04:58Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Nginx */ fixed php7, added auto startup&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&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&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&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 /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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /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 /etc/php7/php-fpm.d/www.conf}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in /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 member of 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;
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 package:&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;
== 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>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15436</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15436"/>
		<updated>2018-08-12T10:56:51Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: /* Nginx */ added sites-enabled, fixed standard nextcloud path&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&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&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&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 /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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /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 /etc/php7/php-fpm.d/www.conf}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in /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 member of 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;
Start services&lt;br /&gt;
{{cmd|rc-service php-fpm start&lt;br /&gt;
rc-service nginx start}}&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 package:&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;
== 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>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15435</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15435"/>
		<updated>2018-08-12T10:52:07Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: changed php version for nginx to 7 also added $path uncommenting&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&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&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&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 a directory for your websites&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in /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 /var/www/vhosts/mysite.mydomain.com/www;&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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /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 /etc/php7/php-fpm.d/www.conf}}&lt;br /&gt;
&lt;br /&gt;
Also enable $PATH by uncommenting the following lines in /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 member of 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;
Start services&lt;br /&gt;
{{cmd|rc-service php-fpm start&lt;br /&gt;
rc-service nginx start}}&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 package:&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;
== 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>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Nextcloud&amp;diff=15403</id>
		<title>Talk:Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Nextcloud&amp;diff=15403"/>
		<updated>2018-08-06T18:23:21Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: PHP5 or PHP7&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are a few missing steps that turn into warnings in the UI&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* enabling $PATH for FPM (set in php-fpm.conf where PATH is normally disabled)&lt;br /&gt;
* enabling opcache (set in a php.ini or opcache.ini)&lt;br /&gt;
* enabling APCu or another cache&lt;br /&gt;
  (set in a apcu.ini AND config.php)&lt;br /&gt;
&lt;br /&gt;
Is there a reason why php5-fpm is recommended instead of php7-fpm?&lt;br /&gt;
Php5 isn&#039;t supported by many applications anymore and will soon become deprecated.&lt;/div&gt;</summary>
		<author><name>Moonlies</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15400</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=15400"/>
		<updated>2018-08-06T18:12:05Z</updated>

		<summary type="html">&lt;p&gt;Moonlies: added mariadb package to installation&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 latest packages available. Make sure you are using a &#039;http&#039; repository in your {{path|/etc/apk/repositories}} and then run:&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. Follow one of the below database alternatives.&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 temporary grant 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; to 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, 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; to 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 when working with large files will consume a lot of memory (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. We&#039;re not explaining how to generate an SSL certificate for your webserver.&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages&lt;br /&gt;
{{cmd|apk add nginx php5-fpm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remove/comment&#039;&#039;&#039; any section like this in&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&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 a directory for your websites&lt;br /&gt;
{{cmd|mkdir /etc/nginx/sites-available}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in /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 /var/www/vhosts/mysite.mydomain.com/www;&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;
&lt;br /&gt;
        ssl_session_cache    shared:SSL:1m;&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 /tmp to /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 files upload takes sometime to be processed by php-fpm. So you need to bump the Nginx read default 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 /etc/php5/php-fpm.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 /etc/php5/php-fpm.conf}}&lt;br /&gt;
&lt;br /&gt;
Make nginx user member of 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;
Start services&lt;br /&gt;
{{cmd|rc-service php-fpm start&lt;br /&gt;
rc-service nginx start}}&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 package:&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;
== 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>Moonlies</name></author>
	</entry>
</feed>