How to Setup Password Authentication with Apache in Linuxmint 18.03
Password Authentication with Apache in Linuxmint 18.03
Password Authentication is a restrict from visitors without authentication where we can hide some important and critical information to the un-authenticated users.This article shows how to setup password authentication with Apache in Linuxmint 18.03.
Installation
Assuming that apache is already installed Use the following command to check the status of Apache.
linuxhelp ~ # systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2018-09-19 14:11:52 IST; 3 months 30 days ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/apache2.service
├─3535 /usr/sbin/apache2 -k start
├─3538 /usr/sbin/apache2 -k start
└─3539 /usr/sbin/apache2 -k start
Sep 19 14:11:51 linuxhelp systemd[1]: Starting LSB: Apache2 web server...
Sep 19 14:11:51 linuxhelp apache2[3513]: * Starting Apache httpd web server apache2
Sep 19 14:11:51 linuxhelp apache2[3513]: AH00557: apache2: apr_sockaddr_info_get() failed for linuxhelp
Sep 19 14:11:51 linuxhelp apache2[3513]: AH00558: apache2: Could not reliably determine the server's full
Sep 19 14:11:52 linuxhelp apache2[3513]: *
Sep 19 14:11:52 linuxhelp systemd[1]: Started LSB: Apache2 web server.
Sep 19 14:12:28 linuxhelp systemd[1]: Started LSB: Apache2 web server.
lines 1-18/18 (END)
Create user and The ' htpasswd' command allows you to create a password file. Here we will creating a hidden file .htpasswd within our /etc/apache2 configuration directory.
linuxhelp ~ # useradd agil
linuxhelp ~ # htpasswd -c /etc/apache2/.htpasawd agil
New password:
Re-type new password:
Adding password for user agil
You can view the username and the encrypted password for each user.
linuxhelp ~ # cat /etc/apache2/.htpasawd
agil:$apr1$aSLFUhkf$r9ggEF8Fkcsk7jddCBCUn.
Go to html location create some directory then, give permission and ownership
linuxhelp ~ # cd /var/www/html/
linuxhelp html # mkdir data data1
linuxhelp html # chown -R www-data:www-data *
linuxhelp html # chmod -R 775 *
Configure the virtual host for apache in following location, here create test.conf,
linuxhelp html # vim /etc/apache2/sites-available/test.conf
<virtualhost *:80>
Servername linuxhelp1.com
Documentroot /var/www/
<Directory /var/www/>
AllowOverride all
AuthType Basic
AuthName " Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</virtualhost>
Enable the site access
linuxhelp html # a2ensite test.conf
Enabling site test.
To activate the new configuration, you need to run:
service apache2 reload
Restart the web server to take effect
linuxhelp html # systemctl restart apache2.service
Open a browser and type the following URL http://domainname or ip address
If the user has not provided correct credentials or if we accidentally click cancel, Unauthorized window will appear
With this, the method to Setup Password Authentication with Apache in Linuxmint 18.03 comes to an end.
Comments ( 0 )
No comments available