A really simple manager for .htaccess Basic Auth using .htpasswd and .htgroups files.
Uses the PHP Apache2 Basic Auth lib.
- Clone the repository under a web:
Considering you have a Apache Web Server running with ServerRoot= /var/www
.
cd /var/www
git clone https://github.com/rafaelgou/php-apache2-basic-auth-manager.git
- Configure the application
cd php-apache2-basic-auth-manager
cp config.yml.dist config.yml
chown -R www-data:www-data *
(or whatever user your webserver is running under).
Edit config.yml
using your favorite editor, and be sure to point to the
right paths for .htpasswd
and .htgroups
files.
# Base URL
baseUrl: http://localhost/php-apache2-basic-auth-manager
# Path to Apache2 files
htpasswd: '/home/rafael/Dev/Rgou/.htpasswd'
htgroups: '/home/rafael/Dev/Rgou/.htgroups'
# Debug
debug: false
- Apache config
The system directory must have:
AllowOverride All
to permit Basic Auth.
- Create
.htpasswd
and.htgroups
files
They can be anywhere, but must be readable by webserver user (e.g. www-data). You need to create a initial admin user:
htpasswd -cB /var/www/.htpasswd superuser
chown www-data:www-data /var/www/.htpasswd
echo 'admin: superuser' > /var/www/.htgroups
chown www-data:www-data /var/www/.htgroups
- Create .htaccess file for the system
cd php-apache2-basic-auth-manager
Edit .htaccess
using your favorite editor, and put the following content
AuthName "Members Area"
AuthType Basic
AuthUserFile /var/www/.htpasswd
AuthGroupFile /var/www/.htgroups
<Limit GET POST>
require group admin
# or
# require user superuser
</Limit>
- Now you can access
http://localhost/php-apache2-basic-auth-manager
Use the user/password created above.