View previous topic :: View next topic |
Author |
Message |
davidbrooke Guru
Joined: 03 Jan 2015 Posts: 341
|
Posted: Thu Jul 07, 2016 2:55 am Post subject: Nextcloud and Lighttpd |
|
|
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
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 |
|
|
davidbrooke Guru
Joined: 03 Jan 2015 Posts: 341
|
Posted: Thu Jul 07, 2016 2:59 am Post subject: |
|
|
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 |
|
|
davidbrooke Guru
Joined: 03 Jan 2015 Posts: 341
|
|
Back to top |
|
|
davidbrooke Guru
Joined: 03 Jan 2015 Posts: 341
|
|
Back to top |
|
|
misterxx Guru
Joined: 18 Apr 2004 Posts: 514
|
Posted: Tue May 05, 2020 8:58 am Post subject: |
|
|
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 |
|
|
xaviermiller Bodhisattva
Joined: 23 Jul 2004 Posts: 8722 Location: ~Brussels - Belgique
|
Posted: Tue May 05, 2020 10:24 am Post subject: |
|
|
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 |
|
|
misterxx Guru
Joined: 18 Apr 2004 Posts: 514
|
Posted: Tue May 05, 2020 12:57 pm Post subject: |
|
|
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 |
|
|
|