After spending some time, I finally make nextcloud working on openwrt. I share my experience below:
mkdir /www/nextcloud
opkg update
opkg install lighttpd lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-access
opkg install php8 php8-cgi php8-fastcgi php8-mod-fpm php8-mod-bcmath php8-mod-calendar php8-mod-ctype php8-mod-curl php8-mod-dom php8-mod-exif php8-mod-fileinfo php8-mod-filter php8-mod-ftp php8-mod-gd php8-mod-gettext php8-mod-gmp php8-mod-iconv php8-mod-imap php8-mod-intl php8-mod-ldap php8-mod-mbstring php8-mod-mysqlnd php8-mod-openssl php8-mod-pdo php8-mod-pdo-mysql php8-mod-pdo-pgsql php8-mod-pdo-sqlite php8-mod-pgsql php8-mod-phar php8-mod-session php8-mod-simplexml php8-mod-sqlite3 php8-mod-xml php8-mod-xmlreader php8-mod-xmlwriter php8-mod-zip php8-pecl-mcrypt php8-pecl-redis
#some of the packages may not needed, but I just install them all
Edit the config-file /etc/lighttpd/lighttpd.conf
server.document-root = "/www/nextcloud"
server.errorlog-use-syslog = "enable"
server.port = 81
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_cgi"
)
$HTTP["url"] =~ "^/data/" {
url.access-deny = ("")
}
index-file.names = ( "index.php", "index.html", "default.html", "index.htm", "default.htm" )
static-file.exclude-extensions = (".php, ".pl", ".fcgi")
fastcgi.server = (
".php" => ((
"bin-path" => "/usr/bin/php-fcgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1
))
)
save and reboot the router.
Now you can either use automatic setup or manual setup.
I use automatic setup:
cd /www/nextcloud
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
Now open the browser and type the address http://192.168.10.1:81/setup-nextcloud.php(I use 192.168.10.1 as my router address and port 81 for lighttpd). It will open the installation page.
here you can enter your installation path or just enter "." to use /www/nextcloud. Click next to download the nextcloud files and the installer will set all the permissions to the folders and files. Wait until the setup is complete and then you can click next to open the login page. Create admin account by enter the admin username and password and then click install.
that is all. After installation completed, you are able to login and configure users etc.
After that, you can change to https and open port for external access.
Install nextcloud app from apple store or google play, you can use it on mobile devices.
see the files and folders permissions below: