Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dos's avatar
Level 2

Trying to install phpMyAdmin on Forge/Digital Ocean

Hi all,

I am a Forge user and have one droplet on Digital Ocean on which I run two websites, both are currently in development.

I need an efficient way to access my production database on Digital Ocean. As I have worked with phpMyAdmin for years this seemed like the obvious choice.

I found these instructions and tried to follow them. https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04-server

I added a comment on that thread, perhaps the Laravel community might be more informed on this particular case though, my comment was:

When I tried installing phpMyAdmin an error message appeared stating the following:

[ERROR] mysql: Empty value for 'port' specified.

A snapshot of my terminal window can be seen here: https://img42.com/ATelX

I opened the phpmyadmin.conf file and could see that the port was indeed empty, I tried manually changing that to 3306 but that didn't work.

Since then I have tried uninstalling and reinstalling phpMyAdmin but the uninstall of the phpMyAdmin database failed, I am not sure if that is important.

In addition I was not able to run 'service php5-fpm restart', The error message was 'php5-fpm: unrecognized service.

Any advice would be welcome!

Regards, David

0 likes
9 replies
noeldiaz's avatar

@dos well for your second thing you don't have php 5 installed, you have 7. So the correct command would be:

sudo service php7.0-fpm restart

Now for your first thing, it could be that MySQL is only listening to localhost and binding to it and thus will not allow you to just connect locally to it. That would be in your /etc/mysql/my.cnf. Might need to adjust your bind setting and restart.

Also, if you want something easier to install, I'm a big fan of Adminer [https://www.adminer.org]. One file and you are good to go with full compliment of options.

1 like
dos's avatar
Level 2

Thank you for taking the time to reply @noeldiaz, those are three VERY useful comments! I'll be trying out all three as soon as I get back to my laptop!

dos's avatar
Level 2

Hi again @noeldiaz

Using the following

sudo service php7.0-fpm restart

did indeed work, thank you for that. However as there were steps previous to that which are still failing I have still not been able to get phpMyAdmin running.

So, as you suggested, I decided to use Adminer instead. I agree that a more light-weight approach is better. I found the following installation instructions (it wasn't clear from https://www.adminer.org/ how to install that single PHP file).

sudo mkdir /usr/share/adminer
sudo wget "http://www.adminer.org/latest.php" -O /usr/share/adminer/latest.php
sudo ln -s /usr/share/adminer/latest.php /usr/share/adminer/adminer.php
echo "Alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf
sudo a2enconf adminer.conf
sudo service apache2 restart

(Those instructions come fro https://www.leaseweb.com/labs/2014/06/install-adminer-manually-ubuntu-14-04/ )

That all seemed to work fine but as that approach uses apache I ran into problems.

When I tried to open Adminer in the browser using my-ip-address/adminer.php, I saw a message stating "No input file specified.". Some Googling informed me that this is likely because Apache is not running.

On my server I can see that nginx is running and apache2 is not running. (Is is even possible for both to run at the same time? Sorry if that is a stupid question, its not a situation I have encountered before!?).

To get Apache to run I edited /etc/apache2/apache2.conf and added 'ServerName localhost' at the bottom of the file, I also changed the port from 80 to 81 to avoid clashes.

Trying again in the browser using this adjusted uri:

my-ip-address:81/adminer.php 

I now see this error:

This site can’t be reached
46.101.153.109 took too long to respond.
ERR_CONNECTION_TIMED_OUT

Maybe I should not use that approach to install Adminer, maybe there is a different way to install it and use nginx to serve it?

There is probably a really simple solution to this that I am missing. Any ideas?

David

noeldiaz's avatar
Level 23

@dos Yeah, forge uses nginx for web server. I would not recommend running both apache and nginx, mostly since you will only be able to run one on port 80.

But you know, here's an alternative. I take it you already have a laravel site on forge right? And probably under nginx already? If so do this. Go into the "public" folder of the laravel site and create a new folder in there to hold the adminer php file. So line make a folder called "adminer" under public, place the file in there, and rename it to "index.php". Then, after you go into that file and fill in the settings, you will be able to access it as:

http://yoursite.com/adminer/

Anything inside the "public" dir gets processed as-is. So this works. Just tried it on one of my sites.

That's a quick and dirty way to get it up without having to mess with your webserver. The correct way, if you want it separate, it to set up another site under nginx and point it to a directory with the adminer file. I would also choose a more cryptic name for the directory so it is harder to find, and maybe even look into htpasswd authentication or IP based blocks on that directory.

But this should get you going.

1 like
dos's avatar
Level 2

You did it again @noeldiaz ! :)

Problem solved. Your suggestion to place Adminer inside my existing Laravel project worked a treat.

For anyone who wants to follow Noel's idea here is what I did:

forge@myserver:~ cd my-laravel-website
forge@myserver:~ cd public
forge@myserver:~ mkdir adminer
forge@myserver:~ cd adminer
forge@myserver:~ sudo wget "http://www.adminer.org/latest.php" -O index.php

Many thanks for this, it's a great idea.

David

1 like
gauravmak's avatar

The following link helps for the htpasswd protection: https://www.designstring.com/protect-your-website-with-password-on-nginx-ubuntu-16-04/

Steps:

1 - sudo sh -c "echo -n 'john:' >> /etc/nginx/.htpasswd"

Where john is the username.

2 - sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"

And specify the password.

3 - Set nginx config. Example:

    location /adminer {
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }

4 - Restart nginx - sudo service nginx restart

1 like
kemweb's avatar

Login to your Server with SSH (User: forge und your Public Key), then:

sudo apt-get update
sudo apt-get install phpmyadmin
sudo service php7.2-fpm restart
cd /home/forge/default/public
sudo ln -s /usr/share/phpmyadmin

Then you can access PhpMyAdmin via:

http://IP-Adress/phpmyadmin

1 like

Please or to participate in this conversation.