Difference between revisions of "PhpMyAdmin"

From ArchWiki
Jump to navigation Jump to search
m (Fixed lighttpd alias url)
Line 159: Line 159:
The php setup for lighttpd is exactly the same as for apache.
The php setup for lighttpd is exactly the same as for apache.
Make an alias for phpmyadmin in your lighttpd config.
Make an alias for phpmyadmin in your lighttpd config.
   alias.url = ( "/phpmyadmin/" => "/usr/share/webapps/phpMyAdmin/")
   alias.url = ( "/phpmyadmin" => "/usr/share/webapps/phpMyAdmin/")
Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )
Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )

Revision as of 08:30, 5 March 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی


See LAMP for a guide to setting up Apache, MySQL, and PHP.


To install phpMyAdmin, install the phpmyadmin and php-mcrypt packages with

pacman -S phpmyadmin php-mcrypt


Ensure you do not have an older copy of phpMyAdmin.

rm -r /srv/http/phpMyAdmin

Copy the example configuration file to your httpd configuration directory.

cp /etc/webapps/phpmyadmin/apache.example.conf /etc/httpd/conf/extra/httpd-phpmyadmin.conf

Add the following lines to Template:Filename:

# phpMyAdmin configuration
Include conf/extra/httpd-phpmyadmin.conf

You can type this into the terminal to produce the same effect:

echo -e "\nInclude conf/extra/httpd-phpmyadmin.conf" >> /etc/httpd/conf/httpd.conf

Add the following lines to Template:Filename:

# Use for PHP 5.x:
LoadModule php5_module        modules/libphp5.so
AddHandler php5-script php

Add index.php after "DirectoryIndex index.html"

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html index.php

In Template:Filename, comment out deny from all. The line should look like this:

#deny from all

Otherwise you'll get an error similar to "Error 403 - Access forbidden!" when you attempt to access your phpMyAdmin installation.

Your Template:Filename should have the following information:

        Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
        <Directory "/usr/share/webapps/phpMyAdmin">
                AllowOverride All
                Options FollowSymlinks
                Order allow,deny
                Allow from all

Open your Template:Filename and go to the line containing open_basedir and add the path(s) to your phpMyAdmin installation so it has the following:


For example, mine contains the following:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/srv/:/usr/share/webapps/:/etc/webapps/

You need the mcrypt and mysql modules, so uncomment in Template:Filename:


Add blowfish_secret passphrase

If you see the following error message at the bottom of the page when you first log in to /phpmyadmin (using a previously setup MySQL username and password) :

ERROR: The configuration file now needs a secret passphrase (blowfish_secret)

You need to add a blowfish password to the phpMyAdmin's config file. Edit Template:Filename and insert a random blowfish "password" in the line

$cfg['blowfish_secret'] = ; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Go here to get a nicely generated blowfish_secret and paste it between the marks. It should now look something like this:

$cfg['blowfish_secret'] = 'qtdRoGmbc9{8IZr323xYcSN]0s)r$9b_JUnb{~Xz'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

The error should go away if you refresh the phpmyadmin page.

Accessing your phpMyAdmin installation

Finally your phpmyadmin installation is complete. Before start using it you need to restart your apache server by following command:

# /etc/rc.d/httpd restart

You can access your phpmyadmin installation using the following url:


Note: 'localhost' is the hostname in your /etc/rc.conf file.

If you want to access it using:


in '/etc/httpd/conf/extra/httpd-phpmyadmin.conf' change:

Alias /phpmyadmin/ "/usr/share/webapps/phpMyAdmin/"


Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"

You should also read this thread.

If you get the error "#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)" then you might want to change "localhost" in /etc/webapps/phpmyadmin/config.inc.php on this line:

$cfg['Servers'][$i]['host'] = 'localhost';

to your hostname specified in /etc/hosts and /etc/rc.conf under HOSTNAME.

If you would like to use phpmyadmin setup script by calling http://localhost/phpmyadmin/setup you will need to create a config directory that's writeable by the httpd in the /usr/share/webapps/phpmyadmin as follows:

cd /usr/share/webapps/phpMyAdmin
sudo mkdir config
sudo chgrp http config
sudo chmod g+w config

Lighttpd Configuration

The php setup for lighttpd is exactly the same as for apache. Make an alias for phpmyadmin in your lighttpd config.

 alias.url = ( "/phpmyadmin" => "/usr/share/webapps/phpMyAdmin/")

Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )

Update open_basedir in /etc/php/php.ini and add "/usr/share/webapps/".

 open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/

Make sure lighttpd is setup to serve php files, Lighttpd and FastCGI

Restart lighttpd and browse to http://localhost/phpmyadmin/index.php

NGINX Configuration

Also similar to apache configuration (and Lighttpd, for that matter).

Create a symbolic link to the /usr/share/webapps/phpmyadmin directory from whichever directory your vhost is serving files from, e.g. /srv/http/<domain>/public_html/

 sudo ln -s /usr/share/webapps/phpmyadmin /srv/http/<domain>/public_html/phpmyadmin

You can also setup a sub domain with a server block like so (if using php-fpm):

 server {
         server_name     phpmyadmin.<domain.tld>;
         access_log      /srv/http/<domain>/logs/phpmyadmin.access.log;
         error_log       /srv/http/<domain.tld>/logs/phpmyadmin.error.log;
         location / {
                 root    /srv/http/<domain.tld>/public_html/phpmyadmin;
                 index   index.html index.htm index.php;
         location ~ \.php$ {
                 root            /srv/http/<domain.tld>/public_html/phpmyadmin;
                 fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
                 fastcgi_index   index.php;
                 fastcgi_param   SCRIPT_FILENAME  /srv/http/<domain.tld>/public_html/phpmyadmin/$fastcgi_script_name;
                 include         fastcgi_params;

You may run into some issues with phpmyadmin telling you "The Configuration File Now Needs A Secret Passphrase" and no matter what you enter, the error is still displayed. Try changing the ownership of the files to the NGINX specified user/group, e.g. nginx...

 cd /usr/share/webapps/phpmyadmin
 sudo chown -R nginx:nginx *

While you can enter anything for the blowfish password, you may want to choose a randomly generated string of characters (most likely for security reasons). Here's a handy tool that will do that for you on the web[1].

Other (Older) information

This page holds a sample 'config.inc.php' file that you can place in the main phpMyAdmin directory so that it immediately starts working

Things you should do first

Create a 'controluser', so that phpmyadmin can read from the main mysql database.

mysql -u root -pYOURROOTPASSWORD
mysql> grant usage on mysql.* to controluser@localhost identified by 'CONTROLPASS';

Where is phpmyadmin

in phpmyadmin 3.2.2-3 the file is missing /srv/http/ create this symlik

ln -s /usr/share/webapps/phpMyAdmin/ /srv/http/phpmyadmin

Things you should change

controluser is set to controluser
controlpass is set to password
verbose is set to name_of_server

Sample 'config.inc.php' file

 * Generated configuration file
 * Generated by: phpMyAdmin setup script by Michal Čihař <michal@cihar.com>
 * Version: $Id: setup.php 11423 2008-07-24 17:26:05Z lem9 $
 * Date: Mon, 01 Sep 2008 20:34:02 GMT

/* Servers configuration */
$i = 0;

/* Server ravi-test-mysql (http) [1] */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['controluser'] = 'controluser';
$cfg['Servers'][$i]['controlpass'] = 'password';
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['verbose'] = 'name_of_server';

/* End of servers configuration */

$cfg['LeftFrameLight'] = true;
$cfg['LeftFrameDBTree'] = true;
$cfg['LeftFrameDBSeparator'] = '_';
$cfg['LeftFrameTableSeparator'] = '__';
$cfg['LeftFrameTableLevel'] = 1;
$cfg['LeftDisplayLogo'] = true;
$cfg['LeftDisplayServers'] = false;
$cfg['DisplayServersList'] = false;
$cfg['DisplayDatabasesList'] = 'auto';
$cfg['LeftPointerEnable'] = true;
$cfg['DefaultTabServer'] = 'main.php';
$cfg['DefaultTabDatabase'] = 'db_structure.php';
$cfg['DefaultTabTable'] = 'tbl_structure.php';
$cfg['LightTabs'] = false;
$cfg['ErrorIconic'] = true;
$cfg['MainPageIconic'] = true;
$cfg['ReplaceHelpImg'] = true;
$cfg['NavigationBarIconic'] = 'both';
$cfg['PropertiesIconic'] = 'both';
$cfg['BrowsePointerEnable'] = true;
$cfg['BrowseMarkerEnable'] = true;
$cfg['ModifyDeleteAtRight'] = false;
$cfg['ModifyDeleteAtLeft'] = true;
$cfg['RepeatCells'] = 100;
$cfg['DefaultDisplay'] = 'horizontal';
$cfg['TextareaCols'] = 40;
$cfg['TextareaRows'] = 7;
$cfg['LongtextDoubleTextarea'] = true;
$cfg['TextareaAutoSelect'] = false;
$cfg['CharEditing'] = 'input';
$cfg['CharTextareaCols'] = 40;
$cfg['CharTextareaRows'] = 2;
$cfg['CtrlArrowsMoving'] = true;
$cfg['DefaultPropDisplay'] = 'horizontal';
$cfg['InsertRows'] = 2;
$cfg['EditInWindow'] = true;
$cfg['QueryWindowHeight'] = 310;
$cfg['QueryWindowWidth'] = 550;
$cfg['QueryWindowDefTab'] = 'sql';
$cfg['ForceSSL'] = false;
$cfg['ShowPhpInfo'] = false;
$cfg['ShowChgPassword'] = false;
$cfg['AllowArbitraryServer'] = false;
$cfg['LoginCookieRecall'] = 'something';
$cfg['LoginCookieValidity'] = 1800;