35

I just finished setting up a default Linux EC2 instance and would like to install PHPMyAdmin. I already have Apache and MySQL installed but cannot seem to install PHPMyAdmin. I tried using

sudo apt-get phpmyadmin but the command apt-get is not recognized.

I also tried sudo yum install phpmyadmin but that I get the message No package phpmyadmin available.

Any suggestions on what I am doing wrong?

studiohack
  • 13,468
  • 19
  • 88
  • 118
David
  • 2,257
  • 8
  • 25
  • 26

12 Answers12

47

I found an easy solution here.

Do the following:

  1. Navigate to the apache folder

    cd /var/www/html
    
  2. Ensure ownership of the folder (assuming signed in with ec2-user)

    sudo chown ec2-user .
    
  3. Download phpMyAdmin

    wget https://files.phpmyadmin.net/phpMyAdmin/4.5.0.2/phpMyAdmin-4.5.0.2-all-languages.tar.bz2
    
  4. Unzip

    tar -jxf phpMyAdmin-4.5.0.2-all-languages.tar.bz2 -C /var/www/html
    
  5. Rename the folder

    mv phpMyAdmin-4.5.0.2-all-languages phpmyadmin
    
  6. Remove the zip file

    rm -rf phpMyAdmin-4.5.0.2-all-languages.tar.bz2
    

That's the basics. You can find more info in the link provided above.

Brett
  • 103
  • 3
David
  • 2,257
  • 8
  • 25
  • 26
  • You can find the latest version of phpMyAdmin here: [http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/](http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/) – jchavannes Sep 08 '13 at 00:33
  • 2
    the only additional step I had to take was updating the server host endpoint for my RDS database in /etc/phpMyAdmin/config.inc.php -- changing `$cfg['Servers'][$i]['host'] = 'localhost'` to `$cfg['Servers'][$i]['host'] = 'xxx.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com'` – Damion Hankejh Oct 09 '13 at 17:43
  • 1
    After installation, the phpmyadmin page is empty in my http://www.mywebsite.com/phpmyadmin. – Bagusflyer Mar 20 '14 at 08:18
  • After following all these steps, i'm not seeing phpMyAdmin. where do i find it? – Jeremy Moritz Jun 09 '16 at 16:21
  • See if this helps if you have an empty mywebsite.com/phpmyadmin: http://stackoverflow.com/a/29354629/1800854 – Mo Beigi Apr 21 '17 at 12:33
37

I know the question has more than one year, but was the first thing that popped up on google with "phpmyadmin ec2". Here is a better way to do things.

Knowing that you have yum, the best way to act is to install it by yum.

The easy way is to activate it just to install the packages you want, like phpMyAdmin or MongoDB. Eg.

sudo yum --enablerepo=epel install phpmyadmin

and it should work.

EDIT (comment by @eric-brotto):

It also should be noted that this comes with the advantage of uninstalling via

(sudo) yum erase phpmyadmin

Eric Brotto Jun 8 at 16:22

Note, that this would install phpmyadmin in /usr/share/phpmyadmin. To make it available in your web root, you would have to symlink it thus:

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

There are two ways to use EPEL, one is above, the other is to activate it permanently, editing the file /etc/yum.repos.d/epel.repo and where it says enabled=0 we change it to enabled=1, now you can sudo yum install phpmyadmin.

Here you can see a package list for the EPEL repo, too.

TJSoler
  • 471
  • 4
  • 4
  • I tried `yum` and can't get it to work. `EPEL` is too difficult. – David Sep 11 '12 at 16:01
  • What's too difficult? If you don't want to edit the config and want to keep the server as-is, just use `sudo yum --enablerepo=epel install whateveryouwant` at least on the ec2 machine i'm working (with the amazon base distribution) that works. – TJSoler Sep 13 '12 at 16:14
  • 4
    I don't think it gets any easier than this. The tl;dr? Just copy and pasted `yum --enablerepo=epel install phpmyadmin` – Tuanderful Oct 12 '12 at 07:43
  • 2
    There are many answers on the web stating how to use yum to install phpmyadmin. None of them worked for me. This one does. A million up votes be showered unto thy! – Eric Brotto Jun 08 '13 at 16:18
  • 3
    It also should be noted that this comes with the advantage of uninstalling via `yum erase phpmyadmin`. – Eric Brotto Jun 08 '13 at 16:22
  • This is the one that worked for me. – Nitzan Wilnai Dec 22 '14 at 17:29
  • 1
    Rats. It's all installed. I've created the symbolic link. I've restarted the server but all I get is: *You don't have permission to access /phpmyadmin on this server.* – Django Reinhardt Feb 04 '15 at 15:01
  • There is no need to create the symlink. The package comes with a nice apache alias config. The access is by default restricted to 127.0.0.1. You can easily change the directives to allow access. – Broncha Feb 11 '15 at 08:06
  • 1
    For me, it's `/usr/share/phpMyAdmin` instead of `/usr/share/phpmyadmin`. That's **`phpMyAdmin`** with capital `M` and `A`. – Pang Mar 20 '15 at 03:03
  • 1
    not working for me.You don't have permission to access /phpmyadmin on this server. – urfusion Apr 27 '15 at 12:13
  • For permissions fixing follow this http://stackoverflow.com/questions/23704674/phpmyadmin-allow-remote-users – vsingh Oct 24 '15 at 16:43
  • 1
    I guess a downside to this approach though is that you might not get the most up-to-date version. When I yum installed, it gave me **phpMyAdmin 4.0.10.12** even though it seems **4.5.4.1** is the latest version (as of right now) . Still a nice approach though, thanks – D.Tate Feb 15 '16 at 17:41
  • I struggled with the config - it was a version of phpmyadmin I had never used, and it kept telling me the passwords were insecure - anyone could change them. – brianlmerritt Feb 25 '16 at 18:11
  • Rather than cluttering up your web dir with a symbolic link, another way would be to create a `phpmyadmin.conf` file in your Apache's conf.d directory and add an Alias, such as `Alias /phpMyAdmin /usr/share/phpMyAdmin` ... Also, I'll note that this method doesn't work with the php7 line, the epel repo lists php56 as a dependency, even though phpmyadmin currently supports versions 5.5 to 7.2 – Typel Sep 20 '18 at 22:58
  • Doesn't work for me on Amazon Linux 2. It seems there are 2 dependencies missing for `php-tidy`. `Package: php-tidy-5.4.16-9.el7.aarch64 (epel) Requires: php(api) = 20100412-64 Installed: php-common-8.0.2-1.amzn2.aarch64 (@amzn2extra-php8.0)'. Also `Requires: php(zend-abi) = 20100525-64 Installed: php-common-8.0.2-1.amzn2.aarch64 (@amzn2extra-php8.0)`. I tried "skip-broken", but then got a bunch more dependency problems. – Buttle Butkus May 07 '21 at 01:55
7

First add the repository, then install:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
sudo rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm 
sudo yum install phpmyadmin 

This works fine on a standart 32bits amazon instance

Simon Sheehan
  • 9,114
  • 12
  • 52
  • 71
Manuel
  • 71
  • 1
  • 1
  • Also working well on 64bit amazon linux. This is may be better for some users then the "accepted" answer as it resolves the dependencies faster then doing a manual install. – Nir Levy Feb 08 '12 at 15:34
  • 3
    note that you'll need to supplement this install with "ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin" – Nir Levy Feb 08 '12 at 15:36
1

Note that if, after using any of the above methods to install phpMyAdmin, the phpMyAdmin page is empty in example.com/phpmyadmin, then you probably need to edit httpd.conf to allow overrides in the web directory, e.g.:

sudo nano /etc/httpd/conf/httpd.conf
  1. Find <Directory "/var/www/html">
  2. Replace AllowOverride none with AllowOverride all
  3. Save changes and exit
  4. Restart Apache server

    sudo service httpd restart
    
random
  • 14,638
  • 9
  • 54
  • 58
Deborah Cole
  • 111
  • 1
1

I don't have permissions to comment, so as a separate answer.

1) Check what LINUX you have

rpm -q centos-release
lsb_release -a
uname -m

2) Check the correct rpm distribution release for you

http://pkgs.repoforge.org/rpmforge-release/

3) Add that distribution

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
sudo rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm 

4) Install the application

sudo yum install phpmyadmin 
ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin
vim /usr/share/phpmyadmin/config.inc.php

5) Create permissions to MySQL if necessary (replace pmapass with your own password!)

GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
GRANT SELECT (
    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
    Execute_priv, Repl_slave_priv, Repl_client_priv
) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
    ON mysql.tables_priv TO 'pma'@'localhost';
0

The latest version of the micro server does not include EPEL rep. The following installs it:

sudo yum install -y epel-release

then you can run:

sudo yum --enablerepo=epel install phpmyadmin

monkia
  • 1
0

I know this is an old question but it came up in Google and the above answer didn't do it for my freshly installed EC2 Linux (June 2017). You don't need to do any of the sym linkage mentioned in other answers, the install makes an apache config file for the phpmyadmin installation automatically, you just need to remove the localhost security restriction, then restart httpd.

If you want a quick copy and paste to get it working in 2017:

sudo yum --enablerepo=epel install phpmyadmin

Edit the httpd config file which was created by the phpmyadmin yum installation:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Comment out this section near the top of the file, it is restricting access to localhost (and you're connecting over the internet not locally):

<Directory /usr/share/phpMyAdmin/>
#<IfModule mod_authz_core.c>
  #Apache 2.4
# <RequireAny>
#   Require ip 127.0.0.1
#   Require ip ::1
# </RequireAny>
#</IfModule>   
#  <IfModule !mod_authz_core.c>
    #Apache 2.2
#    Order Deny,Allow
#    Deny from All
#    Allow from 127.0.0.1
#    Allow from ::1
#  </IfModule>
</Directory>

Restart Apache to pickup the changes.

sudo service httpd restart

In your browser you can now access at /phpmyadmin

As a side point, in the config file you edit if you wanted to change the address you can access phpmyadmin at, at the top you will see Alias lines, set them as you desire.

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

example:

Alias /pma /usr/share/phpMyAdmin
Joeme
  • 101
  • 3
0

If this is a basic Amazon Linux AMI install, then consider it similar to CentOS 6.x (no systemd). Amazon has its own repository, which does not have phpmyadmin in it.

Therefore you need to:

  • install epel repository
  • enable epel repository
  • install phpmyadmin
  • configure phpmyadmin

Here goes:

yum install epel-release

yum-config-manager --enable epel

yum install phpmyadmin

Edit the file /etc/httpd/conf.d/phpMyAdmin.conf and replace 127.0.0.1 with the ip address you are using.

nano /etc/httpd/conf.d/phpMyAdmin.conf

Restart the web server

service httpd restart

jeffmcneill
  • 274
  • 4
  • 10
0

Install using yum and epl repo Please make sure to install epel using amazon linux extras

sudo amazon-linux-extras install epel -y

And then install using

yum install phpmyadmin

Alternatively you could choose to install using composer

composer create-project phpmyadmin/phpmyadmin

It is always better to install int outside document root and point using a separate virtual host.

Below virtual host could be a ref. if you choose /var/www

Sample virtual host entry to install outside web root

Alias /phpMyAdmin /var/www/phpmyadmin
Alias /phpmyadmin /var/www/phpmyadmin
    

<Directory /var/www/phpmyadmin/>
    Options none
    AllowOverride Limit
    Require all granted
</Directory>

<Directory /var/www/phpmyadmin/>
    Options none
    AllowOverride Limit
    Require all granted
</Directory>

<Directory /var/www/phpmyadmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /var/www/phpmyadmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /var/www/phpmyadmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>
Nafsin Vk
  • 111
  • 2
0

The package is called phpMyAdmin. You may need to enable EPEL first.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247
0

As of 13th December 2012, this works fine on an EC2 server:

sudo apt-get install phpmyadmin

No other steps necessary, assuming you have PHP, MySQL and Apache all set up.

Ben
  • 141
  • 2
  • 7
-1
sudo apt-get install phpmyadmin

once you have installed it, you must make a symbolic link (like a redirect) using

sudo ln -s /usr/share/phpmyadmin /var/www

to open (change your IP) http://XXX.XXX.XXX.XXX/phpmyadmin

you MIGHT see an error missing mcrypt. i couldnt solve, but it didnt get in the way.

for logging in user is "root" and the password is the one that you created during the phpmyadmin install

adapted from this tutorial

tony gil
  • 223
  • 1
  • 2
  • 11