≡ Menu

How To: 5 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

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Jim September 16, 2010, 12:39 pm

    Or if you using Ubuntu/Debian you can just type at the command prompt: #apt-get install phpmyadmin
    🙂

  • thaygiaoth September 19, 2010, 7:44 pm

    @Jim:
    if using apt-get install phpmyadmin, you can’t get latest phpmyadmin version. However it is simplest

  • Alexey January 23, 2011, 10:06 am

    Thank you very much! Very helpful.
    Good luck

  • tushar March 24, 2011, 1:04 am

    thanks a lot for this

  • kumar June 18, 2011, 6:56 am

    Hi, I followed your procedure to install phpMyAdmin in my laptop (Linux singh-VGN-CR35G-L 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux). Everything went well except the last part of invoking the setup wizard.

    First thing, I have tried this with localhost (also with my institutional IP address) but everytime I type it gives me “Not Found err” that index.php is not found on this server. I think there is a problem with my Apache installation.
    I then tried to restart my apache server in that too I got the following error:

    singh@singh-VGN-CR35G-L:/etc$ apache2ctl start
    (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    Action ‘start’ failed.
    The Apache error log may have more information.

    I installed Apache distribution yesterday…when I am cheking the server with index.html ..its working…but its not recognizing any PHP files or so…

    Could you help me here???

    Thanx

  • Fractal February 14, 2012, 3:01 pm

    It help me a lot. Thanks!

  • kamal April 30, 2012, 12:19 am

    Hi, I have tried the above steps to install phpmyadmin, however I am getting the below error while browsing http://localhost/phpmyadmin/setup/index.php

    Not Found

    The requested URL /phpmyadmin/setup/index.php was not found on this server.

    What could be the issue, is there anything i have to setup in apache conf file.

    Thanks in advance!!

  • kamal April 30, 2012, 12:31 am

    Hi all,

    I have done apache seeting under httpd.conf file as below mentioned and error get resolved.

    Order Allow,Deny
    Order allow,deny
    Allow from all

    Alias /phpmyadmin /usr/local/apache/htdocs/phpmyadmin
    Alias /phpMyAdmin /usr/local/apache/htdocs/phpmyadmin
    Alias /mysqladmin /usr/local/apache/htdocs/phpmyadmin

    Moreover, it has been worked but here it is showing some configuration part, how to get exarct phpmyadmin page

    Thanks

  • kamal May 1, 2012, 1:54 am

    Hi All,

    The issue got resolved automatically , I hv not done anything
    today just start my system started browsing http://myhostname/phpmyadmin and it work well.

    Thanks to all

  • Victor September 7, 2012, 4:08 am

    Hi,

    i have an amazon server, i already have one phpmyadmin install in that server but it was for website A, if i create a new website name it B that located in the same server, and i want to create a new phpmyadmin should i install phpmyadmin again? or I just can make a new login for website B?

    please help,

    thanks

  • Sonia November 19, 2013, 4:28 pm

    Thank you, it works great 🙂

  • Dip May 15, 2014, 3:19 am

    Ramesh, you saved my day. 🙂

  • Fowzia October 7, 2015, 4:22 pm

    I am using wembin version 1.760 OS Fedora Linux 22(64 bit). I installed phpMyAdmin-4.5.0.2-all-languages.tar.gz under /etc/ phpMyAdmin. After installation I did following:
    mkdir config

    # chmod o+rw config

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

    # chmod o+w config/config.inc.php

    But not able to, invoke the phpMyAdmin setup wizard from the browser using the URL: http://{your-ip-address}/phpmyadmin/setup/index.php . But not able to view the setup wizard. Do you know why?

  • Abhijeet February 17, 2016, 1:50 am

    Thanks for the solutions…. it works…