• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Jaranguda

Belajar Mengajar

  • Home
  • Sponsor/Jasa
  • Tentang

Install Nextcloud 18.0.3 Centos 8 dan Letsencrypt SSL

Last Updated on 24 March 2020 By tommy Leave a Comment

Nextcloud adalah file storage yang banyak digunakan seantro internet. Instalasi nextcloud untuk pemula cukup membingungkan karena harus mengkoneksikan beberapa services, seperti PHP, MySQL, Web Server. Disini anda akan dipandu cara install Nextcloud 18 di Centos 8 tahap demi tahap.

Update system

yum update;yum upgrade -y

Install dependency

yum install git unzip socat python3-policycoreutils -y

Install PHP

yum install php php-cli php-gd php-xmlrpc php-fpm php-curl php-intl php-mysqlnd php-json php-zip php-xml php-mbstring php-bcmath php-process -y

Update config PHP

Beberapa perubahan disini, zona waktu menjadi Asia/Jakarta (GMT +7), maksimum upload file 100MB, timeout post 300 detik. Memory limit yang direkomendasikan Nextcloud minimal 512 MB.

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = Asia\/Jakarta/g' /etc/php.ini
sed -i 's/post_max_size \=\ 8M/post_max_size \=\ 100M/g' /etc/php.ini
sed -i 's/upload_max_filesize \=\ 2M/upload_max_filesize \=\ 100M/g' /etc/php.ini
sed -i 's/memory_limit \=\ 128M/memory_limit \=\ 512M/g' /etc/php.ini
sed -i 's/max_execution_time \=\ 30/max_execution_time \=\ 300/g' /etc/php.ini
sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/user = nginx/g' /etc/php-fpm.d/www.conf

restart PHP-FPM

systemctl restart php-fpm

Ubah permission session PHP

chown nginx:nginx -R  /var/lib/php

Allow Port 80 (http) dan Port 443 (https)

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https

Install Letsencrypt SSL

Install acme.sh

mkdir ~/src
cd ~/src
wget https://github.com/acmesh-official/acme.sh/archive/2.8.5.zip
unzip 2.8.5.zip
cd ~/src/acme.sh-2.8.5
bash acme.sh install
source ~/.bashrc

Generate SSL untuk domain nextcloud.jaranguda.com

acme.sh --issue -d nextcloud.jaranguda.com --standalone

Tunggu beberapa saat sampai SSL selesai di generate

[Tue Mar 24 10:06:20 UTC 2020] Your cert is in  /root/.acme.sh/nextcloud.jaranguda.com/nextcloud.jaranguda.com.cer 
[Tue Mar 24 10:06:20 UTC 2020] Your cert key is in  /root/.acme.sh/nextcloud.jaranguda.com/nextcloud.jaranguda.com.key 
[Tue Mar 24 10:06:20 UTC 2020] The intermediate CA cert is in  /root/.acme.sh/nextcloud.jaranguda.com/ca.cer 
[Tue Mar 24 10:06:20 UTC 2020] And the full chain certs is there:  /root/.acme.sh/nextcloud.jaranguda.com/fullchain.cer

Install MariaDB

yum install mariadb-server

Jalankan mariadb

systemctl start mariadb

Login sebagai root mysql dengan menjalankan mysql di terminal
Buat user dan database untuk nextcloud

CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO "nextcloud"@"localhost" IDENTIFIED BY "jkNEj4KoUxs3TXWsRmzp";

Install Nginx

Tambahkan repository nginx, di repository Centos 8 versi nginx 1.14

echo '
[nginx]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
' > /etc/yum.repos.d/nginx.repo;

install nginx

yum install nginx -y

Update nginx.conf

cat >/etc/nginx/nginx.conf <<EOL
user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log warn;
pid /run/nginx.pid;
worker_rlimit_nofile 100000;
events {
    worker_connections  10000;
    use epoll;
    multi_accept on;
}
 
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent"';
    sendfile        on;
    tcp_nopush on;
    tcp_nodelay on;
    send_timeout 5;
    client_body_timeout 20;
    keepalive_timeout 40;
    server_tokens off;
    client_max_body_size 120M;
 
    gzip on;
    gzip_min_length 10240;
    gzip_comp_level 1;
    gzip_vary on;
    gzip_disable msie6;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types
        text/css
        text/javascript
        text/xml
        text/plain
        text/x-component
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        application/atom+xml
        font/truetype
        font/opentype
        application/vnd.ms-fontobject
        image/svg+xml;
 
    include /etc/nginx/sites/*.conf;
}
EOL

Buat folder untuk server block (vhost) nginx

mkdir -p /etc/nginx/sites/

Copy file SSL

mkdir /etc/nginx/ssl
cp -r /root/.acme.sh/nextcloud.jaranguda.com /etc/nginx/ssl/
# ubah permissionnya agar bisa diakses user nginx
chown nginx:nginx -R /etc/nginx/ssl

ganti nextcloud.jaranguda.com dengan nama domain anda.

Buat satu file konfig /etc/nginx/sites/nextcloud.jaranguda.com.conf, copy konfigurasi dibawah ini. Ubah domain nextcloud.jaranguda.com menjadi domain anda.

upstream php-handler {
    server unix:/run/php-fpm/www.sock;
}
 
server {
    listen 80;
    server_name nextcloud.jaranguda.com;
    # enforce https
    return 301 https://$server_name:443$request_uri;
}
 
server {
    listen 443 ssl http2;
    server_name nextcloud.jaranguda.com;
    ssl_certificate /root/.acme.sh/nextcloud.jaranguda.com/fullchain.cer;    
    ssl_certificate_key /root/.acme.sh/nextcloud.jaranguda.com/nextcloud.jaranguda.com.key;
 
    add_header Referrer-Policy "no-referrer" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Download-Options "noopen" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Permitted-Cross-Domain-Policies "none" always;
    add_header X-Robots-Tag "none" always;
    add_header X-XSS-Protection "1; mode=block" always;
 
    root /var/www/nextcloud;
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    # 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;
 
    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
 
    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
 
    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
 
    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
 
    location / {
        rewrite ^ /index.php;
    }
 
    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }
 
    location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
        set $path_info $fastcgi_path_info;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;
        # Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
 
    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }
 
    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;
        access_log off;
    }
 
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

Jalankan nginx

systemctl restart nginx

Install Nextcloud

Download nextcloud 18.0.3

cd /var/www/
wget https://download.nextcloud.com/server/releases/nextcloud-18.0.3.zip
unzip nextcloud-18.0.3.zip

Ubah permission /var/www/nextcloud agar bisa dibaca user nginx

chown nginx:nginx -R /var/www/nextcloud

Install Nexcloud dari CLI

cd /var/www/nextcloud/
sudo -u www-data php occ maintenance:install --database "mysql" --database-name "nextcloud"  --database-user "nextcloud" --database-pass "jkNEj4KoUxs3TXWsRmzp" --admin-user "jaranguda" --admin-pass "jaranguda123"

set trusted domain nextcloud menjadi nextcloud.jaranguda.com

sudo -u nginx php occ config:system:set trusted_domains 1 --value=nextcloud.jaranguda.com

Jalankan MariaDB NGINX PHP FPM waktu booting

systemctl enable nginx
systemctl enable php-fpm
systemctl enable mariadb

Setting Selinux

Jalankan perintah berikut di terminal, agar php fpm bisa tulis/baca ke folder didalam nextcloud

semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/nextcloud/data(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/nextcloud/config(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/nextcloud/apps(/.*)?'
 
restorecon -Rv '/var/www/nextcloud/'

Tulisan menarik lainnya

  • Install Nextcloud di Debian 8

    Tutorial kali ini adalah cara untuk menginstall Nextcloud di Debian 8, buat yang belum tau…

  • Install fail2ban di CentOS 7

    Untuk mengatasi brute-force akun SSH di CentOS kita menggunakan fail2ban untuk memblokir ip-ip yang mencoba…

  • Cara Install SSL di Mikrotik 6.29.1

    1. Generate Certificate Login lewat SSH, jalankan perintah /certificate add name=MikrotikJaranguda common-name=jaranguda.jrd key-size=2048 country=ID state=Jakarta…

  • Install Unbound 1.6.0 Centos 7 Debian 9

    Unbound salah satu DNS resolver yang bisa digunakan dan sangat mudah dalam konfigurasinya. Install Unbound…

Filed Under: Linux

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Pencarian

Tanya Jawab tentang DevOps SRE CPE, gabung di https://t.me/devopsindonesia

Terbaru

  • Solusi helm Upgrade Failed
  • macOS package is untrusted
  • Cara Mengganti Port Screen Sharing macOS
  • Cara Menonaktifkan Pager di macOS
  • Cara Mengupdate Nama Apple silicon-as-a-Service Scaleway

Komentar

  • Beritalogi on Cara Redirect Domain di Cloudflare
  • Putu on Cara Setting TP-LINK EN020-F5 Sebagai Range Extender
  • Budi on Solusi Simple Queue Mikrotik Tidak Berjalan
  • mazda on Tutorial Lengkap Install Mail Server Postfix Dovecot MariaDB di CentOS 7
  • adi on Menggunakan Mikrotik Sebagai SSH Client

Tulisan Populer

  • Password Router Huawei HG8245H5 Indihome 1.2m views
  • Password Terbaru ZTE F609 Indihome 785k views
  • Password Superadmin Huawei HG8245A 322.8k views
  • Cara Setting Manual Modem GPON ZTE F609 Indihome 273.9k views
  • Cara Setting Wireless ZTE F609 Indihome 258.3k views
  • Mengaktifkan Port LAN di Huawei HG8245 Indihome 170.7k views
  • Akses UseeTV Indihome via Wireless ZTE F609 157.1k views
  • Kemana Menghilangnya Saldo BCA 50 ribu 156.2k views
  • Cara Reset Password ZTE F609 Indihome 147.9k views
  • Cara Setting DHCP Server Modem/Router ZTE F609 114.3k views

Kategori

  • Delphi
  • dll
  • Gambas
  • Internet
  • Java
  • Lazarus
  • Linux
  • PHP
  • Review
  • Teknologi

Sponsor

kadal.id
carakami.com
kuotabisa.com
Untuk jadi sponsor, hubungi kita lewat halaman sponsor
© 2021. Jaranguda
  • Linux
  • PHP
  • Internet
  • Teknologi
  • Delphi
  • Gambas
  • Java