Adminer#

With adminer you can control various databases via a web UI. It is the successor of phpMyAdmin.

Docker#

See also

  • GitHub - vrana/adminer: Database management in a single PHP file [1]

  • GitHub - TimWolla/docker-adminer: Database management in a single PHP file [2]

  • GitHub - docker-library/official-images: Primary source of truth for the Docker “Official Images” program [3]

  1. follow the Docker instructions

  2. create the jobs directories

    mkdir -p /home/jobs/scripts/by-user/root/docker/adminer
    cd /home/jobs/scripts/by-user/root/docker/adminer
    
  3. create a Docker compose file

    /home/jobs/scripts/by-user/root/docker/adminer/docker-compose.yml#
    1version: '2.4'
    2
    3services:
    4  adminer:
    5    image: adminer:latest
    6    restart: always
    7    ports:
    8      - 127.0.0.1:4009:8080
    
  4. create a Systemd unit file. See also the Docker compose services section

    /home/jobs/services/by-user/root/docker-compose.adminer.service#
     1[Unit]
     2Requires=docker.service
     3Requires=network-online.target
     4After=docker.service
     5After=network-online.target
     6
     7## Run
     8## docker-compose up --detach --force-recreate
     9## to reload configuration.
    10
    11[Service]
    12# https://community.hetzner.com/tutorials/docker-compose-as-systemd-service
    13Type=simple
    14WorkingDirectory=/home/jobs/scripts/by-user/root/docker/adminer
    15
    16ExecStart=/usr/bin/docker-compose up --remove-orphans
    17ExecStop=/usr/bin/docker-compose down --remove-orphans
    18
    19Restart=always
    20
    21[Install]
    22WantedBy=multi-user.target
    
  5. fix the permissions

    chmod 700 /home/jobs/scripts/by-user/root/docker/adminer
    chmod 700 -R /home/jobs/services/by-user/root
    
  6. run the deploy script

  7. serve the files via HTTP by creating a new Apache virtual host. Replace FQDN with the appropriate domain and include this file from the Apache configuration

    /etc/apache2/adminer-docker.apache.conf#
     1###########
     2# adminer #
     3###########
     4<IfModule mod_ssl.c>
     5<VirtualHost *:80>
     6    ServerName ${FQDN}
     7
     8    # Force https.
     9    UseCanonicalName on
    10    RewriteEngine on
    11    RewriteCond %{SERVER_NAME} =${FQDN}
    12
    13    # Ignore rewrite rules for 127.0.0.1
    14    RewriteCond %{HTTP_HOST} !=127.0.0.1
    15    RewriteCond %{REMOTE_ADDR} !=127.0.0.1
    16
    17    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    18</VirtualHost>
    19</IfModule>
    20
    21<IfModule mod_ssl.c>
    22<VirtualHost *:443>
    23    UseCanonicalName on
    24
    25    Keepalive On
    26    RewriteEngine on
    27
    28    ServerName ${FQDN}
    29
    30    SSLCompression off
    31
    32    RequestHeader set X-Forwarded-Proto "https"
    33    RequestHeader set X-Forwarded-Port "443"
    34    RequestHeader set X-Forwarded-Host "${FQDN}"
    35
    36    <Proxy *>
    37        # Localhost.
    38        Require ip 127.0.0.1
    39
    40        # LAN.
    41        Require ip 192.168.0.
    42
    43        # Docker containers.
    44        Require ip 172.16.
    45    </Proxy>
    46
    47    ProxyPass / http://127.0.0.1:4009/
    48    ProxyPassReverse / http://127.0.0.1:4009/
    49
    50    Include /etc/letsencrypt/options-ssl-apache.conf
    51    SSLCertificateFile /etc/letsencrypt/live/${FQDN}/fullchain.pem
    52    SSLCertificateKeyFile /etc/letsencrypt/live/${FQDN}/privkey.pem
    53</VirtualHost>
    54</IfModule>
    
  8. restart Apache

    systemctl restart apache2.service
    

Bare metal#

  1. install the dependencies

    apt-get install adminer php7.4-fpm
    
  2. start and enable the php-fpm service

    systemctl enable --now php7.4-fpm.service
    
  3. enable the php7.4-fpm module for Apache

    a2enmod php7.4
    
  4. serve the files via HTTP by creating a new Apache virtual host. Replace FQDN with the appropriate domain and include this file from the Apache configuration

    /etc/apache2/adminer-bare_metal.apache.conf#
     1###########
     2# Adminer #
     3###########
     4<IfModule mod_ssl.c>
     5<VirtualHost *:80>
     6    ServerName ${FQND}
     7
     8    # Force https.
     9    UseCanonicalName on
    10    RewriteEngine on
    11    RewriteCond %{SERVER_NAME} =${FQDN}
    12
    13    # Ignore rewrite rules for 127.0.0.1
    14    RewriteCond %{HTTP_HOST} !=127.0.0.1
    15    RewriteCond %{REMOTE_ADDR} !=127.0.0.1
    16
    17    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    18</VirtualHost>
    19</IfModule>
    20
    21<IfModule mod_ssl.c>
    22<VirtualHost *:443>
    23    UseCanonicalName on
    24
    25    Keepalive On
    26    RewriteEngine on
    27
    28    ServerName ${FQDN}
    29
    30    SSLCompression off
    31
    32    Include conf-enabled/php7.4-fpm.conf
    33
    34    DocumentRoot "/usr/share/adminer/adminer/"
    35    <Directory "/usr/share/adminer/adminer/">
    36       AllowOverride All
    37       Options FollowSymlinks
    38       Require all granted
    39
    40       # You can restrict access to Adminer to LAN
    41       # or Docker containers only by adding this.
    42
    43       # Localhost.
    44       Require ip 127.0.0.1
    45
    46       # LAN.
    47       Require ip 192.168.0.
    48
    49       # Docker containers.
    50       Require ip 172.16.
    51   </Directory>
    52
    53    Include /etc/letsencrypt/options-ssl-apache.conf
    54    SSLCertificateFile /etc/letsencrypt/live/${FQDN}/fullchain.pem
    55    SSLCertificateKeyFile /etc/letsencrypt/live/${FQDN}/privkey.pem
    56</VirtualHost>
    57</IfModule>
    
  5. restart Apache

    systemctl restart apache2.service
    

Footnotes