GNU/Linux >> Belajar Linux >  >> Ubuntu

Cara Memasang Forum Flarum di Ubuntu 20.04

Flarum adalah aplikasi forum gratis, open-source dan generasi berikutnya yang membantu Anda membangun forum diskusi online Anda sendiri. Itu ditulis dalam PHP, sederhana, cepat dan mudah digunakan. Ini menyediakan arsitektur yang fleksibel, APT ekstensi yang kuat dan semua fitur yang Anda butuhkan untuk menjalankan komunitas yang sukses. Flarum terlihat dan terasa luar biasa. Antarmuka pengguna disederhanakan sehingga Anda dapat menghabiskan lebih sedikit waktu untuk mengklik dan lebih banyak waktu untuk berbicara.

Dalam tutorial ini, kami akan menjelaskan cara menginstal forum Flarum dengan Apache dan Let's Encrypt SSL di server Ubuntu 20.04.

Prasyarat

  • Server yang menjalankan Ubuntu 20.04.
  • Nama domain valid yang ditunjukkan dengan IP server Anda.
  • Sandi root dikonfigurasi untuk server.

Memulai

Pertama, selalu disarankan untuk memperbarui paket sistem Anda ke versi terbaru. Anda dapat memperbaruinya menggunakan perintah berikut:

apt-get update -y

Setelah semua paket diperbarui, Anda dapat melanjutkan ke langkah berikutnya.

Instal Server LAMP

Flarum ditulis dalam PHP, berjalan di web server dan menggunakan MySQL/MariaDB sebagai database backend. Jadi, Anda perlu menginstal tumpukan LAMP di sistem Anda. Anda dapat menginstalnya dengan perintah berikut:

apt-get install apache2 mariadb-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-mysql php7.4-gd php7.4-xml php7.4-curl php7.4-cli php7.4-zip php7.4-tokenizer wget unzip curl git -y

Setelah semua paket terinstal, edit file php.ini dan atur beberapa pengaturan:

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

Ubah baris berikut:

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 150M
max_execution_time = 450
date.timezone = Asia/Kolkata

Simpan dan tutup file setelah Anda selesai.

Buat Basis Data Flarum

Selanjutnya, Anda perlu membuat database dan pengguna untuk Flarum. Pertama, login ke shell MariaDB dengan perintah berikut:

mysql

Setelah login, buat database dan user dengan perintah berikut:

MariaDB [(none)]> CREATE DATABASE flarum;
MariaDB [(none)]> CREATE USER 'flarum'@'localhost' IDENTIFIED BY 'password';

Selanjutnya, berikan semua hak istimewa ke database flarum dengan perintah berikut:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarum.* TO 'flarum'@'localhost';

Selanjutnya, flush hak istimewa dan keluar dari MariaDB dengan perintah berikut:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.

Instal Komposer

Selanjutnya, Anda perlu menginstal Komposer di sistem Anda. Composer adalah manajer dependensi untuk PHP yang digunakan untuk menginstal semua dependensi yang diperlukan untuk proyek PHP.

Anda dapat menginstal Komposer dengan perintah berikut:

curl -s https://getcomposer.org/installer | php

Anda akan mendapatkan output berikut:

All settings correct for using Composer
Downloading...

Composer (version 1.10.10) successfully installed to: /root/composer.phar
Use it: php composer.phar

Selanjutnya, pindahkan binary Composer ke direktori /usr/local/bin/ dengan perintah berikut:

mv composer.phar /usr/local/bin/composer

Selanjutnya, verifikasi versi Composer yang diinstal dengan perintah berikut:

composer -V

Anda akan melihat output berikut:

Composer version 1.10.10 2020-08-03 11:35:19

Instal Flarum

Pertama, buat direktori untuk Flarum di dalam direktori root web Apache dengan perintah berikut:

mkdir /var/www/html/flarum

Selanjutnya ubah direktori menjadi flarum dan download Flarum versi terbaru menggunakan Composer seperti gambar di bawah ini:

cd /var/www/html/flarum
composer create-project flarum/flarum . --stability=beta

Selanjutnya, instal semua dependensi PHP menggunakan perintah berikut:

composer install

Setelah semua dependensi terinstal, ubah kepemilikan Flarum menjadi www-data dan berikan izin yang sesuai dengan perintah berikut:

chown -R www-data:www-data /var/www/html/flarum/
chmod -R 755 /var/www/html/flarum/

Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.

Konfigurasi Apache untuk Flarum

Selanjutnya, Anda perlu membuat file konfigurasi virtual host Apache untuk meng-host Flarum. Anda dapat membuatnya dengan perintah berikut:

nano /etc/apache2/sites-available/flarum.conf

Tambahkan baris berikut:

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /var/www/html/flarum/public
 ServerName flarum.linuxbuz.com
 DirectoryIndex index.php
 <Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
 </Directory>
 ErrorLog /var/log/apache2/flarum-error_log
 CustomLog /var/log/apache2/flarum-access_log common
</VirtualHost>

Simpan dan tutup file setelah Anda selesai. Kemudian, aktifkan host virtual Flarum dan modul penulisan ulang Apache dengan perintah berikut:

a2ensite flarum
a2enmod rewrite

Terakhir, restart layanan Apache untuk menerapkan perubahan:

systemctl restart apache2

Anda juga dapat memverifikasi status Apache menggunakan perintah berikut:

systemctl status apache2

Anda akan mendapatkan output berikut:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:57:11 UTC; 2min 44s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 27164 (apache2)
      Tasks: 6 (limit: 2353)
     Memory: 12.3M
     CGroup: /system.slice/apache2.service
             ??27164 /usr/sbin/apache2 -k start
             ??27165 /usr/sbin/apache2 -k start
             ??27166 /usr/sbin/apache2 -k start
             ??27167 /usr/sbin/apache2 -k start
             ??27168 /usr/sbin/apache2 -k start
             ??27169 /usr/sbin/apache2 -k start

Aug 23 09:57:11 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...

Amankan Flarum dengan Let's Encrypt SSL

Selalu disarankan untuk mengamankan situs web Anda dengan Let's Encrypt SSL gratis. Pertama, instal klien Certbot Let's Encrypt dengan perintah berikut:

apt-get install python3-certbot-apache -y

Setelah terinstal, jalankan perintah berikut untuk menginstal Let's Encrypt SSL untuk situs web Flarum Anda:

certbot --apache -d flarum.linuxbuz.com

Anda akan diminta untuk memberikan alamat email yang valid dan menerima persyaratan layanan seperti yang ditunjukkan di bawah ini:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for flarum.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flarum-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flarum-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flarum-le-ssl.conf

Selanjutnya, pilih apakah akan mengarahkan lalu lintas HTTP ke HTTPS seperti yang ditunjukkan di bawah ini:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Ketik 2 dan tekan Enter untuk menginstal sertifikat SSL untuk situs web Anda. Setelah instalasi selesai, Anda akan mendapatkan output berikut:

Redirecting vhost in /etc/apache2/sites-enabled/flarum.conf to ssl vhost in /etc/apache2/sites-available/flarum-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://flarum.linuxbuz.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/flarum.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/flarum.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-11-21. 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"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - 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

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Akses Forum Flarum

Pada titik ini, Flarum diinstal, dikonfigurasi, dan diamankan dengan Let's Encrypt SSL. Sekarang, buka browser web Anda dan akses Flarum menggunakan URL https://flarum.linuxbuz.com. Anda akan diarahkan ke halaman berikut:

Berikan nama forum Anda, nama database, nama pengguna, kata sandi, nama pengguna admin, kata sandi, alamat email dan klik tombol Instal Flarum tombol. Setelah instalasi selesai, Anda akan diarahkan ke dashboard Flarum seperti yang ditunjukkan di bawah ini:

Kesimpulan

Selamat! Anda telah berhasil menginstal forum Flarum dengan Apache dan Let's Encrypt SSL di server Ubuntu 20.04. Anda sekarang dapat meng-host forum komunitas Anda sendiri dengan mudah dengan Flarum. Jangan ragu untuk bertanya kepada saya jika Anda memiliki pertanyaan.


Ubuntu
  1. Cara Menginstal Logstash di Ubuntu 18.04

  2. Cara Menginstal XWiki di Ubuntu 20.04

  3. Cara Menginstal MongoDB di Ubuntu 20.04

  1. Cara Menginstal R di Ubuntu 20.04

  2. Cara Menginstal phpBB di Ubuntu 20.04

  3. Cara Menginstal R di Ubuntu 18.04

  1. Cara Menginstal Syncthing di Ubuntu 20.04

  2. Cara Menginstal Usermin di Ubuntu 20.04

  3. Cara Menginstal Podman di Ubuntu 20.04