What are the best practices for setting up authentication in Apache for PHP websites?

Setting up authentication in Apache for PHP websites involves creating a .htpasswd file to store usernames and passwords, configuring the .htaccess file to require authentication for specific directories, and setting up the authentication type and realm in the Apache configuration.

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /path/to/.htpasswd
Require valid-user