The default configuration for "allowoverride" for both the root / as the htdocs directrory is set to none in /etc/httpd/httpd.conf
Change the configuration to AllowOverride All in /etc/httpd/httpd.conf for the htdocs directory, and create the .htaccess and .htpasswd files as normal.