Halaman 34Panduan Praktekum Administrasi Server
WEB SERVER DENGAN DEBIAN ETCH 4.0
Rumus menghitung subneting
IP ADDRESS : 192.168.1.1/28 (lihat pada tabel subneting 255.255.255.240)
256-240= 16
Blok kelipatan 0,16,32,64, …
Ip Pertama : 192.168.1.1 NAMA DOMAIN : smkbs.sch.id
Ip Terakhir : 192.168.1.14 Broadcast : 192.168.1.15
Studi Kasus
www.smkbs.sch.id alamatnya 192.168.1.1/28
tkj.smkbs.sch.id alamatnya 192.168.1.2/28
Aplikasi yang harus konfigurasi :
1. Setting Network2. DHCP3. DNS4. Apache25. PHP6. Virtualhost
A. Setting Network
Langkah setting network
1. pilih desktop, pilih administration, klik networking2. pilh nic yang aktif, klik propertis
masukan :
IP addres 192.168.1.1
subnetmask 255.255.255.240
Getway 192.168.1.1
isikan pada menu general
hostname : smkbs
domain name : smkbs.sch.id
Isikan pada DNS server : 192.168.1.1
isikan pada search domain : smkbs.sch.id
setelah selesai klik ok
a
tau konfigurasi pada direktori /etc/network/interfaces
# pico /etc/network/interfaces
# The primary network interfaceallow-hotplug eth0iface eth0 inet static address 192.168.1.1 netmask 255.255.255.240 network 192.168.1.0 broadcast 192.168.1.15 gateway 192.168.1.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 192.168.1.1 dns-search smkbs.sch.id
untuk keluar dan save tekan tombol ctrl+x >y (yes)
lakukan pengecekan IP Address dengan perintah ifconfig
:
debian:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:BF:5E:19:C9
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::250:bfff:fe5e:19c9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:902 errors:0 dropped:0 overruns:0 frame:0
TX packets:2081 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:116241 (113.5 KiB) TX bytes:141221 (137.9 KiB)
Interrupt:5 Base address:0xa800
eth1 Link encap:Ethernet HWaddr 00:A0:00:02:FE:AA
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0xac00
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1105 errors:0 dropped:0 overruns:0 frame:0
TX packets:1105 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:97805 (95.5 KiB) TX bytes:97805 (95.5 KiB)
Konfigurasi hosts
smkbs:/etc/bind# pico /etc/hosts
127.0.0.1 localhost smkbs.sch.id
192.168.1.1 smkbs.sch.id smkbs.sch.id
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Konfigurasi resolv.conf
smkbs:/etc/bind# pico /etc/resolv.conf
search smkbs.sch.id
domain smkbs.sch.id
nameserver 192.168.1.1
Lakukan Pengecekan dengan ping
smkbs:/home/smk# ping smkbs.sch.id
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.209 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.163 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.168 ms
Jika berhasil maka akan muncul seperti diatas jika gagal cek pada hosts dan resolv.conf
B. DHCP
Langkah – langkah Instalasi DHCP
smkbs:/home/smk# apt-get install dhcp3-server
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
dhcp3-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/292kB of archives.
After unpacking 836kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously deselected package dhcp3-server.
(Reading database ... 72002 files and directories currently installed.)
Unpacking dhcp3-server (from .../dhcp3-server_3.0.4-13_i386.deb) ...
Setting up dhcp3-server (3.0.4-13) ...
Generating /etc/default/dhcp3-server...
Starting DHCP server: dhcpd3 failed to start - check syslog for diagnostics.
invoke-rc.d: initscript dhcp3-server, action "start" failed.
Langkah konfigurasi DHCP
1. backup terlebih dahulu file dhcpd.conf pada /etc/dhcp3
debian:~#cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_orig
2. edit dan ketikan pada dhcpd.conf ( gunakan perintah pico utk mengedit teks)
contoh :
debian:~# cd /etc/dhcp3
debian:/etc/dhcp3# pico dhcpd.conf
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
Lakukan pengeditan teks pada dhcpd.conf
hapus tanda ( #) dan tuliskan konfigurasinya menjadi :
# A slightly different configuration for an internal subnet.
subnet 192.168.1.0 netmask 255.255.255.240 {
range 192.168.1.5 192.168.1.14;
option domain-name-servers 192.168.1.1;
option domain-name "smkbs.sch.id";
option routers 192.168.1.1;
option broadcast-address 192.168.1.15;
default-lease-time 600;
max-lease-time 7200;
3. Tekan Ctrl x dan jawab yes untuk menyimpan teks dan keluar
4. lakukan perintah /etc/init.d/dhcp3-server restart
debian:/etc/dhcp3# /etc/init.d/dhcp3-server restart
Stopping DHCP server: dhcpd3.
Starting DHCP server: dhcpd3 failed to start - check syslog for diagnostics.
5. ketikan /etc/dhcp3# netstat -uap
( untuk melihat aktivitas DHCP)
debian:/etc/dhcp3# netstat -uap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 *:32768 *:* 2270/named
udp 0 0 *:nfs *:* -
udp 0 0 *:32770 *:* 2284/lwresd
udp 0 0 *:32772 *:* 2638/avahi-daemon:
udp 0 0 *:32773 *:* -
udp 0 0 *:32774 *:* 2850/rpc.statd
udp 0 0 debian.com:netbios-ns *:* 2778/nmbd
udp 0 0 *:netbios-ns *:* 2778/nmbd
udp 0 0 *:906 *:* 2850/rpc.statd
udp 0 0 debian.com:netbios-dgm *:* 2778/nmbd
udp 0 0 *:netbios-dgm *:* 2778/nmbd
udp 0 0 localhost.localdoma:921 *:* 2284/lwresd
udp 0 0 *:817 *:* 2761/rpc.mountd
udp 0 0 debian.com:domain *:* 2270/named
udp 0 0 localhost.locald:domain *:* 2270/named
udp 0 0 *:mdns *:* 2638/avahi-daemon:
udp 0 0 *:sunrpc *:* 2017/portmap
udp 0 0 *:ipp *:* 2563/cupsd
udp6 0 0 *:32769 *:* 2270/named
udp6 0 0 *:32771 *:* 2284/lwresd
udp6 0 0 *:domain *:* 2270/named
6. ketikan perintah tail -n 100 /var/log/syslog
untuk mengetahui DHCP telah berhasil dijalankan)
debian:/etc/dhcp3# tail -n 100 /var/log/syslog
Nov 7 06:09:26 localhost syslogd 1.4.1#18: restart.
Nov 7 06:09:26 localhost anacron[2886]: Job `cron.daily' terminated
Nov 7 06:09:26 localhost anacron[2886]: Normal exit (1 job run)
Nov 7 06:09:26 localhost avahi-daemon[2638]: Interface eth0.IPv4 no longer relevant for mDNS.
Nov 7 06:09:26 localhost avahi-daemon[2638]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.1.1.
Nov 7 06:09:26 localhost avahi-daemon[2638]: Withdrawing address record for 192.168.1.1 on eth0.
Nov 7 06:09:26 localhost kernel: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Nov 7 06:09:26 localhost avahi-daemon[2638]: New relevant interface eth0.IPv4 for mDNS.
Nov 7 06:09:26 localhost avahi-daemon[2638]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.1.1.
C. DNS
Instalasi & konfigurasi DNS
Instalasi BIND
smkbs:/home/smk# apt-get install bind
Reading package lists... Done
Building dependency tree... Done
Suggested packages:
bind-doc
The following packages will be REMOVED:
bind9
The following NEW packages will be installed:
bind
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
Need to get 0B/966kB of archives.
After unpacking 1356kB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 71947 files and directories currently installed.)
Removing bind9 ...
Stopping domain name service...: bind.
Selecting previously deselected package bind.
(Reading database ... 71924 files and directories currently installed.)
Unpacking bind (from .../b/bind/bind_8.4.7-1_i386.deb) ...
Replaced by files in installed package dnsutils ...
Setting up bind (8.4.7-1) ...
Installing new version of config file /etc/bind/named.conf ...
Installing new version of config file /etc/bind/named.conf.local ...
Installing new version of config file /etc/bind/named.conf.options ...
Starting domain name service: named.
Konfigurasi named.conf
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
Edit file named.conf menjadi
/ be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "smkbs.sch.id" {
type master;
file "/etc/bind/forward";
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/reverse";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
Lakukan pengcopian ke 2 file pada direktori /etc/bind yaitu db.local menjadi forward dan db.127 menjadi reverse
smkbs:/etc/bind# cp /etc/bind/db.local /etc/bind/forward
smkbs:/etc/bind# cp /etc/bind/db.127 /etc/bind/reverse
Konfigurasi Forward
smkbs:/etc/bind# pico forward
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
edit text menjadi :
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA smkbs.sch.id. root.smkbs.sch.id. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS smkbs.sch.id.
@ IN A 192.168.1.1
IN MX 10 mail.smkbs.sch.id.
ns IN A 192.168.1.1
www IN CNAME @
tkj IN CNAME @
mail IN CNAME @
Konfigurasi Reverse
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
1.0.0 IN PTR localhost.
Edit text menjadi :
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA smkbs.sch.id. root.smkbs.sch.id. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS smkbs.sch.id.
1 IN PTR smkbs.sch.id.
Lakukan Pengecekan dengan perintah ping
smkbs:/home/smk# ping smkbs.sch.id
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.209 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.163 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.168 ms
smkbs:/home/smk# ping www.smkbs.sch.id
PING smkbs.sch.id (192.168.1.1) 56(84) bytes of data.
64 bytes from smkbs.sch.id.sch.id (192.168.1.1): icmp_seq=1 ttl=64 time=0.117 ms
64 bytes from smkbs.sch.id.sch.id (192.168.1.1): icmp_seq=2 ttl=64 time=0.140 ms
64 bytes from smkbs.sch.id.sch.id (192.168.1.1): icmp_seq=3 ttl=64 time=0.160 ms
64 bytes from smkbs.sch.id.sch.id (192.168.1.1): icmp_seq=4 ttl=64 time=0.154 ms
Lakukan Pengecekan dengan perintah nslookup
smkbs:/home/smk# nslookup smkbs.sch.id
Server: 192.168.1.1
Address: 192.168.1.1#53
Name: smkbs.sch.id
Address: 192.168.1.1
smkbs:/home/smk# nslookup www.smkbs.sch.id
Server: 192.168.1.1
Address: 192.168.1.1#53
www.smkbs.sch.id canonical name = smkbs.sch.id.
Name: smkbs.sch.id
Address: 192.168.1.1
Lakukan Pengecekan dengan perintah host
smkbs:/home/smk# host www.smkbs.sch.id
www.smkbs.sch.id is an alias for smkbs.sch.id.
smkbs.sch.id has address 192.168.1.1
smkbs.sch.id mail is handled by 10 mail.smkbs.sch.id.
Lakukan Pengecekan dengan perintah dig
smkbs:/home/smk# dig www.smkbs.sch.id
; <<>> DiG 9.3.4 <<>> www.smkbs.sch.id
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52928
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;www.smkbs.sch.id. IN A
;; ANSWER SECTION:
www.smkbs.sch.id. 604800 IN CNAME smkbs.sch.id.
smkbs.sch.id. 604800 IN A 192.168.1.1
;; AUTHORITY SECTION:
smkbs.sch.id. 604800 IN NS smkbs.sch.id.
;; ADDITIONAL SECTION:
smkbs.sch.id. 604800 IN A 192.168.1.1
;; Query time: 3 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Wed Apr 7 20:28:53 2010
;; MSG SIZE rcvd: 94
Edit index.html pada direktori /etc/apache2/sites-default
Cek dibrowser melalui Epiphany Web Browser
www.smkbs.sch.id atau dengan IP Address 192.168.1.1
D. Instalasi Apache2
smkbs:/home/smk# apt-get install apache2
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
apache2
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/38.6kB of archives.
After unpacking 86.0kB of additional disk space will be used.
Selecting previously deselected package apache2.
(Reading database ... 71959 files and directories currently installed.)
Unpacking apache2 (from .../apache2_2.2.3-4_all.deb) ...
Setting up apache2 (2.2.3-4) ...
E. Instalasi PHP5
smkbs:/home/smk# apt-get install php5
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
libapache2-mod-php5 php5-common
Suggested packages:
php-pear
The following packages will be REMOVED:
libapache2-mod-php4
The following NEW packages will be installed:
libapache2-mod-php5 php5 php5-common
0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.
Need to get 0B/2626kB of archives.
After unpacking 2875kB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 71961 files and directories currently installed.)
Removing libapache2-mod-php4 ...
Module php4 disabled; run /etc/init.d/apache2 force-reload to fully disable.
Selecting previously deselected package php5-common.
(Reading database ... 71958 files and directories currently installed.)
Unpacking php5-common (from .../php5-common_5.2.0-8+etch1_i386.deb) ...
Selecting previously deselected package libapache2-mod-php5.
Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.2.0-8+etch1_i386.d eb) ...
Selecting previously deselected package php5.
Unpacking php5 (from .../php5_5.2.0-8+etch1_all.deb) ...
Setting up php5-common (5.2.0-8+etch1) ...
Setting up libapache2-mod-php5 (5.2.0-8+etch1) ...
Creating config file /etc/php5/apache2/php.ini with new version
Forcing reload of web server (apache2)....
Setting up php5 (5.2.0-8+etch1) ...
Konfigurasi php
smkbs:/home/smk# cd /var/www
smkbs:/var/www# pico info.php
ketikan :
<?
phpinfo ();
?>
F. Konfigurasi Virtualhost dengan IP Address yang berbeda
www.smkbs.sch.id 192.168.1.1
tkj.smkbs.sch.id 192.168.1.2
1. Buat terlebih dahulu IP Address Alias
smkbs:/var/www# /sbin/ifconfig eth0:1 192.168.1.2
Lakukan perintah untuk mengaktifkan IP Address alias
/etc/init.d/networking restart
Cek IP address alias yang kita buat dengan perintah :
# ifconfig
Lakukan perintah ping
# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.188 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.153 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.150 ms
2. Buat website direktori /var/www
smkbs:/var/www # mkdir -p /var/www/www.smkbs.sch.id/public_html
smkbs:/var/www # mkdir -p /var/www/tkj.smkbs.sch.id/public_html
edit text
smkbs:/var/www/www.smkbs.sch.id/public_html# pico index.html
smkbs:/var/www/tkj.smkbs.sch.id/public_html# pico index.html
Buat web www.smkbs.sch.id
<html> Selamat datang di WWW.SMKBS.SCH.ID </html>
simpan dengan nama index.html
smkbs:/var/www# mkdir -p /var/www/tkj.smkbs.sch.id/public_html
smkbs:/var/www/tkj.smkbs.sch.id# pico index.html
Buat web tkj.smkbs.sch.id
<html> selamat datang di tkj.smkbs.sch.id </html>
3. Merubah konfigurasi DNS forward dan reverse
Konfigurasi Forward
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA smkbs.sch.id. root.smkbs.sch.id. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS smkbs.sch.id.
@ IN A 192.168.1.1
IN MX 10 mail.smkbs.sch.id.
ns IN A 192.168.1.1
www IN A 192.168.1.1
tkj IN A 192.168.1.2
mail IN A 192.168.1.1
Konfigurasi Reverse
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA smkbs.sch.id. root.smkbs.sch.id. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS smkbs.sch.id.
1 IN PTR smkbs.sch.id.
1 IN PTR mail.smkbs.sch.id.
2 IN PTR tkj.smkbs.sch.id.
Konfigurasi pada default pada direktori /etc/apache2/sites-available
masuk ke direktori /etc/apache2/sites-available/default
Perintah :
smkbs:~# cd /etc/apache2/sites-available
smkbs:/etc/apache2/sites-available# ls
default
smkbs:/etc/apache2/sites-available# pico default
Konfigurasi file default
Konfigurasi pada default pada direktori /etc/apache2/sites-available
masuk ke direktori /etc/apache2/sites-available
Jangan lupa back up terlebih dahulu default menjadi nama file master
smkbs:~# cd /etc/apache2/sites-available
smkbs:/etc/apache2/sites-available# ls
default
smkbs:/etc/apache2/sites-available# pico default
Ketikan pada bagian terakir pada default
</VirtualHost>
<VirtualHost 192.168.1.1>
ServerAdmin [email protected]
DocumentRoot /var/www/www.smkbs.sch.id/public_html
ServerName www.smkbs.sch.id
</VirtualHost>
<VirtualHost 192.168.1.2>
ServerAdmin [email protected]
Documentroot /var/www/tkj.smkbs.sch.id/public_html
ServerName tkj.smkbs.sch.id
</VirtualHost>
Konfigurasi pada direktori /etc/apache2/ports.conf
smkbs:/etc/apache2# cd /etc/apache2
smkbs:/etc/apache2# ls
apache2.conf envvars mods-available ports.conf sites-enabled
conf.d httpd.conf mods-enabled sites-available
smkbs:/etc/apache2# pico ports.conf
Ketikan :
NameVirtualhost 192.168.1.1
Listen 80
<IfModule mod_ssl.c>
Listen 443
</Ifmodule>
Lakukan service :
1. smkbs:/etc/apache2# /etc/init.d/bind restart
Stopping domain name service: named.
Starting domain name service: named.
2. smkbs:/etc/apache2# /etc/init.d/apache2 restart
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using smkbs.sch.id for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using smkbs.sch.id for ServerName
3. smkbs:/etc/apache2# /etc/init.d/apache2 start
Starting web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using smkbs.sch.id for ServerName
httpd (pid 4007) already running
Copyright ©2010 SMK-TI Bina Sejahtera 1 Linux Debian Etch 4.0
Teknik Komputer & Jaringan