Linux Directory Access

From Nonecks Docs

Jump to: navigation, search

Contents

Create .htaccess File

vi /var/www/sitename/.htaccess

.htaccess file contents

AuthType Basic
AuthUserFile /path/to/where/you/want/to/store/the/password/file/.htpasswd
AuthName Admin
require valid-user
satisfy any
  • Obviously you would fix the path here before saving

Edit Permissions for .htaccess

chmod 644 .htaccess

Create .htpasswd File

htpasswd -bc /path/to/where/you/want/to/store/the/password/file/.htpasswd admin admin_password

Edit Permissions for .htpasswd

chmod 644 /path/to/where/you/want/to/store/the/password/file/.htpasswd
  • This would have to match your .htaccess file.