Instalasi Nginx Debian 12: Perbedaan antara revisi
Loncat ke navigasi
Loncat ke pencarian
Tidak ada ringkasan suntingan |
k (Melindungi "Instalasi Nginx Debian 12" ([Sunting=Hanya untuk pengurus] (selamanya) [Pindahkan=Hanya untuk pengurus] (selamanya))) |
Revisi per 3 September 2024 02.03
Instal Nginx diawali dengan mengetikan perintah
apt update apt upgrade apt install ufw
akan muncul tampilan seperti berikut
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: iptables libip6tc2 libnetfilter-conntrack3 libnfnetlink0 Suggested packages: firewalld rsyslog The following NEW packages will be installed: iptables libip6tc2 libnetfilter-conntrack3 libnfnetlink0 ufw 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 603 kB of archives. After this operation, 3606 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://deb.debian.org/debian bookworm/main amd64 libip6tc2 amd64 1.8.9-2 [19.4 kB] Get:2 http://deb.debian.org/debian bookworm/main amd64 libnfnetlink0 amd64 1.0.2-2 [15.1 kB] Get:3 http://deb.debian.org/debian bookworm/main amd64 libnetfilter-conntrack3 amd64 1.0.9-3 [40.7 kB] Get:4 http://deb.debian.org/debian bookworm/main amd64 iptables amd64 1.8.9-2 [360 kB] Get:5 http://deb.debian.org/debian bookworm/main amd64 ufw all 0.36.2-1 [168 kB] Fetched 603 kB in 0s (2373 kB/s) Preconfiguring packages ... Selecting previously unselected package libip6tc2:amd64. (Reading database ... 19138 files and directories currently installed.) Preparing to unpack .../libip6tc2_1.8.9-2_amd64.deb ... Unpacking libip6tc2:amd64 (1.8.9-2) ... Selecting previously unselected package libnfnetlink0:amd64. Preparing to unpack .../libnfnetlink0_1.0.2-2_amd64.deb ... Unpacking libnfnetlink0:amd64 (1.0.2-2) ... Selecting previously unselected package libnetfilter-conntrack3:amd64. Preparing to unpack .../libnetfilter-conntrack3_1.0.9-3_amd64.deb ... Unpacking libnetfilter-conntrack3:amd64 (1.0.9-3) ... Selecting previously unselected package iptables. Preparing to unpack .../iptables_1.8.9-2_amd64.deb ... Unpacking iptables (1.8.9-2) ... Selecting previously unselected package ufw. Preparing to unpack .../archives/ufw_0.36.2-1_all.deb ... Unpacking ufw (0.36.2-1) ... Setting up libip6tc2:amd64 (1.8.9-2) ... Setting up libnfnetlink0:amd64 (1.0.2-2) ... Setting up libnetfilter-conntrack3:amd64 (1.0.9-3) ... Setting up iptables (1.8.9-2) ... update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in auto mode update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in auto mode update-alternatives: using /usr/sbin/iptables-nft to provide /usr/sbin/iptables (iptables) in auto mode update-alternatives: using /usr/sbin/ip6tables-nft to provide /usr/sbin/ip6tables (ip6tables) in auto mode update-alternatives: using /usr/sbin/arptables-nft to provide /usr/sbin/arptables (arptables) in auto mode update-alternatives: using /usr/sbin/ebtables-nft to provide /usr/sbin/ebtables (ebtables) in auto mode Setting up ufw (0.36.2-1) ... Creating config file /etc/ufw/before.rules with new version Creating config file /etc/ufw/before6.rules with new version Creating config file /etc/ufw/after.rules with new version Creating config file /etc/ufw/after6.rules with new version Created symlink /etc/systemd/system/multi-user.target.wants/ufw.service -> /lib/systemd/system/ufw.service. Processing triggers for libc-bin (2.36-9+deb12u8) ... Processing triggers for man-db (2.11.2-2) ... root@nginx:~#
Enable ufw dengan mengetikkan perintah
root@nginx:~# ufw enable (enter) Firewall is active and enabled on system startup root@nginx:~#
Cek status ufw
root@nginx:~# ufw status (enter) Status: active root@nginx:~#
Install nginx dengan mengetikkan perintah
root@nginx:~# apt install nginx (enter) Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: nginx-common Suggested packages: fcgiwrap nginx-doc The following NEW packages will be installed: nginx nginx-common 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 640 kB of archives. After this operation, 1696 kB of additional disk space will be used. Do you want to continue? [Y/n] Y (enter) Get:1 http://deb.debian.org/debian bookworm/main amd64 nginx-common all 1.22.1-9 [112 kB] Get:2 http://deb.debian.org/debian bookworm/main amd64 nginx amd64 1.22.1-9 [527 kB] Fetched 640 kB in 0s (2491 kB/s) Preconfiguring packages ... Selecting previously unselected package nginx-common. (Reading database ... 19463 files and directories currently installed.) Preparing to unpack .../nginx-common_1.22.1-9_all.deb ... Unpacking nginx-common (1.22.1-9) ... Selecting previously unselected package nginx. Preparing to unpack .../nginx_1.22.1-9_amd64.deb ... Unpacking nginx (1.22.1-9) ... Setting up nginx-common (1.22.1-9) ... Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -> /lib/systemd/system/nginx.service. Setting up nginx (1.22.1-9) ... Upgrading binary: nginx. Processing triggers for man-db (2.11.2-2) ... Processing triggers for ufw (0.36.2-1) ... root@nginx:~#
Instalasi lengkap dengan mysql dan PHP, dengan mengetikan perintah seperti di bawah ini,
apt -y install nginx php5 php5-xmlrpc php5-mysql php5-gd php5-cli php5-curl \ mysql-client mysql-server
Cek / Test
Restart nginx
root@nginx:~# systemctl restart nginx (enter) root@nginx:~# systemctl status nginx (enter) * nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: active (running) since Tue 2024-09-03 01:48:21 UTC; 35s ago Docs: man:nginx(8) Process: 5207 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exit> Process: 5209 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, statu> Main PID: 5210 (nginx) Tasks: 2 (limit: 38314) Memory: 1.7M CPU: 5ms CGroup: /system.slice/nginx.service |-5210 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" `-5211 "nginx: worker process" Sep 03 01:48:21 nginx systemd[1]: Starting nginx.service - A high performance web server and a r> Sep 03 01:48:21 nginx systemd[1]: Started nginx.service - A high performance web server and a re> ...skipping... * nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: active (running) since Tue 2024-09-03 01:48:21 UTC; 35s ago Docs: man:nginx(8) Process: 5207 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exit> Process: 5209 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, statu> Main PID: 5210 (nginx) Tasks: 2 (limit: 38314) Memory: 1.7M CPU: 5ms CGroup: /system.slice/nginx.service |-5210 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" `-5211 "nginx: worker process" Sep 03 01:48:21 nginx systemd[1]: Starting nginx.service - A high performance web server and a r> Sep 03 01:48:21 nginx systemd[1]: Started nginx.service - A high performance web server and a re> ~ ~
lines 1-16/16 (END) (tekan kombinasi tombol ctrl + c untuk keluar dari tampilan ini) ^C root@nginx:~# ^C root@nginx:~#
Cek IP Address Server dengan mengetikkan perintah
root@Ngin-X:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0@if58: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 42:92:d2:25:49:58 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.20.9/24 brd 192.168.20.255 scope global dynamic eth0 valid_lft 1566sec preferred_lft 1566sec inet6 fe80::4092:d2ff:fe25:4958/64 scope link valid_lft forever preferred_lft forever root@Ngin-X:~#
akses melalui web
http://192.168.20.9
akan keluar kata-kata
Welcome to nginx!
Konfigurasi Default
Folder HTML default
root /usr/share/nginx/html;
Konfigurasi nginx
/etc/nginx/sites-enabled/default
chmod -Rf 755 /usr/share/nginx chown -Rf nobody.nogroup /usr/share/nginx
Untuk mengubah document root supaya tidak bentrok, ubah /etc/nginx/sites-enabled/default
root /var/www/html;