Web Server Apache.

Web Server Apache.

Konsep Dari Web bekerja dalam konsep client – server.

Web client meminta halaman (dokumen web) kepadaweb server melalui jaringan komputer. Web server merespon dengan mencarikan dokumen(halaman) pada lokasi penyimpanan dokumen web yang ada pada web server. Selanjutnya webserver mengirimkannya kepada web client.

Contoh aplikasi web client: Mozilla Firefox, IE, Opera, Safari, Chrome dan lain lain Contoh aplikasi web server: Apache, IIS, Nginx, lighttpd, tomcat dan lain lain.

ok gan langsung saja tanpa basa basi untuk penjelasan mengenai apache. Mungkin kalau yang masih awam-awam banget biasanya dalam benak seorang akan bertanya-tanya. Apasih itu APACHE?

Apache Merupakan aplikasi web server default di CentOS 6.

Nama paket softwarenya adalah httpd.  Demikian pula nama servicenya sama yaitu httpd. Sedangkan port default yang digunakan adalah  port 80. File konfigurasi utamanya ada di /etc/httpd/conf/httpd.conf sedangkan file konfigurasi  tambahan dapat disimpan di direktori /etc/httpd/conf.d dengan menggunakan ekstensi .conf. Direktori default untuk menyimpan file­file html atau biasa disebut dengan Document Root terdapat di /var/www/html. 

Instalasi Apache Untuk memeriksa ketersediaan paket httpd jalankan perintah berikut: 

[root@pc­server­fauzi ~]# rpm ­qa | grep httpd atau  bisa juga
[root@pc­serverfauzi ~]# rpm ­q httpd 
package httpd is not installed Apabila paket httpd belum diinstal, jalankan berintah berikut untuk menginstalnya:
[root@pc­serverfauzi ~]# yum ­y install httpd

Mengelola Service Apache Sebagai berikut :

Menjalankan service apache: 

# service httpd start 

Menghentikan service apache: 

# service httpd stop 

Me­restart service apache: 

# service httpd restart 

Memeriksa status serviec apache: 

# service httpd status

Konfigurasi Direktory Di Apache.

Contoh konfigurasi direktori:

 Cara Kerja Web Server  :

<Directory "/var/www/html"> 
     Options Indexes FollowSymLinks
     AllowOverride none 
     Order allow,deny
     Allow from all 
</Directory>  

Keterangan:

Indexes : file­file di dalam direktori dapat diakses tanpa file index
FollowSymLinks : biar bisa menggunakan symbolic link
AllowOverride none : fitur untuk autentikasi dalam hal ini dinonaktifkan
Order allow,deny : urutan hak akses ke direktori
Allow from all : diperbolehkan dari semua IP, contoh lain : Allow from 192.168.1.0/24

Konfigurasi User Director.

Fungsinya agar setiap user bisa menyimpan halaman website­nya di  home directory  masing­-masing. Diakses dengan menggunakan URL: http://hostname/~user
Contoh :
User badu dapat diakses website­nya di alamat http://localhost/~fauzi

Langkah­langkah pengaturan konfigurasinya: 

1. Edit file /etc/httpd/conf/httpd.conf, kemudian beri komentar (tanda #) pada baris UserDir  Disabled dan hapus komentar (tanda #) pada baris UserDir public_html sehingga menjadi  seperti contoh
di bawah ini:
<IfModule mod_userdir.c>     
     # 
     # UserDir is disabled by default since it can confirm the presence
     # of a username on the system (depending on home directory
     # permissions).
     #    
     # UserDir disabled

     #
     # To enable requests to /~user/ to serve the user's public_html
     # directory, remove the "UserDir disabled" line above, and uncomment
     # the following line instead:
     #      UserDir public_html 
</IfModule>

Catatan:

public_html adalah nama direktori yang harus ada pada home directory user untuk menyimpan file­ file html. Nama direktori ini dapat diganti sesuai keinginan.

2. Edit file /etc/httpd/conf/httpd.conf, kemudian hapus komentar (tanda #) pada baris­baris berikut: 

<Directory /home/*/public_html>
     AllowOverride FileInfo AuthConfig Limit
     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
     <Limit GET POST OPTIONS>
         Order allow,deny
         Allow from all
     </Limit>
     <LimitExcept GET POST OPTIONS>
         Order deny,allow
         Deny from all
     </LimitExcept>
 </Directory> 

3. Restart service apache

[root@pc­serverfauzi ~]#  service httpd restart 

4. Buat direktori public_html pada home directory user fauzi

[root@pc­server ~]# su ­ badu
[badu@pc­server ~]$ mkdir public_html  
[badu@pc­server ~]$ cd public_html 

5. Buat file index.html pada direktori public_html untuk menampilkan halaman web, contoh isinya sbb:

[badu@pc­server public_html]$ vim index.html
<h1 style="text­align:center">Halaman Web Fauzi</h1> 

6. Ubah permissions direktori /home/badu menjadi 711 

[badu@pc­server ~]$ chmod 711 /home/badu 
7. Jalankan web browser kemudian akses alamat url berikut  :
http://192.168.100.10/~fauzi

Konfigurasi Alias Direktori 

Menampilkan halaman web dari direktori lain seakan­akan berada di Document Root.
Contoh : Direktori /home/data dapat diakses dengan url http://localhost/data

Langkah­langkah pengaturan konfigurasinya:

1. Buat file /etc/httpd/conf.d/alias.conf, tambahkan baris­baris berikut di dalamnya: 

[root@pc­serverfauzi ~]# vim /etc/httpd/conf.d/alias.conf 
Alias /data "/home/data/"
  <Directory "/home/data/">
     Options Indexes FollowSymLinks
     AllowOverride none
     Order allow,deny
     Allow from all
  </Directory> 

2. Restart service apache 

[root@pc­server ~]#  service httpd restart  

3. Buat direktori /home/data 

[root@pc­server ~]#  mkdir /home/data  

4. Jalankan web browser kemudian akses alamat url berikut  : 

http://192.168.100.10/data

Konfigurasi Virtual Host 

Fungsinya menampilkan halaman yang berbeda untuk setiap domain yang diarahkan ke komputer  tersebut.

Langkah­langkah pengaturan konfigurasinya:

1. Edit file /etc/httpd/conf/httpd.conf, kemudian tambahkan baris­baris berikut di bagian akhir file:

[root@pc­server ~]# vim /etc/httpd/conf/httpd.conf 
NameVirtualHost *:80
  <VirtualHost *:80>
     ServerAdmin root@fauzi.oke
     DocumentRoot /var/www/html
     ServerName www.dudi.oke
     ErrorLog logs/www.dudi.oke­error.log
     CustomLog logs/www.dudi.oke­access.log common
  </VirtualHost>
  <VirtualHost *:80>
     ServerAdmin root@fauzi.oke
     DocumentRoot /home/blog
    ServerName blog.dudi.oke
     ErrorLog logs/blog.fauzi.oke­error.log
     CustomLog logs/blog.dudi.oke­access.log common
  </VirtualHost>  

2. Restart service apache 

[root@pc­server ~]# service httpd restart 

3. Buat direktori /home/blog

[root@pc­server ~]# mkdir /home/blog 

4. Buat file index.html pada direktori /home/blog untuk menampilkan halaman web, contoh isinya  sbb:

[root@pc­server ~]$ vim /home/blog/index.html <h1 style="text­align:center">blog.fauzi.oke</h1>

sekian. semoga bermanfaat. dan langsung di appalay gan sekaligus praktek.
copyright by ©_fauzi rohman syah.

Comments