Friday, 15 November 2013

HTTP and User Base Authentication in LINUX

# yum install httpd -y

# cd /var/www/html - > Default Document Root.

Just creating a index.html file with test matter.

cat > index.html
Test for HTTPD

ctrl + D


# vi /etc/httpd/conf/httpd.conf
at last of this file



<VirtualHost *:80>
    ServerAdmin root@desktop10.example.com  # Administrator of HTTP Site
    DocumentRoot /var/www/html # Document Root for Index.html
    ServerName desktop10.example.com  # Website Name
</VirtualHost>


# Service httpd restart;chkconfig httpd on


elinks desktop10.example.com  # Check normal website is working or not.


For user base Authentication - 


vi /var/www/html/.htaccess  # creating to add username and password details


AuthName "Test for learning"  # This text displayed as a caption.

AuthType basic # Authentication Type
AuthUserFile /var/www/html/mypass # Password file location for user below
require user ashutosh 

edit httpd.conf again and add at last


<Directory "/var/www/html">

  AllowOverride AuthConfig
  Order allow,deny
  Allow from all

</Directory>

# useradd ashutosh

# passwd ashutosh # Not compulsory

# htpasswd -c /var/www/html/mypass ashutosh # this is save an encrypted password to mypass file.


#service httpd restart 


CHECK THE RESULT


Suggestion, Comments are alwasy WELCOME

Regards
Ashutosh S.Bhakare
(EX413, RHCSS,RHCVA 3.0,RHCE,MCP,CCNA)
Unnati Computers,Aurangabad
Red Hat Authorised Training Partner
www.unnatiithub.org
Ph.9822451920,0240-2485766

No comments:

Post a Comment