Membuat Web Server di Ubuntu 22.04 (APACHE, MARIADB, PHP, PHPMYADMIN, WEBMIN, CERTBOT)

NOTE : UNTUK MEMUDAHKAN PROSES INSTALASI SILAHKAN GUNAKAN PUTTY UNTUK MASUK KE DALAM UBUNTU SERVER ANDA ATAU DAPAT MENGGUNAKAN REMOTE BY SSH

PuTTY svg logo on Behance
DOWNLOAD PUTTY KLIK

STEP 1 – Install Apache Web Server

Langkah pertama adalah silahkan update repository Ubuntu anda > Install > check status web server apache menggunakan perintah di bawah ini.

Ket : tanda $ tidak di masukkan dalam perintah.

$ sudo apt install update
$ sudo apt install apache2 -y
$ systemctl status apache2

Install software download manager wget & text editor nano

sudo apt install wget nano -y

STEP 2 – Install DBMS MariaDB v10.x

Update repository & install mariadb

sudo apt update
sudo apt install mariadb-server mariadb-client

Check Status Service MariaDB Server

systemctl status mysqld

Setting Password root MariaDB (Hardening)

sudo mariadb-secure-installation

*JALANKAN SECARA HATI-HATI

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
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):[enter]
OK, successfully used password, moving on...

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password:[masukkan password root database Mariadb] [enter]
Re-enter new password: [masukkan password root database Mariadb] [enter]
Password updated successfully!
Reloading privilege tables..
 ... Success!


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!




Test Login root DBMS MariaDB

mysql -u root -p

Jika berhasil login akan muncul seperti dibawah ini

firmanprtama@firmanpratama:~$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

STEP 3 – Install PHP Package


Silahkan Install PHP Package di bawah ini (Jika anda nanti akan menginstall WordPress Saja)

sudo apt install php libapache2-mod-php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y


Silahkan Install PHP Package di bawah ini (Jika anda nanti akan menginstall WordPress & Moodle)

sudo apt update
sudo apt install php libapache2-mod-php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-soap php-xmlrpc php-intl -y

Check versi php

php --version

Buat file info.php di dalam folder /var/www/html

sudo nano /var/www/html/info.php

Copy paste code php di bawah ini Lalu Save

<?php

// Menampilkan seluruh informasi
phpinfo();

// Untuk menampilkan modul php pada server
phpinfo(INFO_MODULES);

?>

Lalu buka Pada browser anda

http://ipaddress/info.php

Contoh http://192.168.6.127/info.php

STEP 4 – Instalasi PHPMyAdmin

Selanjutnya install PHPMyadmin

sudo apt update
sudo apt install php-mbstring php-zip php-gd php-json php-curl phpmyadmin

Pastikan web server apache diberikan tanda bintang (*) (dipilih) >lalu ok

silahkan setting password db phpmyadmin pada tahap di atas.

Selanjutnya Test login ke phpmyadmin

http://ipaddress/phpmyadmin

Contoh http://192.168.6.127/phpmyadmin

Jika Berhasil Login ke phpmyadmin Akan muncul menu seperti ini

STEP 5 – Install Webmin

Update Repository

sudo apt update

Sisipkan repository code webmin pada akhir baris file sources.list di folder /etc/apt/

sudo nano /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib

Caranya copy & paste pada baris paling bawah lalu save & exit

Save & Exit
CTRL + X
Enter

Lanjut ke terminal jalankan code berikut

sudo wget -q -O- http://www.webmin.com/jcameron-key.asc | sudo apt-key add
sudo apt update

Install Webmin

sudo apt install webmin

Check service status webmin menggunakan command di bawah ini

systemctl status webmin

jika benar akan muncul status active (running) seperti di bawah ini

Selanjutnya Test akses webmin Anda dengan cara buka pada browser https://IPADDRESS:Port10000 menggunakan login root user ubuntu.

contoh : https://192.168.6.127:10000/

Jika berhasil login ke webmin akan muncul tampilan seperti berikut.

Jika gagal login menggunakan user root silahkan jalan kan perintah di bawah ini untuk reset password root

sudo su
passwd root

STEP 6 – Install Certbot

Instalasi Certbot, Software ini digunakan untuk melakukan instalasi sertifikat SSL Let’s Encrypt.

Untuk menginstall gunakan perintah berikut

sudo apt install certbot python3-certbot-apache -y

STEP 7 – Additional Software

Langkah ini merupakan installasi software tambahan untuk mendukung operasional server

sudo apt install graphviz aspell ghostscript clamav nmap -y

Part 8 – Setting Firewall

Check Firewall

sudo ufw status

Buka Akses untuk ssh (22), http (Port 80/TCP), https (443/TCP), DBMS MariaDB (Port 3306/TCP), Webmin (Port 10000/TCP)

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 3306/tcp
sudo ufw allow 10000/tcp

  • Untuk open akses port MariaDB (3306/tcp) bersifat opsional jika diperlukan, jika tidak diperlukan untuk akses dari luar lebih baik ditutup / tidak ditambahkan pada pengecualian port yang dibuka pada firewall
  • Port Webmin (10000/tcp), Port SSH(22/tcp) dapat di custom misal (service ssh di ubah dari port 22 ke port 2201) atau (service webmin di ubah dari port 10000 ke port 12345) dengan memodifikasi file konfigurasi pada tiap-tiap servicenya.

Aktifkan Service Firewall

sudo ufw enable

Check Status Firewall

sudo ufw restart

Restart Status Firewall

sudo ufw status

Part 9 – Setting Time Zone

Setting Time Zone server (Perintah di bawah untuk server dengan konfigurasi waktu Indonesia/Jakarta) Silahkan sesuaikan untuk zona waktu lain

sudo timedatectl set-timezone Asia/Jakarta

Untuk mengecek zona waktu lain

timedatectl list-timezones

Untuk mengecek zona waktu saat ini pada server

timedatectl

Laporan Berisi

  1. Teori (jelaskan software apa saja yang digunakan dalam praktikum ini beserta fungsinya)
  2. Laporan Praktikum (Screenshoot & Penjelasan)
  3. Kesimpulan