Monday, May 11, 2020

add apache authentication in ubuntu and centOS


IN CENT OS

 Create user :-

 # htpasswd  /var/www/.htpasswd user_name

# /etc/httpd/httpd.conf

<Directory "/var/www/html">

    #Requires Authentication to view pages
        AuthUserFile /var/www/.htpasswd
        #Satisfy any  ------------------comment (authentication on) uncomment (authentication off)
        AuthName "Username and password required"
        AuthType Basic
    <RequireAll>

        Require valid-user-----------It is use  for multiple user
       #Require user user_name ---------It is use for single user with name

    </RequireAll>





IN UBUNTU OS
Create User :-

# htpasswd /etc/apache2/.htpasswd subhash

# /etc/apache2/sites-available/000-default.conf

        <Directory "/var/www/html">
        AuthType none

      AuthName "Restricted Content"

      AuthUserFile /etc/apache2/.htpasswd

        #Satisfy any

      Require valid-user
  </Directory>
</VirtualHost>

Now Check In URL

http://www.localhost.com/


No comments:

Post a Comment

testing