Thursday 24 January 2013

How to Password Protect a Directory on Your Website

If you want to password protect a directory in Apache then we need to modify below file

    [root@localhost ~]#  vim   /etc/httpd/conf/httpd.conf



Now restart the Apache service 

        [root@localhost ~]# service httpd restart

        Stopping httpd:                                            [  OK  ]
        Starting httpd: httpd:                                    [  OK  ]
        [root@localhost ~]# 

Now we need to create ".htaccess" file under the folder ( /var/www/html/test ).

        [root@localhost ~]# vim  /var/www/html/test/.htaccess

        AuthName  "Caution! Authorized users only"
        Authtype  basic
        AuthUserFile  /etc/httpd/conf/passwd-test
        require  valid-user
            
                 "passwd-test"  is a file which will store the Passwords.

Now we will create passwd-test file using below command

         [root@localhost ~]#  htpasswd  -c  /etc/httpd/conf/passwd-test  manivel

New password: Re-type new password: Adding password for user manivel
 [root@localhost ~]#
 
-c  --> create new file
Manivel  --> username  ( based on system user)

passwd-test --> user name and password store file

If you want multiple user to access "test" directory you can create password using htpasswd command

         [root@localhost ~]#  htpasswd   /etc/httpd/conf/passwd-test  another-username
 
You can check user list 
         
         [root@localhost ~]#cat  /etc/httpd/conf/passwd-test
test:$apr1$yaW9ZSps$I9bCkCYgKhwkj1Lk0cD5s1
manivel:mX7oxMcGIoZdo
[root@localhost ~]#

Now we will check http://localhost/test  in browser. It will ask password prompt.

Saturday 19 January 2013

How to configure the Apache mod_rewrite module on Centos



"mod_rewrite" is an Apache module used to manipulate URL's and is compiled into the base Apache HTTP Server in CentOS. more details http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Open the Apache configuration file following location and modify

        [root@sysadmin]#  vim   /etc/httpd/conf/httpd.conf

Change "AllowOverride None "to "AllowOverride All"




save and close.

Now restart the service 

           [root@sysadmin]#  /etc/init.d/httpd   restart


That solve...

Sunday 6 January 2013

How to install Phpmyadmin on Centos

Phpmyadmin is a web interface through which you can manage your Mysql databases.
  

First we enable the EPEL repository on our centos system because phpMyAdmin is not available in the official CentOS repositories. EPEL link

Run the following yum install command

    
[root@sysadmin ~]#  yum   install  phpmyadmin

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections

    
[root@sysadmin ~]#  vim   /etc/httpd/conf.d/phpmyadmin.conf





Next we change the authentication in phpMyAdmin from cookie to http

    
[root@sysadmin ~]#   vim   /usr/share/phpmyadmin/config.inc.php




Restart Apache and Mysql service 

   [root@sysadmin ~]#   /etc/init.d/httpd   restart
   
[root@sysadmin ~]#   /etc/init.d/httpd   restart

Afterwards, you can access phpMyAdmin under http://10.102.152.198/phpmyadmin/