Cara Install Apache Web Server Debian 12

Dibuat: 18 Feb 2026 00:08
Instal instance server Debian 12 di Vultr.
Buat record A domain yang mengarah ke alamat IP publik instance tersebut . Misalnya, app.example.com.
Akses server menggunakan SSH sebagai pengguna non-root dengan hak akses sudo.
Perbarui server .
Instal Apache
Apache tersedia di repositori paket default pada Ubuntu 24.04 dengan informasi paket terbaru. Ikuti langkah-langkah di bawah ini untuk menginstal Apache menggunakan manajer paket APT di server Anda.

Perbarui indeks paket server.

menghibur

Menyalin
$ sudo apt update

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Instal Apache.

menghibur

Menyalin
$ sudo apt install apache2 -y

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Lihat versi PHP yang terpasang di server Anda.

menghibur

Menyalin
$ apachectl -v

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Your output should be similar to the one below.

Server version: Apache/2.4.58 (Ubuntu)
Server built: 2024-07-17T18:55:23
Allow the HTTP port 80 through the default firewall configuration.

console

Copy
$ sudo ufw allow 80

Explain Code
BETA
Powered by Vultr Agent
Reload the firewall to apply changes.
console
Copy
$ sudo ufw reload

Explain Code
BETA
Powered by Vultr Agent
Start the Apache web server.

console

Copy
$ sudo systemctl start apache2

Explain Code
BETA
Powered by Vultr Agent
Visit your server IP address using a web browser such as Chrome.

http://SERVER-IP
Verify that Apache delivers the default virtual host web application page in your browser.

Halaman Selamat Datang Default Apache

Manage the Apache System Service
Apache uses the apache system service to manage the application processes and runtime on your server. Follow the steps below to enable the Apache web server to automatically start at boot time, and manage the system service processes.

Enable Apache to automatically start at system boot.

console

Copy
$ sudo systemctl enable apache2

Explain Code
BETA
Powered by Vultr Agent
Start the Apache web server.

console

Copy
$ sudo systemctl start apache2

Explain Code
BETA
Powered by Vultr Agent
View the Apache service status and verify that it's running.

console

Copy
$ sudo systemctl status apache2

Explain Code
BETA
Powered by Vultr Agent
Output:

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
Active: active (running) since Tue 2024-07-09 09:00:46 UTC; 45s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 2019 (apache2)
Tasks: 55 (limit: 1091)
Memory: 9.7M
CPU: 36ms
CGroup: /system.slice/apache2.service
├─2019 /usr/sbin/apache2 -k start
├─2021 /usr/sbin/apache2 -k start
└─2022 /usr/sbin/apache2 -k start
Stop the Apache service.

console

Copy
$ sudo systemctl stop apache2

Explain Code
BETA
Powered by Vultr Agent
Restart the Apache service.

console

Copy
$ sudo systemctl restart apache2

Explain Code
BETA
Powered by Vultr Agent
Reload the Apache web server configuration to apply configuration changes without affecting the existing connections.

console

Copy
$ sudo systemctl reload apache2

Explain Code
BETA
Powered by Vultr Agent
Create a new Apache Virtual Host
Apache virtual host profiles enable the web server to deliver web applications with specific configurations and file types. The /etc/apache2/sites-available directory contains Apache virtual host configuration files that define specific addresses or domains to serve web applications on your server. Follow the steps below to create a new Apache virtual host to serve sample web application files using the example domain app.example.com.

Disable the default Apache virtual host configuration.

console

Copy
$ sudo a2dissite 000-default.conf

Explain Code
BETA
Powered by Vultr Agent
Create a new Apache virtual host configuration. For example, app.example.com.conf.

console

Copy
$ sudo nano /etc/apache2/sites-available/app.example.com.conf

Explain Code
BETA
Powered by Vultr Agent
Add the following contents to the file. Replace app.example.com with your actual domain.

apacheconf

Copy
<VirtualHost *:80>

ServerAdmin email@app.example.com
ServerName app.example.com
ServerAlias app.example.com

DocumentRoot /var/www/app.example.com
DirectoryIndex index.php index.html

ErrorLog ${APACHE_LOG_DIR}/app.example.com-error.log
CustomLog ${APACHE_LOG_DIR}/app.example.com-access.log combined

</VirtualHost>

Explain Code
BETA
Powered by Vultr Agent
Save and close the file.

The above configuration creates a new Apache virtual host that listens for connection requests on the HTTP port 80 using the domain app.example.com to deliver web application files from the web root directory /var/www/app.example.com.

Test the Apache configuration for errors.

console

Copy
$ sudo apache2ctl configtest

Explain Code
BETA
Powered by Vultr Agent
Output:

Syntax OK
Enable the Apache virtual host configuration.

console

Copy
$ sudo a2ensite app.example.com

Explain Code
BETA
Powered by Vultr Agent
Create the virtual host's web root directory /var/www/app.example.com.

console

Copy
$ sudo mkdir /var/www/app.example.com

Explain Code
BETA
Powered by Vultr Agent
Grant the Apache user www ownership privileges to the web root directory.

console

Copy
$ sudo chown -R www:www /var/www/app.example.com

Explain Code
BETA
Powered by Vultr Agent
Change the directory permissions to 755 to grant the Apache user full privileges to all available files.

console

Copy
$ sudo chmod -R 755 /var/www/app.example.com

Explain Code
BETA
Powered by Vultr Agent
The above 755 permission mode sets the following privileges on the directory and all files:

7: Read, write and execute permissions to the www user.
5: Read and execute permissions to the www user group.
5: Read and execute permissions to other system users.
Create a new sample HTML application file index.html in the virtual host's web root directory.

console

Copy
$ sudo nano /var/www/app.example.com/index.html

Explain Code
BETA
Powered by Vultr Agent
Add the following contents to the file.

html

Copy
<!DOCTYPE html>
<html lang="en">
<head>
<title>Greetings from Vultr</title>
</head>
<body>
<h1>Greetings from Vultr</h1>
</body>
</html>

Explain Code
BETA
Powered by Vultr Agent
Save and close the file.

The above HTML application displays a Greetings from Vultr message when accessed in a web browser.

Restart the Apache service to apply your configuration changes.

console

Copy
$ sudo systemctl restart apache2

Explain Code
BETA
Powered by Vultr Agent
Access your domain in a web browser window and verify that Apache serves your index.html web application.

http://app.example.com
Uji Host Virtual

Secure the Apache Web Server
Apache mendengarkan permintaan koneksi menggunakan domain Anda pada port HTTP default 80menggunakan konfigurasi virtual host Anda. Koneksi HTTP tidak aman dan secara default tidak menyertakan mekanisme enkripsi apa pun. Aktifkan koneksi HTTPS menggunakan sertifikat SSL yang valid untuk mengenkripsi semua permintaan antara browser web pengguna dan server web Apache. Ikuti langkah-langkah di bawah ini untuk menghasilkan sertifikat SSL Let's Encrypt tepercaya dan mengamankan server web Apache.

Instal pengelola paket Snap di server Anda.

menghibur

Menyalin
$ sudo apt install snapd -y

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Instal alat klien Certbot Let's Encrypt menggunakan Snap.

menghibur

Menyalin
$ sudo snap install certbot --classic

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Periksa versi Certbot yang terpasang di server Anda.

menghibur

Menyalin
$ sudo certbot --version

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Keluaran:

certbot 2.11.0
Buat sertifikat SSL baru untuk domain virtual host Anda. Ganti app.example.comdengan domain Anda yang sebenarnya dan user@example.comdengan alamat email Anda.

menghibur

Menyalin
$ sudo certbot --apache -d app.example.com -m email@example.com --agree-tos

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Keluaran:

Account registered.
Requesting a certificate for app.example.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/app.example.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/app.example.com/privkey.pem
This certificate expires on 2024-10-17.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for app.example.com to /etc/httpd/conf.d/app.example.com-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://app.example.com
Uji proses pembaruan sertifikat SSL otomatis Certbot.

menghibur

Menyalin
$ sudo certbot renew --dry-run

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Keluaran:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/app.example.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for app.example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/app.example.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Izinkan koneksi jaringan pada port HTTPS 443melalui firewall.

menghibur

Menyalin
$ sudo ufw allow 443

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Muat ulang konfigurasi firewall untuk menerapkan perubahan.

menghibur

Menyalin
$ sudo ufw reload

Jelaskan Kode
BETA
Didukung oleh Vultr Agent
Kunjungi domain Anda di jendela peramban web baru menggunakan HTTPS dan verifikasi bahwa koneksi Anda aman.
https://app.example.com
Pastikan bahwa Connection is secureprompt muncul di bilah URL browser Anda.

Sumber: https://docs.vultr.com/how-to-install-apache-webserver-on-debian-12

Postingan lainnya

LKM (Lembar Kerja Mahasiswa) Topik:Menjelaskan peran & memilih perangkat jaringan sesuai kebutuhan

06 Mar 2026 20:22

LKM Pertemuan: Menjelaskan peran & memilih perangkat jaringan sesuai kebutuhan Silakan mengunduh LKPM/LKM melalui Google Drive:…

Lanjut membaca →

LKM (Lembar Kerja Mahasiswa) Topik: Bottom-Up Parsing (Shift-Reduce)

05 Mar 2026 11:35

LKPM/LKM Pertemuan: Bottom-Up Parsing (Shift–Reduce) dan Kaitan dengan Python Silakan mengunduh LKPM/LKM melalui Google Drive:…

Lanjut membaca →

LKPM (Lembar Kerja Mahasiswa) Topik: Bottom-Up Parsing (Shift-Reduce) dan Kaitan dengan Python

05 Mar 2026 11:23

LKPM/LKM Pertemuan: Bottom-Up Parsing (Shift–Reduce) dan Kaitan dengan Python Silakan mengunduh LKPM/LKM melalui Google Drive:…

Lanjut membaca →

LKPM (Lembar Kerja Mahasiswa) Topik: Bottom-Up Parsing (Shift-Reduce) dan Kaitan dengan Python

05 Mar 2026 11:19

LKPM/LKM Pertemuan: Bottom-Up Parsing (Shift–Reduce) dan Kaitan dengan Python Silakan mengunduh LKPM/LKM melalui Google Drive:…

Lanjut membaca →

Hasil Sidang Isbath Awal Puasa Ramadhan 1447H

18 Feb 2026 00:37

Liputan6.com, Jakarta - Pemerintah melalui Kementerian Agama (Kemenag) menggelar sidang isbat dalam rangka menentukan awal Ramadan 1447 Hijriah. Hasilnya…

Lanjut membaca →

Create a script to delete a script with the comment "mikhmon".

18 Feb 2026 00:18

Create Script: /system script add name="delete_mikhmon" source=" :foreach script in=[/system script find where comment=\"mikhmon\"] do={ /system script remove…

Lanjut membaca →

Cara Install Apache Web Server Debian 12

18 Feb 2026 00:08

Instal instance server Debian 12 di Vultr. Buat record A domain yang mengarah ke alamat IP publik instance tersebut . Misalnya, app.example.com. Akses server…

Lanjut membaca →

Kisah Hidup: Perjalanan dari Lulus SMK Hingga Menjadi ASN

17 Feb 2026 21:00

Kisah Hidup: Perjalanan dari Lulus SMK Hingga Menjadi ASN Setelah menyelesaikan pendidikan di SMK, saya merasa bahwa dunia luas menanti untuk dijelajahi. Di…

Lanjut membaca →

Perkembangan Teknologi Informasi dan Komunikasi di Indonesia

17 Feb 2026 18:23

Perkembangan Teknologi Informasi dan Komunikasi di Indonesia Surabaya - Teknologi komunikasi merupakan salah satu pilar utama dalam perkembangan masyarakat…

Lanjut membaca →