Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Nextcloud and Lighttpd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Thu Jul 07, 2016 2:55 am    Post subject: Nextcloud and Lighttpd Reply with quote

I have recently switched from Owncloud to Nextcloud. The following are my installation steps for Nextcloud and Lighttpd.

Reference URL's
https://docs.nextcloud.org/server/9/admin_manual/contents.html
https://wiki.gentoo.org/wiki/Owncloud
https://wiki.gentoo.org/wiki/Lighttpd
https://wiki.gentoo.org/wiki/PHP
https://wiki.gentoo.org/wiki/Webapp-config
https://forums.gentoo.org/viewtopic-t-1028396.html (my previous Owncloud and Lighttpd installation)

Nextcloud current version = 9.0.51

1. Add the following to package.accept_keywords:
Code:
app-admin/webapp-config ~amd64
dev-lang/php ~amd64
www-servers/lighttpd ~amd64
www-apps/nextcloud ~amd64

2. Install webapp-config
A.
Code:
emerge -av webapp-config

B. Modify /etc/vhosts/webapp-config
from
Code:
vhost_server="apache"

to
Code:
vhost_server="lighttpd"

3. Install webserver lighttpd (use -php)
Code:
emerge -av www-servers/lighttpd

4. Install Nextcloud server
A. Modify package.use
Code:
dev-lang/php fpm sqlite zip pdo xmlreader gd curl xmlwriter
app-eselect/eselect-php fpm

B. Install Nextcloud
Code:
emerge -av www-apps/nextcloud

5. Modify /etc/lighttpd/lighttpd.conf
Uncomment the following
Code:
server.document-root = var.basedir + "/htdocs"
server.errorlog      = var.logdir  + "/error.log"
accesslog.filename   = var.logdir + "/access.log"
include "mod_fastcgi.conf"

6. Modify /etc/lighttpd/mod_fastcgi.conf
Replace the existing code with the following:
Code:
server.modules += ("mod_fastcgi")
fastcgi.server = ( ".php" =>
  ( "localhost" =>
    (
      "host" => "127.0.0.1",
      "port" => "9000"
    )
  )
)

7. Modify /etc/php/fpm-php7.0/php.fpm.conf
A. Uncomment
Code:
error_log = /var/log/php-fpm.log

B. Add the following
Code:
user = clouddata
group = clouddata
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin:/var/www/localhost/htdocs:
env[TMP] = /tmp

8. Test lighttpd.conf
Code:
lighttpd-angel -t -f /etc/lighttpd/lighttpd.conf

Should see something similar:
Code:
Syntax OK
lighttpd-angel.c.139: child (pid=26771) exited normally with exitcode: 0

9. Set the timezone
Add the following to /etc/php/fpm-php7.0/php.ini
Code:
date.timezone = America/New_York

10. Create cloud data group/user
Code:
groupadd -g 988 clouddata && useradd -g clouddata clouddata

11. Change ownership to lighttpd ***OPTIONAL***
Code:
chown -R lighttpd:lighttpd /var/www/localhost/

12. Change ownership to nextcloud (Nextcloud script)
Run nextcloud.sh
Code:
#. nextcloud.sh

13. Modify group
Add lighttpd to clouddata
Code:
clouddata:x:988:lighttpd

14. Start lighttpd & php-fpm
Code:
rc-update add lighttpd default && rc-update add php-fpm default && /etc/init.d/php-fpm start && /etc/init.d/lighttpd start

15. Test lighttpd in browser
A. The following will show a list of variables (see below for code)
Code:
http://localhost/info.php

or
B. The following will show the current group and user (see below for code)
Code:
http://localhost/whoami.php

16. Restart

17. Nextcloud setup
A. http://localhost/nextcloud
B. Select "Storage and Database" to change data location to /to/your/nextcloud/data (/to/your/nextcloud/data will be created, do not create!)
C. Create admin user and password
D. Select "Finish Setup" to complete setup
E. Setup other users and apps

18. Change file handling size (Can't be changed in GUI due to Lighttpd)
Modify /var/www/localhost/htdocs/nextcloud/.user.ini via root
From
Code:
upload_max_filesize=513M
post_max_size=513M

To
Code:
upload_max_filesize=16G
post_max_size=16G

19. Setup cron job
Code:
sudo crontab -u clouddata -e
*/15  *  *  *  * php -f /var/www/localhost/htdocs/nextcloud/cron.php

20. Trusted Domains issue - add server ip address
Modify /var/www/localhost/htdocs/nextcloud/config/config.php
From
Code:
array (
    0 => 'localhost',
),

To
Code:
array (
    0 => 'localhost','nextcloud.server.ip.address',
),


**********************************************************************************************

The following three files are to help setup Nextcloud.

1. Nextcloud script - change permissions for nextcloud
Code:
#!/bin/bash
ncpath='/var/www/localhost/htdocs/nextcloud'
htuser='clouddata'
htgroup='clouddata'
rootuser='root'

printf "Creating possible missing Directories\n"
mkdir -p $ncpath/data
mkdir -p $ncpath/assets
mkdir -p $ncpath/updater

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

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ncpath}/
chown -R ${htuser}:${htgroup} ${ncpath}/apps/
chown -R ${htuser}:${htgroup} ${ncpath}/assets/
chown -R ${htuser}:${htgroup} ${ncpath}/config/
chown -R ${htuser}:${htgroup} ${ncpath}/data/
chown -R ${htuser}:${htgroup} ${ncpath}/themes/
chown -R ${htuser}:${htgroup} ${ncpath}/updater/

chmod +x ${ncpath}/occ

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

2. /var/www/localhost/htdocs/info.php - PHP info
Code:
<?php phpinfo(); ?>

3. /var/www/localhost/htdocs/whoami.php - Tells who is the current group and user for Nextcloud
Code:
<?php
echo "User: " . exec('whoami');
echo "Group: " . exec('groups');
?>


Last edited by davidbrooke on Fri Jul 15, 2016 11:24 pm; edited 2 times in total
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Thu Jul 07, 2016 2:59 am    Post subject: Reply with quote

Reserved for Nextcloud client when available.
For now the Owncloud client can be used but you will need to specify "nextcloud" in the server setup:
Code:
nextcloud.server.ip.address/nextcloud
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Thu Jul 07, 2016 3:00 am    Post subject: Reply with quote

Upgrade

Reference:
https://docs.nextcloud.org/server/9/admin_manual/maintenance/upgrade.html
https://docs.nextcloud.org/server/9/admin_manual/maintenance/package_upgrade.html
https://docs.nextcloud.org/server/9/admin_manual/configuration_server/occ_command.html#command-line-upgrade-label

After portage upgrades Nextcloud make the following adjustments:
1. Run Nextcloud upgrade
A. Open Nextcloud via browser and after login an update process will be presented.
or
B. sudo -u lighttpd php occ upgrade

2. Change file handling size (Can't be changed in GUI due to Lighttpd)
Modify /var/www/localhost/htdocs/nextcloud/.user.ini via root
From
upload_max_filesize=513M
post_max_size=513M
To
upload_max_filesize=16G
post_max_size=16G

3. Re-enable app's
Calender

Note:
The upgrade process was much easier and smoother than Owncloud.
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Tue Oct 11, 2016 9:13 pm    Post subject: Reply with quote

Upgrade to version 10.0.1

Reference:
https://docs.nextcloud.org/server/9/admin_manual/maintenance/upgrade.html
https://docs.nextcloud.org/server/9/admin_manual/maintenance/package_upgrade.html
https://docs.nextcloud.org/server/9/admin_manual/configuration_server/occ_command.html#command-line-upgrade-label

After portage upgrades Nextcloud make the following adjustments:
1. Run Nextcloud upgrade
A. Open Nextcloud via browser and after login an update process will be presented.

2. Change file handling size (Can't be changed in GUI due to Lighttpd)
Modify /var/www/localhost/htdocs/nextcloud/.user.ini via root
From
upload_max_filesize=513M
post_max_size=513M
To
upload_max_filesize=16G
post_max_size=16G

3. Re-enable app's
Calender

Note:
The upgrade process again, was much easier and smoother than Owncloud.
Back to top
View user's profile Send private message
misterxx
Guru
Guru


Joined: 18 Apr 2004
Posts: 514

PostPosted: Tue May 05, 2020 8:58 am    Post subject: Reply with quote

Good Topic, thank you, davidbrooke!

How we can run occ script?

Code:
# php occ - apache list
Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: apache
Try adding 'sudo -u apache ' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u apache' to the docker command (without the single quotes)


We can not login like a apache to execute this and we dont have sudo.
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8722
Location: ~Brussels - Belgique

PostPosted: Tue May 05, 2020 10:24 am    Post subject: Reply with quote

you need to run it as the user associated to lighthttpd:
Code:
su -s /bin/bash -c "php /var/www/localhost/htdocs/nextcloud/occ COMMAND" lighthttpd

_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
misterxx
Guru
Guru


Joined: 18 Apr 2004
Posts: 514

PostPosted: Tue May 05, 2020 12:57 pm    Post subject: Reply with quote

xaviermiller wrote:
you need to run it as the user associated to lighthttpd:
Code:
su -s /bin/bash -c "php /var/www/localhost/htdocs/nextcloud/occ COMMAND" lighthttpd


Thank you! It works fine!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum