# Cara Membuat Web Server dengan NGINX

1. **Install NGINX**

Untuk menginstall NGINX pada Ubuntu, gunakan perintah dibawah. jika ada pilihan \[Y/n] enter saja

```
sudo apt install nginx
```

2. **Melihat status NGINX**

Setelah proses instalasi berhasil, mari kita lihat apakah NGINX sudah berjalan dengan semestinya. Ketikkan command dibawah:

```
// Untuk melihat status NGINX
systemctl status NGINX
```

Jika statusnya sudah "running" seperti gambar dibawah, artinya NGINX sudah berjalan dengan semestinya.

<figure><img src="/files/E2pZHR7aiznfEyjE38if" alt=""><figcaption></figcaption></figure>

3. **Mari kita cek apakah web server dapat berjalan di browser**

Pertama-tama, kita cek IP address server nya terlebih dahulu. Gunakan perintah dibawah:

```
// bisa pilih salah satu
ip a
ipconfig
```

<figure><img src="/files/2YVpczLWXHAzD5mu7hX8" alt=""><figcaption></figcaption></figure>

IP address nya adalah <mark style="background-color:red;">192.168.0.111</mark> dan berjalan di localhost. Oleh karena itu web server belum dapat diakses di luar jaringan lokal. Silahkan ketikkan IP tersebut pada browser, seharusnya tampilan seperti ini:

<figure><img src="/files/Ldgo9QxfZQjDzBK0gnsT" alt=""><figcaption></figcaption></figure>

4. **Direktori file web server**

Konten pada web server terletak di direktori /var/www/html. Untuk berpindah ke direktori tersebut, silahkan gunakan perintah dibawah:

```
cd /var/www/html

// untuk melihat isi direktori
ls
```

<figure><img src="/files/ompGGjqSWXjTsKTNDWKW" alt=""><figcaption></figcaption></figure>

Terdapat file index.nginx-debian.html yang merupakan konten dari web server. Anda bisa menambahkan file website Anda sendiri pada direktori ini.&#x20;

5. **Restart server**

Jika Anda selesai mengonfigurasi web server, lakukan restart NGINX. Terdapat beberapa opsi perintah:

```
// Restart server
systemctl restart nginx

// Stop server
systemctl stop nginx

// Start server
systemctl start nginx

// Reload server
systemctl reload nginx
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devops.my.id/cloud-computing/cara-membuat-web-server-dengan-nginx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
