Wadah Belajar Linux, Debian, Mikrotik, Networking, Routing, dan Ilmu Pendukungnya

< Browse > Home / Linux, script / Blog article: Proteksi Web Direktori Menggunakan htaccess dan htpasswd

| Mobile | RSS

Proteksi Web Direktori Menggunakan htaccess dan htpasswd

October 16th, 2008 | No Comments | Posted in Linux, script

File htaccess berguna untuk melakukan authenticate user tingkat web server, oleh karena itu file htaccess harus di configure juga di /etc/apache2/sites-available/default (file configurasi site apache2).

# vim /etc/apache2/sites-available/default
cari bagian :

<Directory “/var/www”>
Options Indexes FollowSymLinks MultiViews +SymlinksIfOwnerMatch
IndexOptions NameWidth=* +SuppressDescription
AllowOverride None
Order allow,deny
allow from all
</Directory>

Supaya bisa memakai htaccess harus merubah :

AllowOverride None

menjadi :

AllowOverride AuthConfig

Setelah dirubah, save dan restart si apache :
# /etc/init.d/apache2 restart

Buat file .htaccess, contoh kali ini kita buat di folder /var/www
# vim /var/www/.htaccess

AuthUserFile /var/www/.htpasswd
AuthGroupFile /dev/null
AuthName “Zulfan Test Login”
AuthType Basic
require valid-user

Menggunakan htpasswd utk bikin file data user yg boleh akses, utk yg pertama kali dengan menggunakan opsi -c, misal :
# htpasswd -c /var/www/.htpasswd zulfan
New password:
Re-type new password:
Adding password for user zulfan

Utk menambahkan user lain :
# htpasswd /var/www/html/.htpasswd guest
New password:
Re-type new password:
Adding password for user guest

Silahkan dicoba.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogosphere News
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Slashdot
  • StumbleUpon
  • Technorati
  • Print
  • email
Leave a Reply 3570 views, 2 so far today |

Related Posts

Leave a Reply



View My Stats