Apache Web Server di Ubuntu 14.04
Install Apache Web Server dari repository
sudo apt-get update sudo apt-get install apache2
Selesai install, kita bisa mencobanya dengan mengakses alamat ip server kita melalui browser.
Konfigurasi VirtualHost
Untuk mengonfigurasi virtualhost, kita perlu menentukan nama domain (nama host) yang akan kita gunakan. Misalnya sekolahku.sch.id. Dalam hal ini, alamat Ip yang digunakan adalah 192.168.7.7.
Oiya, kita juga perlu menentukan lokasi folder tempat kita akan menyimpan file aplikasi web kita. Misalnya lokasinya di /var/www/html/sekolahku/
maka langkah konfigurasinya sebagai berikut :
DocumentRoot
Buat folder yang akan digunakan sebagai DocumentRoot :
sudo mkdir -p /var/www/html/sekolahku/
Ubah hak akses direktori tersebut :
sudo chown -Rfv www-data.www-data /var/www/html/sekolahku/
Buat sebuah berkas index.html
sudo nano /var/www/html/sekolahku/index.html
lalu isi file tersebut (diketik) dengan :
- index.html
<html> <head> <title>Belajar Membuat VirtualHost</title> </head> <body> <h1>Belajar Membuat VirtualHost</h1> <p>Paragraf pertama</p> <p>paragraf kedua</p> </body>
Selanjutnya kita konfigurasi Webservernya. Pindah direktori kerja :
cd /etc/apache2/sites-available/
Salin berkas konfigurasi default ke berkas baru,
sudo cp 000-default.conf sekolahku.conf
Edit dengan teks editor nano,
sudo nano sekolahku.conf
Ubah hingga sebagai berikut :
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName sekolahku.sch.id ServerAlias www.sekolahku.sch.id ServerAdmin hay@samsul.web.id DocumentRoot /var/www/html/sekolahku/ # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Simpan dengan menekan Ctrl+X, lalu Y, kemudian Enter. Aktifkan kofigurasi tersebut dengan perintah :
sudo a2ensite sekolahku
Outputnya sebagai berikut :
Enabling site sekolahku. To activate the new configuration, you need to run: service apache2 reload
Berdasarkan keluaran tersebut, maka kita perlu menjalankan perintah :
sudo service apache2 reload
Selanjutnya, tambahkan alamat IP dan domain ke dalam file /etc/hosts
sudo nano /etc/hosts
Lalu tambahkan baris berikut :
#[alamat-ip] nama-domain 127.0.0.1 localhost 127.0.1.1 maarif 192.168.7.7 sekolahku.sch.id
Dalam hal ini, alamat IP yang digunakan adalah 192.168.7.7 sesuaikan alamat IP-nya dengan konfigurasi Anda.
Sampai tahap ini, konfigurasi web server beserta VirtualHost-nya sudah selesai, namun supaya nama domain dapat diakses dari client kita memerlukan DNS Server.
Buka peramban web (misalnya Mozilla Firefox, atau Google Chrome), dan ketikkan alamat http://sekolahku.sch.id. Jika berhasil, maka tampilannya akan sebagai berikut :
Tautan Lain
~~DISQUS~~