Skip to content

Nginx

NGINX DEBIAN

Install the prerequisites:

Terminal window
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring

Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:

Terminal window
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Verify that the downloaded file contains the proper key:

Terminal window
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
Terminal window
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

Set up repository pinning to prefer our packages over distribution-provided ones:

Terminal window
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx

To install nginx, run the following commands:

Terminal window
sudo apt update
sudo apt install nginx
Terminal window
nginx -v

Configuration

Terminal window
systemctl start nginx
systemctl restart nginx
systemctl status nginx

Cek pada browser http://localhost atau http://ipaddress

server block

Maksudnya adalah setting konfigurasi untuk mengarahkan ke direktori tertentu, sehingga nantinya server bisa di isi banyak domain

Contoh