Install Nextcloud Ubuntu 16.04 LTS dengan Apache2

by | Mar 12, 2021 | Blog, FOSS, Linux | 0 comments

( Nextcloud Ubuntu 16.04 LTS Server )
Owncloud serta Nextcloud merupakan 2 layanan penyimpanan cloud yang dihosting sendiri. Tetapi, cuma Nextcloud yang betul- betul open source. Nextcloud merupakan cabang dari Owncloud, bila Kamu mencari layanan penyimpanan cloud yang di- host sendiri 100% open source, maka Nextcloud mesti pilihanmu.

Postingan ini menampilkan kepada kamu metode menginstal Nextcloud Ubuntu 16.04 LTS dengan sokongan Apache2, MariaDB, PHP serta Lets Encrypt SSL. Nextcloud merupakan cabang dari Owncloud. Semacam DropBox serta layanan penyimpanan cloud yang lain, Nextcloud serta Owncloud sediakan peranan yang yang mirip serta tidak serupa yang lain, keduanya free untuk digunakan.

Keduanya merupakan piranti lunak sumber terbuka yang mengaktifkan layanan awan individu di server pengguna sendiri. Owncloud serta Nextcloud merupakan sinkronisasi file yang dihosting sendiri serta berbagi platform aplikasi dan dengan mereka kamu bisa mengakses & menyinkronkan file, kontak, serta informasi di segala fitur kamu.

Di lingkungan dikala ini, Nextcloud kerap diinstal dengan enkripsi SSL/ TLS sehingga seluruh kemudian lintas ke serta dari platform dilindungi lewat HTTPS. Ini merupakan metode terbaik buat mengamankan informasi Kamu di Nextcloud.

Bimbingan pendek ini menampilkan kepada siswa serta pengguna baru langkah- langkah buat menginstal serta mengkonfigurasi Nextcloud Ubuntu 16.04 LTS Server dilingkungan mereka sendiri.

Kita mulai menginstal Nextcloud, simak langkah- langkah dibawah ini:

Update Repository

Karena repository dari indonesia tidak bisa kalian harus mengganti repositorinya ke US.

Repo : Link Repo

Ketikkan perintah berikut untuk mengganti repository.

#hapus repository default indo
sudo rm /etc/apt/sources.list

#buat file repositori baru
sudo nano /etc/apt/sources.list
#Isi dengan kode/repository berikut

#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

#Simpan hasil tersebut.
Ctrl + X > Y > Enter

#Ketikkan perintah untuk update repository
sudo apt update

Langkah 1: Instal Apache2

Nextcloud memerlukan server website untuk berperan dan server website sangat terkenal yang digunakan dikala ini merupakan Apache2. Jadi, buka dan instal Apache2 di Ubuntu dengan melaksanakan perintah di bawah ini:

sudo apt install apache2

Sesudah menginstal Apache2, jalankan perintah di bawah ini buat menonaktifkan catatan direktori.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

Berikutnya, jalankan perintah di bawah ini buat berhenti, mengawali, serta mengaktifkan layanan Apache2 untuk senantiasa mengawali dengan boot server.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Langkah 2: Instal MariaDB

Nextcloud pula memerlukan server database buat berperan, serta server database MariaDB merupakan tempat yang pas untuk mengawali. Cara menginstalnya, jalankan perintah di bawah ini.

sudo apt-get install mariadb-server mariadb-client

Sehabis menginstal, perintah di bawah ini bisa digunakan untuk menghentikan, mengawali, serta mengaktifkan layanan MariaDB untuk senantiasa mengawali disaat server melangsungkan booting. Sehabis itu, jalankan perintah di bawah ini buat mengamankan server MariaDB.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Setelah itu, jalankan perintah di bawah ini untuk mengamankan server MariaDB.

sudo mysql_secure_installation

Disaat diminta, jawab persoalan di bawah dengan mencontohi panduan.

Enter current password for root (enter for none): Just press the Enter
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Mulai ulang server MariaDB.

sudo systemctl restart mysql.service

Langkah 3: Instal PHP 7. 4 dan Modul Terkait

PHP 7. 4 tidak ada di repositori default Ubuntu, cara menginstalnya, kamu wajib mendapatkannya dari repositori pihak ketiga.

Jalankan perintah di bawah ini untuk menambahkan repositori pihak ketiga di bawah ini untuk tingkatkan ke PHP 7. 4.

sudo apt-get install software-properties-common

# Repository Ondrej/php untuk sekarang tidak memberikan dukungan terhadap Ubuntu Xenial
sudo add-apt-repository ppa:ondrej/php

# Gunakan repository ini untuk fix php7.4
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp

Setelah itu perbarui serta tingkatkan ke PHP 7. 4.

sudo apt update

Jalankan perintah di bawah ini untuk menginstal PHP 7. 4 serta modul terpaut.

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-common libapache2-mod-php7.4 php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-apcu php7.4-smbclient php7.4-ldap php7.4-redis php7.4-gd php7.4-xml php7.4-intl php7.4-json php7.4-imagick php7.4-mysql php7.4-cli php7.4-ldap php7.4-zip php7.4-curl

Sehabis menginstal PHP 7. 4, jalankan perintah di bawah ini buat membuka file default PHP- FPM.

sudo nano /etc/php/7.4/apache2/php.ini

Setelah itu buat pergantian baris berikut di bawah ini pada file dan simpan.

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 64M
max_execution_time = 360
date.timezone = Asia/Jakarta

Langkah 4: Buat Database Nextcloud

Saat ini sesudah Kamu menginstal seluruh paket yang dibutuhkan, lanjutkan di bawah ini untuk mulai mengkonfigurasi server. mula- mula jalankan perintah di bawah ini untuk membuat database Nextcloud.

Jalankan perintah di bawah ini untuk masuk ke server database. Dikala dituntut kata sandi, ketikkan kata sandi root yang Kamu buat di atas.

sudo mysql -u root -p

Setelah itu buat database bernama nextcloud.

CREATE DATABASE nextcloud;

Buat pengguna database bernama nextclouduser dengan kata sandi baru.

CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'new_password_here';

Setelah itu bagikan pengguna akses penuh ke database.

GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Terakhir, simpan pergantian Kalian dan keluar.

FLUSH PRIVILEGES;
EXIT;

Langkah 5: Download Rilis Terkini Nextcloud

Berikutnya, kunjungi web Nextcloud buat mengunduh salinan free Kamu. Edisi komunitas merupakan yang mau kamu download.

Sehabis mengunduh, jalankan perintah di bawah ini untuk mengekstrak file unduhan ke direktori root Apache2.

cd /tmp && wget --no-check-certificate https://download.nextcloud.com/server/releases/nextcloud-19.0.5.zip
unzip nextcloud-19.0.5.zip
sudo mv nextcloud /var/www/html/nextcloud/

Setelah itu jalankan perintah di bawah ini untuk mengendalikan izin yang benar untuk Nextcloud berperan.

sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

Langkah 6: Konfigurasi Apache2

Terakhir, konfigurasikan file konfigurasi web Apahce2 untuk NextCloud. File ini bakal mengontrol bagaimana pengguna mengakses konten NextCloud. Jalankan perintah di bawah ini untuk membuat file konfigurasi baru bernama nextcloud.conf.

sudo nano /etc/apache2/sites-available/nextcloud.conf

Setelah itu salin serta tempel konten di bawah ini ke dalam file dan simpan. Ubah baris yang disorot dengan nama domain kamu sendiri serta posisi pangkal direktori.

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud/
     ServerName example.com
     ServerAlias www.example.com
  
     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Simpan file dan keluar.

Langkah 7: Aktifkan Modul Nextcloud serta Tulis Ulang

Sesudah mengkonfigurasi VirtualHost di atas, aktifkan dengan melaksanakan perintah di bawah ini.

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

#nonaktifkan semua versi php kecuali php7.4
#aktifkan php versi 7.4
a2enmod php7.4

Langkah 8: Mulai ulang Apache2

Untuk muat seluruh pengaturan di atas, mulai ulang Apache2 dengan melaksanakan perintah di bawah ini.

sudo systemctl restart apache2.service

LANGKAH 9: Setup Let’s Encrypt( Sertifikat SSL ) Apache2

Kini sesudah konfigurasi Nextcloud berakhir, lanjutkan dibawah ini untuk menginstal serta mengkonfigurasi Lets Encrypt. Lets Encrypt kini sediakan modul Apache2 untuk mengotomatiskan proses ini. Untuk menginstal klien/ modul di Ubuntu, jalankan perintah dibawah ini.

sudo apt-get install python-certbot-apache

Sehabis itu jalankan perintah dibawah ini untuk memperoleh sertifikat Lets Encrypt SSL/ TLS free buat web kamu.

sudo certbot --apache -m admin@example.com -d example.com -d www.example.com

Sehabis melaksanakan perintah diatas, Kamu hendak dituntut untuk menerima persyaratan lisensi. Bila seluruhnya dicentang, klien wajib secara otomatis menginstal sertifikat SSL/ TLS free serta mengkonfigurasi web Apache2 untuk memakai sertifikat tersebut.

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

Seleksi Ya( Y) untuk memberikan alamat email kamu.

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y

Ini merupakan betapa mudahnya memperoleh sertifikat SSL/ TLS free buat web website yang didukung web server kamu.

Pilih opsi 2 untuk alihkan seluruh lalu lintas lewat HTTPS. Ini berguna!

Sehabis itu, klien SSL wajib memasang sertifikat serta mengonfigurasi web website Kamu untuk alihkan seluruh lalu lintas lewat HTTPS.

Congratulations! You have successfully enabled https://example.com and
https://www.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.example.com
-------------------------------------------------------------------------------

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2018-02-24. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Blok kode yang disorot mesti ditambahkan ke file konfigurasi web Apache2 Nextcloud kamu secara otomatis oleh Lets Encrypt certbot. Web Nextcloud kamu siap digunakan lewat HTTPS.

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud/
     ServerName example.com
     ServerAlias www.example.com
  
     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

File konfigurasi baru untuk domain pula wajib terbuat dengan nama /etc/apache2/sites- available/ nextcloud-ssl. conf. Ini merupakan file konfigurasi modul Apache2 SSL serta wajib berisi definisi sertifikat yang ditetapkan didalamnya.

<IfModule mod_ssl.c>
<VirtualHost *:443>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud/
     ServerName example.com
     ServerAlias www.example.com
  
     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>
</IfModule>

Setelah itu buka browser kamu serta telusuri nama domain server diiringi dengan install. Kamu wajib memandang wizard pengaturan Nextcloud buat menuntaskan. Harap simak wizard dengan hati- hati.

Selamat! Kamu sudah sukses menginstal Nextcloud Ubuntu 16.04 LTS dengan sokongan Lets Encrypt.

Untuk mempersiapkan proses buat memperbarui sertifikat secara otomatis, tambahkan tugas cron buat melaksanakan proses perpanjangan.

sudo crontab -e

Setelah itu tambahkan baris dibawah serta simpan.

0 1 * * * /usr/bin/certbot renew & > /dev/null

Tugas cron hendak berupaya memperbarui 30 hari saat sebelum kedaluwarsa.

Selamat!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Cari

Kategori Artikel