How to install phpmyadmin on nginx on centos 6

Phpmyadmin is a free tool used to administrate MySQL . it supports all major operation with MySQL in GUI mode.
In the previous post we saw about installing and configuring nginx on centos 6.5 . Here we can see about installing phpmyadmin on nginx server.
Before starting please make sure you have installed LEMP stack ( Nginx , mysql and php )
Refer this post (Install LEMP on centos 6)

Install phpmyadmin on nginx on centos 6.5

Step 1 » Enable EPEL repository for installing dependencies . Find the latest release file from EPEL 6 repository and install using rpm command.
[root@krizna ~]# rpm -ivh http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
Step 2 » Install dependencies by the below command.
[root@krizna ~]# yum install php php-cli php-gd php-mbstring php-mcrypt php-php-gettext apr-util-ldap mailcap
Step 3 » Download latest phpmyadmin from official site ( Phpmyadmin Download ) to /usr/share/ directory. choose .tar.bz2 for less size and easy extraction with default tar command.
[root@krizna ~]# cd /usr/share/
[root@krizna share]# wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.1.7/phpMyAdmin-4.1.7-all-languages.tar.bz2

Step 4 » Extract the files using the below command.
[root@krizna share]# tar -xvf phpMyAdmin-4.1.7-all-languages.tar.bz2
Step 5 » Rename the folder .
[root@krizna share]# mv phpMyAdmin-4.1.7-all-languages phpmyadmin
Step 6 » Create a config file inside phpmyadmin folder. just copy config.sample.inc.php into config.inc.php file .
[root@krizna phpmyadmin]# cp config.sample.inc.php config.inc.php
Step 7 » Create a virtual site to access phpmyadmin in 8080 port . Create a file /etc/nginx/conf.d/phpmyadmin.conf and add the below lines .

server {
    listen       8080;                          # listen port
    server_name  localhost;                     # Server name (www.krizna.com)
    location / {
        root   /usr/share/phpmyadmin;           # Document root
        index index.php  index.html index.htm;
    }
    location ~ .php$ {
        root           /usr/share/phpmyadmin;   # Document root
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Step 8 » Restart nginx service.
[root@krizna ~]# service nginx restart
Open /etc/sysconfig/iptables file and add the following line to open port 8080 in iptables.
-A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
Step 9 » Now open http://serverip:8080 in your browser . you could see phpmyadmin login page . use mysql root username and password to login . after logged in, you can see the page below.
phpmyadmin-on-nginx-on-centos
All the best.

15 Comments

  1. I followed your instructions but it failed, it shows me the following error when I type localhost:8080 on my browser:Cannot start session without errors, please check errors given in your
    PHP and/or webserver log file and configure your PHP installation
    properly. Also ensure that cookies are enabled in your browser.

  2. I followed your instructions but it failed, it shows me the following error when I type localhost:8080 on my browser:Cannot start session without errors, please check errors given in your
    PHP and/or webserver log file and configure your PHP installation
    properly. Also ensure that cookies are enabled in your browser.

1 Trackback / Pingback

  1. さくらのVPSにCent OS/ Nginx / Mysql / PHP の環境を構築 | 千葉県柏市のホームページ制作会社-株式会社Circle

Leave a Reply

Your email address will not be published.


*