Cara menginstal Nextcloud 10 dengan Nginx di Debian 8

Posted on

Cara menginstal Nextcloud 10 dengan Nginx di Debian 8

Nextcloud adalah perangkat lunak sinkronisasi dan berbagi file open source. Ini adalah cabang dari ownCloud dan digunakan baik di tingkat individu maupun organisasi. Baru-baru ini dimulai oleh Frank Karlitschek, yang sebelumnya mendirikan proyek ownCloud. Nextcloud tidak hanya memiliki semua fitur dari ownCloud, tetapi juga berencana untuk menawarkan fitur-fitur baru dan inovatif.

Pada artikel ini, kami akan memperkenalkan cara menginstal Nextcloud versi terbaru di Debian 8 menggunakan Nginx (diucapkan EngineX), MariaDB dan PHP7.

1) Instal Nextcloud

File Nextcloud tersedia untuk diunduh dari server Nextcloud. Kami dapat mengunduh dan mengekstrak file zip untuk menyelesaikan instalasi.

# wget https://download.nextcloud.com/server/releases/nextcloud-10.0.1.zip
# unzip nextcloud-10.0.1.zip

Mari pindahkan direktori nextcloud ke /var/www dan ubah kepemilikannya menjadi www-data

# mkdir /var/www/

# mv nextcloud /var/www/

# rm -f nextcloud-10.0.1.zip

# chown -R www-data: /var/www/nextcloud

2) Instal Nginx

Nginx adalah open source dan salah satu server web paling populer di luar sana. Ia bekerja secara efisien, menskalakan dengan baik dengan perangkat keras minimal, dan responsif bahkan di bawah beban. Menginstalnya hanyalah tugas sederhana menjalankan perintah apt-get install.

# apt-get update

# apt-get install nginx -y

Kami dapat memeriksa versi nginx yang diinstal serta status untuk melihat apakah layanan dimulai atau tidak.

# nginx -v

#service nginx status

Kami juga dapat mengarahkan browser ke IP server dan melihat halaman selamat datang nginx:

Verifikasi Nginx-Web

3) Instal MariaDB

Instal server MariaDB dan perangkat lunak klien

# apt-get install mariadb-server-10.0 mariadb-client-10.0 -y

Selama konfigurasi DB, Anda akan diminta untuk menetapkan kata sandi untuk “administratif” pengguna root. Masukkan kata sandi dan keluar.

Konfirmasikan versi yang diinstal

# mysql --version
mysql Ver 15.1 Distrib 10.0.27-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Kita dapat membuat instalasi lebih aman dengan menjalankan instalasi MySQL yang aman. Ini direkomendasikan untuk server produksi.

# mysql_secure_installation

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):
OK, successfully used password, moving on...

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

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.

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
... Success!

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
... Success!

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
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

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

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

4) Buat database dan pengguna untuk Nextcloud

Masuk ke MariaDB menggunakan kata sandi yang telah ditetapkan sebelumnya saat mengonfigurasi DB.

# mysql -u root -p
Enter password:

Sekarang buat pengguna dan atur kata sandi untuk pengguna yang sama.

MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user nxtcloudadmin@localhost identified by 'admin123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on nextcloud.* to nxtcloudadmin@localhost identified by 'admin123'
-> ;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;

5) Aktifkan logging biner untuk MariaDB

Log biner mencakup perubahan data dan perubahan struktural yang dibuat di DB. Log ini akan berguna dalam mengulang dan memulihkan informasi. Untuk mengaktifkan ini, edit file /etc/mysql/my.cnf dan tambahkan baris berikut.

log-bin = /var/log/mysql/mariadb-bin
log-bin-index = /var/log/mysql/mariadb-bin.index
binlog_format = mixed

Setelah ini, muat ulang server mysql

# service mysql reload

6) Instal PHP7

Pertama, periksa apakah PHP sudah terinstal di sistem Anda. Untuk melakukan ini, jalankan perintah berikut

# dpkg --list |grep php

Jika tidak, cari versi Debian yang Anda miliki dan dapatkan paket yang relevan.

# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie

Pada contoh di atas, nama publikasinya adalah ‘jessie’. Jadi, mari tambahkan detail paket jessie ke daftar sumber daya, tambahkan kunci, lalu instal paket PHP yang diperlukan.

# echo 'deb http://packages.dotdeb.org jessie all' >> /etc/apt/sources.list
# echo 'deb-src http://packages.dotdeb.org jessie all' >> /etc/apt/sources.list

# cd /tmp
# wget https://www.dotdeb.org/dotdeb.gpg
# apt-key add dotdeb.gpg

apt-get update

root@debian-linoxide:~# apt install php7.0-common php7.0-fpm php7.0-cli php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php-pear php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring

7) Dapatkan sertifikat SSL gratis untuk domain Nextcloud Anda

Untuk mengaktifkan HTTPS di situs web apa pun, kita perlu mendapatkan sertifikat dari Certificate Authority (CA). “Let’s Encrypt” adalah CA yang menyediakan sertifikat SSL gratis untuk domain.

Untuk melakukan ini, pertama-tama kita perlu menginstal paket ‘git’ dan kemudian mengkloning repositori GitHub untuk mengunduh letsencrypt.

# apt-get install git bc -y

# git clone https://github.com/letsencrypt/letsencrypt

Sekarang, kita bisa mendapatkan sertifikat SSL dengan mengubah ke direktori “letsencrypt” dan mengeluarkan perintah:

# /letsencrypt-auto certonly --standalone --email <your-email-address> --agree-tos -d <your-node-name>
keluaran letsencrypt

8) Menyiapkan host virtual untuk domain Anda

Untuk membuat virtual host, buat file dengan nama domain Anda dengan ekstensi ‘.conf’ (misalnya nodenixbox.com.conf dalam kasus ini) di jalur /etc/nginx/sites-enabled dan tambahkan konten berikut.

Catatan: Anda perlu mengganti nama node (berwarna merah) dengan nama domain Anda dan mengubah jalur sertifikat ssl (berwarna biru) ke mana pun sertifikat ssl Anda berada.

upstream php-handler {
server unix:/run/php/php7.0-fpm.sock;
}

server {
listen 80;
server_name nodenixbox.com;
}

server {
listen 443 ssl;
server_name nodenixbox.com;

ssl_certificate /etc/letsencrypt/live/nodenixbox.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/nodenixbox.com/privkey.pem;

# Path to the root of your installation
root /var/www/nextcloud/;
# set max upload size
client_max_body_size 10G;
fastcgi_buffers 64 4K;

# Disable gzip to avoid the removal of the ETag header
gzip off;

# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;

index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;

rewrite ^/.well-known/carddav /remote.php/dav/ permanent;
rewrite ^/.well-known/caldav /remote.php/dav/ permanent;

# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}

location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}

location / {

rewrite ^/remote/(.*) /remote.php last;

rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ =404;
}

location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
}

# Adding the cache control header for js and css files
# Make sure it is BELOW the location ~ \.php(?:$|/) { block
location ~* \.(?:css|js)$ {
add_header Cache-Control "public, max-age=7200";
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
# Optional: Don't log access to assets
access_log off;
}

# Optional: Don't log access to other assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
access_log off;
}
}

9) Akses antarmuka web Nextcloud

Untuk membuat dan mengelola akun administratif Nextcloud Anda, arahkan browser Anda ke nama domain Anda. Dalam contoh ini, ini adalah “https://nodenixbox.com”. Ini akan membuka jendela seperti di bawah ini yang meminta Anda untuk membuat akun pengelola. Di bagian bawah halaman yang sama, Anda akan melihat kotak lain yang menanyakan pengguna database, kata sandi, dan nama database. Di sini masukkan detail akun yang Anda buat saat menginstal MariaDB dan tekan tombol “Finish Setup”.

BerikutnyaCloud-AccountCreation(1)(1)

Selamat! Sekarang Anda telah menyiapkan server Nextcloud Anda dan Anda dapat berbagi file menggunakannya.

Halaman cloud berikutnya

Hasil

Nextcloud adalah tempat yang aman bagi siapa saja, termasuk perusahaan, untuk menyimpan, berbagi, dan melindungi file atau data mereka. Ini juga dapat digunakan untuk berbagi kalender, kontak, komunikasi, dll. tanpa mengkhawatirkan keamanannya. Ini berfokus pada kebutuhan pengguna dan pelanggan dan mencoba menambahkan lebih banyak fitur ke dalamnya. Secara keseluruhan, ini adalah alat yang bagus untuk digunakan.



Source link

Leave a Reply

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