Install Nextcloud di Ubuntu 20.04 dengan web server Apache

Kali ini saya akan menginstall Nextcloud di server lokal. Dengan Lokasi penginstalan di /var/ww/html (Default DocumentRoot Apache)

Install dan konfigurasi pendukung

Install apache

sudo apt install apache2

Install mariaDB

sudo apt install mariadb-server

Install PHP

sudo apt install php

Install modul/ekstensi PHP

sudo apt install apache2 php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip libapache2-mod-php php-bz2 php-imap php-apcu php-memcached php-redis

Install zip dan unzip

sudo apt install zip unzip

Restart apache

systemctl restart apche2

Pengujian

Buat file PHP info untuk mengetahui PHP sudah berjalan atau belum

nano /var/www/html/info.php

Masukkan ini kedalamnya

<?php phpinfo( ); ?>

Akses menggunakan web browser

http://IP-address/
http://IP-address/info.php

Pastikan muncul halaman default apache dan informasi PHP

Konfigurasi apache

Edit file /etc/apache2/sites-available/000-default.conf

nano /etc/apache2/sites-available/000-default.conf

Tambahkan ini kedalamnya sebelum tag penutup </Virtualhost> atau dibawah DocumentRoot

<Directory /var/www/html/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/html/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud

</Directory>

Database

Jalankan secure installation

mysql_secure_installation

Jika muncul pertanyaan

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

Tekan enter

Jika muncul pertanyaan

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y

Jawab Y enter, lalu masukkan password baru

Jika muncul pertanyaan

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y

Jawab Y

Jika muncul pertanyaan

Remove anonymous users? [Y/n] y

Jawab Y

Jika muncul pertanyaan

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y

Jawab Y

Jika muncul pertanyaan

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y

Jawab Y

Jika muncul pertanyaan

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y

Jawab Y

Konfigurasi database

Masuk kedalam mysql

mysql -u root -pkatasandi

Membuat database nextcloud

create database nextcloud;

Membuat user untuk mengelola database nextcloud

CREATE USER 'namauser'@'localhost' IDENTIFIED BY 'katasandi';

Mengizinkan user untuk mengelola database nextcloud

GRANT ALL PRIVILEGES ON nextcloud.* TO 'namauser'@'localhost';
FLUSH PRIVILEGES;

Install dan konfigurasi Nextcloud

Download nextcloud

Kunjungi https://nextcloud.com/install/#instructions-server, lalu klik Download Nextcloud.

Atau Download menggunakan wget dengan cara klik kanan pada tombol Download Nextcloud lalu salin link

wget <link>

Ekstrak Nextcloud

unzip nextcloud-version.xxx.zip

Pindahkan direktori hasil ekstrak ke /var/www/html/

mv nextcloud /var/ww/html/

Ubah kepemilikan dan izin direktori nextcloud

chown -R www-data:www-data /var/www/html/nextcloud/
chmod -R 775 /var/www/html/nextcloud/

Aktifkan semua konfigurasi dan modul yang diperlukan

sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Restart Apache

sudo systemctl restart apache2

Mengakses Nextcloud

http://IP-address/nextcloud

Buat akun admin baru

Jika ingin tentukan lokasi penyimpanan data nextcloud

Masukkan user, password, dan nama database.

Jika ingin merubah port tambahkan nomer port yang di inginkan di belakang localhost:

Jika sudah Klik Finish Setup