How to install PHPMyAdmin on Linux EC2 instance?

82

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

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
    

Solution 5

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';
Share:
82
Milkncookiez
Author by

Milkncookiez

Updated on September 18, 2022

Comments

  • Milkncookiez
    Milkncookiez over 1 year
    1452 Cannot add or update a child row: a foreign key constraint fails (`bpr`.`trips`, CONSTRAINT `trips_driver_user_id_foreign` FOREIGN KEY (`driver_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE)
    

    is the error.

    Adding a row, manually, through MySQL works fine. If I do it through my application - nope.

    The id that I am trying to insert is correct (it exists and is an integer). I checked the foreign keys and stuff, everything looks fine. I don't know what the problem might be...

    Some code:

     $input = Input::all();
    
     Trip::create([
                    'route_from'       => $input['route_from'],
                    'route_to'         => $input['route_to'],
                    ... adding other stuff ...
                    'driver_user_id'   => Auth::user()->id
                ]);
    

    When I var_dump(Auth::user()->id) I do get correct int number, which is the correctly corresponding ID of the certain user.

    in the Trip model:

    protected $hidden = [
        'id'
    ];
    protected $fillable = [
        'route_from',
        'route_to',
        ... 
        'driver_user_id'
    ];
    public function Trip()
    {
        return $this->belongsTo('User', 'driver_user_id', 'id');
    }
    

    in the User model:

    public function Trips()
    {
        return $this->hasMany('Trip');
    }
    
    • Admin
      Admin about 9 years
      Can we see code? Or what framework you're using etc, just a little more info
    • Milkncookiez
      Milkncookiez about 9 years
      @IkoTikashi - done. :)
    • Admin
      Admin about 9 years
      Take a look here, hope it helps: stackoverflow.com/questions/20705539/…
    • Milkncookiez
      Milkncookiez about 9 years
      @IkoTikashi - This does not really help me. I already have the row of the certain user, created in the DB, before trying to insert the row for trip and link it to a user. Otherwise I wouldn't be able to get its id from Auth::.
    • Admin
      Admin about 9 years
      Sorry, should've read more thoroughly. I can't help you here, sorry :(
  • David
    David almost 13 years
    Can you provide more clarification? How do I go about enabling EPEL?
  • David
    David almost 13 years
    That looks way too difficult just to install phpMyAdmin. See my answer for a better solution.
  • David
    David over 11 years
    I tried yum and can't get it to work. EPEL is too difficult.
  • TJSoler
    TJSoler over 11 years
    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.
  • Tuanderful
    Tuanderful over 11 years
    I don't think it gets any easier than this. The tl;dr? Just copy and pasted yum --enablerepo=epel install phpmyadmin
  • Nick F
    Nick F almost 11 years
    The question specifically says that apt-get is not available.
  • Eric Brotto
    Eric Brotto almost 11 years
    It also should be noted that this comes with the advantage of uninstalling via yum erase phpmyadmin.
  • jchavannes
    jchavannes over 10 years
    You can find the latest version of phpMyAdmin here: http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/
  • zhongzhu
    zhongzhu over 10 years
    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'
  • Happy Coder
    Happy Coder almost 10 years
    How can I access it through web browser once installed ?
  • Django Reinhardt
    Django Reinhardt over 9 years
    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.
  • Nadav Kiani
    Nadav Kiani over 9 years
    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.
  • Milkncookiez
    Milkncookiez about 9 years
    Okay, that worked! Can you elaborate a bit, please, what was the problem with the trip being guarded? Do I necessarily need to unguard the whole Trip object, because it has the id field in it.. and it is sensitive data? Could I put the driver_user_id field in hidden, because it's sensitive data? And what was going on in general in this situation? Thanks in advance!
  • Luceos
    Luceos about 9 years
    Well you've used $fillable to make attributes accessible (see laravel.com/docs/5.0/eloquent). However knowing from past experience it seems to misbehave. So I always instantiate the object first, unguard, fill, reguard and save.. Also unguarding only seems effective on the current object level.
  • Luceos
    Luceos about 9 years
    Upon further inspection of the code, your object is not totally guarded otherwise a MassAssignmentException. What exact version of laravel are you using?
  • Milkncookiez
    Milkncookiez about 9 years
    I am using 4.2 version.
  • Milkncookiez
    Milkncookiez about 9 years
    I found this: ...if fillable is not specified, and the key is not listed in the guarded property, the framework will assume that the key can be safely mass-assigned. Sound perfectly fine and should be expected, but when we include a property that is not a field of the table, it will cause an error, because the framework will try to insert a data into a column that doesn’t exists. in here: hndr.me/blog/… Was helpful. :)
  • Luceos
    Luceos about 9 years
    That is not related. Could you please post the whole $fillable and $guarded arrays and your table layout? It might be that you are trying to assign a value to a property that is not fillable or is guarded.
  • Pang
    Pang about 9 years
    For me, it's /usr/share/phpMyAdmin instead of /usr/share/phpmyadmin. That's phpMyAdmin with capital M and A.
  • urfusion
    urfusion about 9 years
    not working for me.You don't have permission to access /phpmyadmin on this server.
  • vsingh
    vsingh over 8 years
    For permissions fixing follow this stackoverflow.com/questions/23704674/…
  • D.Tate
    D.Tate over 8 years
    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
  • brianlmerritt
    brianlmerritt about 8 years
    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.
  • Jeremy Moritz
    Jeremy Moritz almost 8 years
    After following all these steps, i'm not seeing phpMyAdmin. where do i find it?
  • Mo Beigi
    Mo Beigi about 7 years
    See if this helps if you have an empty mywebsite.com/phpmyadmin: stackoverflow.com/a/29354629/1800854
  • digout
    digout almost 6 years
    /etc/httpd/conf.d/phpMyAdmin.conf is not there. System wide search couldn't find it
  • Typel
    Typel over 5 years
    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
  • Buttle Butkus
    Buttle Butkus about 3 years
    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.