How To Set Up Password Authentication with Apache on Ubuntu 14.04, 16.04 & 18.04


I followed this guide for my Ubuntu 18.04 server and opted the virtual host method (there are two methods to setup Apache auth, one is Virtual Host Definition and other one requires .htaccess file), I opted the first one namely the Virtual Host Definition. I followed the guide but config file in the guide didn’t worked for me so I had to improvise :). This is my config file that worked for me.

Options +FollowSymlinks
AllowOverride All
Require all granted

AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

Checkout this link for more.