Friday, October 22, 2010

Steps to Install phpMyAdmin on Linux


Steps to Install phpMyAdmin on Linux

Do you have a MySQL database in your environment? Did you know that the easy (and most effective) way to manage MySQL database is using phpMyAdmin?
phpMyAdmin is a web-based tool written in PHP to manage the MySQL database. Apart from viewing the tables (and other db objects), you can perform lot of DBA functions through the web based interface. You can also execute any SQL query from the UI.
This article will provide step-by-step instructions on how to install and configure phpMyAdmin on Linux distributions.

1. phpMyAdmin Pre requisites

Make sure you have PHP 5 (or above) installed.
# php -v
PHP 5.3.2 (cli) (built: May 19 2010 03:43:49)
Make sure you have MySQL 5 (or above) installed.
# mysql -V
mysql  Ver 14.14 Distrib 5.1.47, for pc-linux-gnu (i686) using readline 5.1
Make sure Apache is installed and running.

PHP5 Modules

If you don’t have PHP, I recommend that you install PHP from source. Following is the configure command I executed while installing PHP from source. This includes all the required PHP modules for phpMyAdmin.
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-bz2 --with-zlib --enable-zip --enable-mbstring --with-mcrypt
If you don’t compile PHP5 with the above options, you’ll get following error message from phpMyAdmin web interface.
  • GZip – GZip compression and decompression requires functions (gzencode) which are unavailable on this system.
  • Bzip2 – Bzip2 compression and decompression requires functions (bzopen, bzcompress) which are unavailable on this system.
  • ZIP – Zip decompression requires functions (zip_open) which are unavailable on this system.
  • ZIP – Zip compression requires functions (gzcompress) which are unavailable on this system.

2. Download and Install phpmyadmin in Apache DocumentRoot

Identify your Apache’s DocumentRoot.
# grep DocumentRoot /usr/local/apache2/conf/httpd.conf
DocumentRoot /usr/local/apache2/htdocs
Download the latest version of phpMyAdmin. Currently the stable version of phpMyAdmin is 3.3.7
# cd /usr/local/apache2/htdocs

# tar xvfz phpMyAdmin-3.3.7-all-languages.tar.gz

# mv phpMyAdmin-3.3.7-all-languages phpmyadmin

3. Secure the phpmyadmin Directory – Create phpmy user

Create phpmy Unix user.
# adduser phpmy

# passwd phpmy
Check which user and group is used by Apache.
# egrep 'User|Group' /usr/local/apache2/conf/httpd.conf
User daemon
Group daemon
Modify the phpmyadmin directory’s user ownership to phpmy user.
# cd /usr/local/apache2/htdocs

# chown -R phpmy.daemon phpmyadmin/

4. Update phpMyAdmin config.inc from Wizard

You need to setup the config.inc file properly for phpMyAdmin to work. You can either create and edit this file manually, or use the config phpMyAdmin installer setup wizard. I recommend that you use the setup wizard, as it is very straight forward. To do that, you should create the following dummy config.inc with proper permission.
# cd /usr/local/apache2/htdocs/phpmyadmin/

# mkdir config

# chmod o+rw config

# cp config.sample.inc.php config/config.inc.php

# chmod o+w config/config.inc.php
Now, invoke the phpMyAdmin setup wizard from the browser using the URL: http://{your-ip-address}/phpmyadmin/setup/index.php . This will show the following setup wizard.
Fig: phpMyAdmin Setup Wizard
Click on “New Server”, which will display following server wizard.
Fig: phpMyAdmin Create New Server
Fill-out following information in the new server screen. Leave other fields to default values.
  • Verbose Name of the Server – Give some descriptive server name.
  • Password for Config Auth – Enter the MySQL root password here.
  • Authentication Type – The default selection is cookie. Just use that.
Click on Save to save the configuration. You might see following warning messages. Ignore it for now.
  • Use SSL – You should use SSL connections if your web server supports it
  • PHP extension to use – You should use mysqli for performance reasons
  • Blowfish secret – You didn’t have blowfish secret set and have enabled cookie authentication, so a key was automatically generated for you. It is used to encrypt cookies; you don’t need to remember it.

5. Launch phpmyadmin

Invoke phpMyAdmin from the browser using the URL: http://{your-ip-address}/phpmyadmin/index.php
If you’ve installed phpMyAdmin on a Linux desktop distribution, you can also access phpMyAdmin using the localhost URL: http://localhost/phpmyadmin/index.php
Login with your MySQL root password. i.e use “root” for phpmyadmin username. Use MySQL root’s password for phpmyadmin password.

If you see the “Cannot load mcrypt extension. Please check your PHP configuration.” message, you didn’t compile your PHP with mcrypt. Make sure you have libmcrypt and libmcrypt-devel packages installed on your Linux before you compile PHP with –with-mcrypt option.
You will also see the message : “Directory config, which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.”
Just like the message says, remove the config directory.
# cd /usr/local/apache2/htdocs/phpmyadmin

# rm -rf config
After moving the config directory, if you go to setup/index.php url, you’ll see following message. This is a good thing, as you’ve already configured the phpMyAdmin.
Cannot load or save configuration. Please create web server writable folder config in phpMyAdmin top level directory as described in documentation. Otherwise you will be only able to download or display it.”
Once you’ve logged-in you should be able to manage all the MySQL databases from your browser.


Fig: phpMyAdmin DB Structures

1 comment:

  1. Understand PHPMyAdmin MySQL Issues through MySQL Enterprise Backup
    Have you regularly defying PHPMyAdmin or MySQL related issues? In the event that yes, at that point what steps you are taking to dispose of this issue? The vast majority of the clients login with their username or secret word yet it appears to be nothing. Well! In the event that you are not ready to take care of this issue at that point contact to our specialists i.e. MySQL Remote Support or MySQL Remote Service. Here they give ensured best help and 100% investigate your issues. Aside from that issue they likewise comprehend your association related issues, establishment issues et cetera.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete