AWS S3-based enterprise network file sharing using Nextcloud

David Clinton
Dec 13, 2017 · 11 min read

Hardware prerequisites

Hardware and software requirements for both recommended and minimal Nextcloud installations

Building a LAMP server

# apt install apache2 mariadb-server libapache2-mod-php7.0 \
php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring \
php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip \
wget nano
 # apt install lamp-server^
# mysql_secure_installation 
MariaDB [(none)]> SET PASSWORD = PASSWORD(‘your-password’);
MariaDB [(none)]> update mysql.user set plugin = ‘mysql_native_password’ where User=’root’;
MariaDB [(none)]> FLUSH PRIVILEGES;

Apache configuration

# a2enmod rewrite
# a2enmod headers
Alias /nextcloud “/var/www/nextcloud/”<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
<VirtualHost *:443> <1>
ServerName bootstrap-it.com
DocumentRoot /var/www/nextcloud
ServerAlias bootstrap-it.com/nextcloud <2>
</VirtualHost>
Apache reads configuration files in /etc/apache2/sites-enabled/ and uses their settings to redirect requests
# ln -s /etc/apache2/sites-available/nextcloud.conf \
/etc/apache2/sites-enabled/nextcloud.conf

Downloading and unpacking Nextcloud

Links to Nextcloud download archives: either the .tar.bz2 or the .zip formats will work
$ wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.tar.bz2 
$ tar xjf nextcloud-12.0.0.tar.bz2
# cp -r nextcloud /var/www/ 
# chown -R www-data:www-data /var/www/nextcloud/
# systemctl restart apache2
# journalctl | tail
10.0.3.36/nextcloud
The main Nextcloud console, complete with sample folders and files — you can work with objects here just as you would using an OS file manager

Using AWS S3 as your primary Nextcloud storage

The list of currently available apps, including External storage support

Connect Nextcloud to an S3 bucket

$ aws s3 mb nextcloud32327
The External storages setup page for Amazon S3, showing a successful connection to my S3 bucket
$ aws s3 ls s3://nextcloud32327
testfile.pdf
$ aws s3 cp test.txt s3://nextcloud32327

David Clinton

Written by

Linux system admin and tech training content provider. Known to hang out at https://bootstrap-it.com.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade