OMG
OMG
OMG
Where will it end.
how-to Nextcloud on Android
This is a working local cloud. I have just done this because
- I use NC for some time and wanted to know how the installation goes now a days. ( I am very amazed )
- see if it would run on unrooted Android 9
I Simply supply the steps i have taken. There are still errors in the admin overview but i’m so psyched I wanted to share this because it was SO easy.
You will need to setup the following package/programs ( LAMP Server )
- Android Termux ( not the GooglePlay version )
- Linux proot-distro
- Apache
- MySQL
- PHP 7,4
Get Termux here https://f-droid.org/repo/com.termux_118.apk
or install F-droid a alternative for Google Play Store https://f-droid.org/F-Droid.apk
and search there for termux (terminal emulator)
open it when installation is finished. ( you need atleast 1 terminal open to keep nc running )
pkg upgrade;\
pkg install screen proot-distro -y;\
proot-distro install debian;\
proot-distro login debian
exit ( will close all proceses started in that shell )
Steps I took.
install apache ( here i include all packages needed )
apt update && apt upgrade && apt install wget apache2 php7.4 php7.4-zip php7.4-dom php7.4-gd php7.4-mbstring php7.4-curl php7.4-mysql php7.4-xmlwriter php7.4-xml php7.4-simplexml mariadb-server php7.4-intl php7.4-bcmath php7.4-imagick php7.4-opcache php7.4-gmp php7.4-apcu libmagickcore-6.q16-6-extra -y
adjust apache ports.conf change 80 to 8000 and 443 to 4443 because unrooted Android don’t allow usage of ports below 1024.
sed -i -e 's/80/8000/' -e 's/443/4443/' /etc/apache2/ports.conf
change 80 to 8000 in your 000-default.conf
sed -i -e 's/80/8000/' /etc/apache2/sites-available/000-default.conf
change 443 to 4443 in your default-ssl.conf
sed -i -e 's/443/4443/' /etc/apache2/sites-available/default-ssl.conf
here i started apache to check if that worked
service apache2 start
I didn’t have any php installed yet but got a apache default page @ http://localhost:8000
now since apache works I installed mariadb. It is included above so we continiou with.
service mariadb start
mysql_secure_installation
answer as you see fit. or as I did
- ENTER
- ENTER
- y NEW-PASSWORD
- ENTER
- ENTER
- ENTER
- ENTER
Change the root password for MySQL user root
I went to nextcloud.com looking for a zip to extract but found this setup script
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php -O /var/www/html/setup-nextcloud.php
while no php installed apache simply shows php as plain text. So I installed php7.4, because apache is installed it will also install those apachemod-php7.4
restarting apache to load the new modules
service apache2 restart
Now I got a nice Setup page @ http://localhost:8000/setup-nextcloud.php
If you want it accessible for other computers in your lan browse to http://local-IP:8000/setup-nextcloud.php
I have applied ssl later on still using the snakeoil so you have to accept ssl warnings.
after clicking NEXT I was presented a nice list of required php modules or missing so to say.
- zip
- dom
- GD
- xml Writer
- xml
- mb Multi Byte
- curl
- simplexml
only module mb Muli byte should be renamed to mbstring so it’s even easier for novice players to decode.
Since there all installed above you can simply continou on the setup fill in storage . (dot) remove the prefilled nextcloud. NEXT wait while nc is being downloaded and extracted. Page will reload when ready. ( 1 to 5 minutes )
fill in a new admin account for Nextcloud
select a data location outside the web root I used /srv/data
as database user fill in root
as password the password you created when finishing mysql_secure_installation
database as you like [nextcloud] if your creative
Install wait 2 to 3 min boem logged in local nextcloud. just like that.
solving errors
- data directory is accessible from the www
nano /var/www/html/config/config.php
change to or add
datadirectory' =. '/srv/data',
'memcache.local' => '\OC\Memcache\APCu',
'default_phone_region' => 'NL',
- missing php modules php7.4-bcmath php7.4-gmp php7.4-imagick php7.4-intl php7.4-apcu php7.4-opcache libmagickcore-6.q16-6-extra (included above)
- php memory below 512M minimum
sed -i -e 's/output_buffer = 4096/output_buffer = 0/' -e 's/memory_limit = 256M/memory_limit = 512M/' /etc/php/7.4/apache2/php.ini
- setting up ssl
a2enmod ssl
a2enmod rewrite
a2ensite default-ssl
default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:4443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/\.well-known/carddav remote.php/dav [R=301,L]
RewriteRule ^/\.well-known/caldav remote.php/dav [R=301,L]
RewriteRule ^/\.well-known/webfinger index.php/.well-known/webfinger [R=301,L]
RewriteRule ^/\.well-known/nodeinfo index.php/.well-known/nodeinfo [R=301,L]
</IfModule>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
if you gotten this far you know to change your config overwrite cli url accordingly
If you need a real certificate install certbot
- mail server. setup as normal. you may install sendmail. change port 25 to 2525 and 587 to 1587 or however you wish set mail server to sendmail with pipe (-t). you cannot send mail but nc thinks he can solves mail setting warning
The Goal was to see if Nextxloud would run on Unrooted Android. The verdict is It can.
Tho not suitable for production due to lack of permissions / security A rooted phone could work well as a Nextcloud Server.
##VIDEO SAMPLES
10 minutes of software update / install. Installing LAMP on Android. Last 2 minutes setup mariadb
!VIDEO
Final Steps setup-nextcloud.php
!VIDEO
EDIT: added ssl / added imagick svg support