การตั้ง user/password สำหรับ Apache Web directory

Apache

  • แก้ไข apached.conf

<Directory "/var/www/html/protected">
AllowOverride AuthConfig
# The Options below is an example. Use what you deem is necessary.
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>

  • แก้ไข .htaccess

AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/etc/htpasswd/.htpasswd"
Require valid-user

  • สร้าง user/password file

# htpasswd -c /etc/htpasswd/.htpasswd username

  • restart apache service

Reference

Comments are closed