Wednesday, March 28, 2012

HOW TO Install phpMyAdmin in CentOS

I am using CentOS 5 in one of my Virtual Servers and I wanted it to have phpMyAdmin. I tried installing it by doing yum install phpmyadmin but it said No package phpmyadmin available. So I add to add a repo. I discovered that rpmforge repo had this package. To add it, I executed the following commands:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.i386.rpm
If you have 64-bit version installed, you should try this one out:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
If you get a 404 Not Found, then you will need to figure out the latest updated version of repo url from rpmforge usage page.
After that, you may like to update your packages by doing this:
yum update
and then continue installing phpmyadmin
yum install phpmyadmin
It should ask you for confirmation and you can continue installing phpMyAdmin with dependencies.
When installation is done, you can edit /etc/httpd/conf.d/phpmyadmin.conf and allow it to be opened from anywhere and not just the same computer. You are going to need this if you have installed it in a remote virtual server.
To do so, open up /etc/httpd/conf.d/phpmyadmin.conf using:
nano /etc/httpd/conf.d/phpmyadmin.conf
You will see:
<Directory "/usr/share/phpmyadmin">
  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1
</Directory>
Just change the line “Allow from 127.0.0.1″ to “Allow from [yourip]“, where [yourip] is IP address of your computer if you have public static IP. Otherwise, you can also set it to “Allow from all”.
Press Ctrl+O followed by Enter to save and Ctrl+X to exit nano.
Now, you must restart apache. To do so, run
service httpd restart
Now, you can access phpMyAdmin by visiting http://vps_server_IP_or_domain/phpmyadmin. But you will get the following error:
Error
The configuration file now needs a secret passphrase (blowfish_secret).
To make it work, you will need to edit config.inc.php. To do so, type in:
nano /usr/share/phpmyadmin/config.inc.php
Find a line saying:
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS
FOR
COOKIE AUTH! */
Fill in any secret keyword there, eg mysecretpassphrase, so that it looks like:
$cfg['blowfish_secret'] = 'mysecretpassphrase'; /* YOU MUST FILL IN THIS
FOR
COOKIE AUTH! */
and then save it.
If you don’t have mysql server installed, you will get the following error:
Error
#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)
To install mysql-server, just run:
yum install mysql-server
and then start it:
service mysqld start
Then change the root password:
mysqladmin -u root password PASSWORD_HERE
Now, you will have to remove phpmyadmin:
yum remove phpmyadmin
and reinstall it again:
yum install phpmyadmin
Then you will need to edit the config.inc.php again to enter blowfish secret (see above). Then, you can login.
If however, you want phpMyAdmin to connect to a remote server, you can change the line by replacing localhost with your server IP:
$cfg['Servers'][$i]['host'] = 'localhost';
Hope this helps.

how to fix : No activity within 1800 seconds; please log in again

1800 seconds is such a long time, right?
  1. It’s 30 minutes.
  2. It’s 0.5 hours.
  3. It’s 0.0208333333 days.
  4. It’s also 5.70397764 × 10-5 years.
And it’s not long enough for me. phpMyAdmin logs you out after 1800 seconds, obviously for security reasons. That’s fine if there are other people about, if I was in an office with people coming and going, but I work from home. All I see for most of the day is my family, the radio, my messy desk, computers, and the view out the window. Time to figure out how to make that 1800 second limit a little longer or remove it altogether.
After a little digging, I discovered that extending the time limit to a day is actually quite easy. Open your phpMyAdmin’s config.inc.php and search for or add the following line:
$cfg['LoginCookieValidity'] = 86400;
Refresh your logged out phpMyAdmin and presuming you haven’t left it idle for 24 hours, you’ll be logged in again!
If the time limit really bugs you, you need http authentication. Look for the “auth_type” line in the config.inc.php and change that to “http”. phpMyAdmin won’t log you out as long as your browser is open. Perfect!
If you’re concerned about sending your MySQL username and password in the clear each time you make a request to phpMyAdmin you can either use SSL or try the “config” auth_type. Make sure you fill in the username and password fields in the config file, and secure the phpMyAdmin directory with a htpasswd file.

How to Install php-mcrypt on CentOS 6.2

Symptoms :
This error appeared when i try to use phpmyadmin on authentication type as cookie. mcrypt is necessary if you want to use cookie based authentication with phpymyadmin.
The mcrypt exension is missing. Please check your PHP configuration.
mcrypt
To install php-mcrypt on CentOS 6.2, follow the following steps :
1. Download epel repository :
[root@centos62 ~]# [root@centos62 ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
[root@centos62 ~]# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
2. Install epel repository :
[root@centos62 ~]# rpm --import RPM-GPG-KEY-EPEL-6
[root@centos62 ~]# rpm -i epel-release-6-5.noarch.rpm
3. Simply run the following command to install php-mcrypt :
[root@centos62 ~]# yum install php-mcrypt -y

How to check CentOS version via command line?

Via command line, type this:
cat /etc/redhat-release
To safely upgrade CentOS to the latest version, type this:
yum update