I am not so good at making tutorials, but here it is:
**Disclaimer:**
* This tutorial does not include the specific configurations on how to set-up
Nextlcloud server as you can read any other linux tutorial on how to setup a
web-server for that and it can be applied here.
* This tutorial will simply make your Termux setup run with all the necessary
dependencies to set-up a Nextcloud server (or any other web server in
general).
**Necessary apps:**
* Termux
**Prerequisite knowledge:**
* Basic knowledge of running a webserver (LAMP/Caddy Server, etc) in linux.
Without this knowledge/understanding beforehand, you will not be able to setup
the Nextcloud server properly here. (If you don't know how to install
Nextcloud server in the first place, you will not be able to install Nextcloud
server in Termux.)
**Tutorial**
**In termux:**
1.) You want all your commands to be read in arm64/aarch64 architecture. To do
that, type: "setarch linux64" (Or "setarch arm64", or "setarch aarch64").
Default SOC Architecture settings vary depending on your phone/OS, and in my
case, the default in my device (Snapdragon 865 SOC) is arm8l (Which is aarch
set to 32-bit mode, so I had to manually change this to proceed). To know what
your current architecture setting is type in the command line "uname -m". You
want "aarch64" to appear here, or else you won't be able to install 64-bit
programs (such as the Collabora Built-in CODE server ARM64)).
2) You want to get all the Nextcloud server dependencies. Since original
termux repo may not contain every package you need (depending on how you want
to run your server), you want to get to an environment where all package
dependencies are available. To do that, type: " apt install proot-distro"
then, "proot-distro install ubuntu-20.04", then "proot-distro login
ubuntu-20.04"
3) Now that you are in a fresh ubuntu-20.04 environment, you want to update
your packages. To do that type: "apt-get update".
4) "sudo" is not installed by default in proot-distro. You want to install
"sudo" to have correct arguments running inside the commands of your programs
(especially if you want to run Nextcloud server using Caddy). To do this,
type: "apt-get install sudo"
5) You now want to complete all the dependencies to run Nextcloud server.
Nextcloud is a php based web server application, so you can choose whichever
server program you are comfortable of using. This tutorial assumes that you
have basic knowledge of running a web server.
From here onward, it will be depending on the user's personal preference on
which programs he/she want to run his/her Nextcloud webserver on. Specific
configuration on running and fine-tuning a webserver is not included in this
tutorial as there are lots of better resources in the internet for that (Any
linux tutorial related to this is generally applicable here too.).
NOTE: Since you are now in an ubuntu linux environment, you can just install
setup a LAMP server (or other program variations you prefer to get your web
server running)
6) Install Caddy server (you can also use nginx, apache, etc., I just prefer
caddy for its simplicity in setting up https)
7) Install Php8.0 (you can also use other versions of php (such as 7.2 or
7.4))
8) Install Mysql/MariaDB (you can also use other database programs such as
PostgreSQL or you can even just use php-sqlite)
9) Assuming that you were able to setup a running web server,[download
Nextcloud server installer, and save it in your website
directory.](https://nextcloud.com/install/#instructions-server)
10) Completing Nextcloud setup:
A. In the web browser of the android device, access
"localhost/setup-nextcloud.php" to finish setting up your Nextcloud server.
OR
B. Turn on mobile hotspot of the android device. In another device
(pc/tablet/smartphone), connect to the hotspot. Open the web browser of
the other device, and connect "<ip address of the web
server>/setup-nextcloud.php" to finish setting up your Nextcloud server.
\*to see the ip address of mobile hotspot of the device, in Termux, type: "ip
a" and look for the line containing "inet" under "wlan."
-
install some dependencies
pkg install php php-fpm sqlite coreutils openssl-tool -
Allow Termux to access storage outside of own folder
termux-setup-storage -
(If you want to clone with Termux:
cd /storage/emulated/0/ && git clone https://github.com/nextcloud/server.git nextcloud) -
Get the Nextcloud submodules
cd /storage/emulated/0/nextcloud/ && git submodule update --init -
Start the server
php -S 0.0.0.0:8080 -t /storage/emulated/0/nextcloud/
- Go to
http://0.0.0.0:8080 - Set an admin username and password in the
- (SQLite will be used as database)
**Optional:**
For convenience, for android pie and up, you can [configure your dnsmasq so
that your device mobile hotspot ip address will be
static.](https://android.stackexchange.com/questions/213514/how-can-i-permanently-change-my-hotspot-tethering-ip-address)
(By doing this, you do not need to manually rewrite your new ip address in the
trusted domains of the nextcloud config.php every time when you restart your
mobile hotspot.)