After ISPC update, PHPMyAdmin results in 404

Discussion in 'General' started by schwim, Jun 9, 2025.

  1. schwim

    schwim Member HowtoForge Supporter

  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    What error do you get when the page opens? Are you sure you've setup the hostname correctly? The link through the panel will try to open the phpmyadmin page with the hostname of the panel. If you reach your panel only with the IP in the URL then this link will not work.
     
  3. schwim

    schwim Member HowtoForge Supporter

    Sorry if I've not explained it well, this server has been up and running for years and
    phpma has worked without issue until this last update. hostname is set correctly and everything else works(ISPC admin, webmail, etc.)

    When visiting the PHPMA URL with either the domain or IP, this is the result:

     
  4. pyte

    pyte Well-Known Member HowtoForge Supporter

    Ok, you should check if the config /etc/apache2/conf-enabled/phpmyadmin.conf is present. And check if phpmyadmin is still installed. The files should be located at /usr/share/phpmyadmin.
     
  5. schwim

    schwim Member HowtoForge Supporter

    The conf file is there but the directory is missing under/usr/share.

    Should I just install phpmyadmin through apt or does a particular copy need to be installed for use with ISPC?
     
  6. pyte

    pyte Well-Known Member HowtoForge Supporter

    I don't know why it is gone in your installation. Usually the ISPConfig Installer grabs the latest release from the upstream repository, installs that manually and then creates a cron job to auto update it. Do you have the cronjob at /etc/cron.daily/auto_update_phpmyadmin?

    I think you can just manually install phpmyadmin and should be good to go. Make sure to not install it with your package manager. If you have access to the ISPConfig git you could just follow the steps the official installer does when you install ISPConfig. https://git.ispconfig.org/ispconfig...ISPConfigDebianOS.inc.php?ref_type=heads#L244
     
  7. schwim

    schwim Member HowtoForge Supporter

    the auto_update_phpmyadmin file does exist.

    I'm not sure I'm savvy enough to figure out what the install script is doing. Would forcing an update of ISPC reinstall it correctly?
     
  8. pyte

    pyte Well-Known Member HowtoForge Supporter

    Ok that's good to know. I don't think that would do anything related to phpmyadmin. I can have a look into it tomorrow and write up the exact steps you need to take to reinstall phpmyadmin correctly.
     
    till likes this.
  9. schwim

    schwim Member HowtoForge Supporter

    I'm aok to wait until tomorrow, that would be very helpful if you could do that, thank you so much!
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    I doubt that the ISPConfig update removed phpmyadmin, there is no code in ISPConfig to do that. So something else must have happened that removed phpmyadmin.
     
  11. schwim

    schwim Member HowtoForge Supporter

    Other than running the update script, I've done nothing to the system aside from using the panel to manage users and accessing phpmyadmin.

    I of course can't say what happened to cause it but I definitely need it ;)
     
  12. pyte

    pyte Well-Known Member HowtoForge Supporter

    Hi,

    i think this should do the trick in your case. That should be everything neccessary to make phpmyadmin work on your system again. I skipped the step where the apache conf sets created, as you mentioned it is already there and i also skipped the step for the cronjob for the same reason aswell. Good Luck!
    1. Create necessary directories for phpMyAdmin
    2. Change permissions on those directories
    3. Create an empty htpasswd file
    4. Change ownership to www-data
    5. Download the phpMyAdmin version 5.2.2 from the official website
    6. Extract the archive and copy its contents into /usr/share/phpmyadmin
    7. Remove the downloaded archive file and directory
    8. Copy the sample phpMyAdmin config file to it's correct location
    9. Generate a random 32-character blowfish secret and update the config
    10. Set the TempDir configuration
    11. Generate a new random 15-character password for the MySQL pma user.
    12. Update the pma@localhost user password with the newly generated password in database
    13. Correctly setup the servers config in the config file for phpMyAdmin
    14. Update phpMyAdmin configuration settings (controlhost, controlport, controluser, controlpass) with values reflecting localhost and the new password

    Code:
    #!/bin/bash
    set -e
    
    # Exit if not run as root
    if [[ "$EUID" -ne 0 ]]; then
      echo "This script must be run with sudo or as root." >&2
      exit 1
    fi
    
    # Create directory
    mkdir -p /usr/share/phpmyadmin
    chmod 0755 /usr/share/phpmyadmin
    
    mkdir -p /etc/phpmyadmin
    chmod 0755 /etc/phpmyadmin
    
    mkdir -p /var/lib/phpmyadmin/tmp
    chmod 0770 /var/lib/phpmyadmin/tmp
    
    # Create htpasswd
    touch /etc/phpmyadmin/htpasswd.setup
    
    # Change ownership
    chown -R www-data:www-data /var/lib/phpmyadmin
    
    # Download and install
    cd /tmp
    wget https://files.phpmyadmin.net/phpMyAdmin/5.2.2/phpMyAdmin-5.2.2-all-languages.tar.gz
    tar xfz phpMyAdmin-5.2.2-all-languages.tar.gz
    cp -a phpMyAdmin-5.2.2-all-languages/* /usr/share/phpmyadmin/
    rm phpMyAdmin-5.2.2-all-languages.tar.gz
    rm -rf /tmp/phpMyAdmin-5.2.2-all-languages
    
    # Copy sample and set blowfish secret and tmp dir
    cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
    
    BLOWFISH_SECRET=$(head -c 64 /dev/urandom | sha1sum | cut -c1-32)
    
    sed -i -E "s|^(//\s*)?\s*\$cfg\['blowfish_secret'\]\s*=.*$|\$cfg['blowfish_secret'] = '$BLOWFISH_SECRET';|" /usr/share/phpmyadmin/config.inc.php
    sed -i -E "s|^(//\s*)?\s*\$cfg\['TempDir'\]\s*=.*$|\$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';|" /usr/share/phpmyadmin/config.inc.php
    
    # Overwrite the PMA Password
    PMA_PASS=$(head -c 32 /dev/urandom | tr -dc 'A-Za-z0-9' | head -c15)
    
    # Escape single quotes and backslashes for SQL
    PMA_PASS_ESCAPED=$(echo "$PMA_PASS" | sed "s/[\'\\\\]/\\\\&/g")
    
    mysql -u root -p -e "
    ALTER USER 'pma'@'localhost' IDENTIFIED BY '$PMA_PASS_ESCAPED';
    FLUSH PRIVILEGES;
    "
    
    CONFIG_FILE="/usr/share/phpmyadmin/config.inc.php"
    
    # Uncomment any lines that start the server config block
    sed -i -E "s|^(\s*)//\s*(\$cfg\['Servers'\]\[\$i\])|\1\2|" "$CONFIG_FILE"
    # Replace controlhost
    sed -i -E "s|^(//\s*)?\s*(\$cfg\['Servers'\]\[\$i\]\['controlhost'\])\s*=.*$|\2 = 'localhost';|" "$CONFIG_FILE"
    # Replace controlport
    sed -i -E "s|^(//\s*)?\s*(\$cfg\['Servers'\]\[\$i\]\['controlport'\])\s*=.*$|\2 = '';|" "$CONFIG_FILE"
    # Replace controluser
    sed -i -E "s|^(//\s*)?\s*(\$cfg\['Servers'\]\[\$i\]\['controluser'\])\s*=.*$|\2 = 'pma';|" "$CONFIG_FILE"
    # Replace controlpass
    sed -i -E "s|^(//\s*)?\s*(\$cfg\['Servers'\]\[\$i\]\['controlpass'\])\s*=.*$|\2 = '$PMA_PASS_ESCAPED';|" "$CONFIG_FILE"
     
    till likes this.
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Hi @pyte , thanks a lot for writing this down. Maybe we should also put this in the Tips & Tricks forum?
     
  14. pyte

    pyte Well-Known Member HowtoForge Supporter

    Sure why not. But we should explictly mention that the parts for creating the cronjob, initial phpmyadmin database setup and apache config are missing tho.
     
    till likes this.
  15. schwim

    schwim Member HowtoForge Supporter

    Thank you so much for your help!

    I am running the script and it's asking for a password after downloading the package. Which password should I be entering here? PHPMyAdmin user or MySQL root?
    Code:
    root@system:/usr# ./phpma.sh
    --2025-06-10 07:19:20--  https://files.phpmyadmin.net/phpMyAdmin/5.2.2/phpMyAdmin-5.2.2-all-languages.tar.gz
    Resolving files.phpmyadmin.net (files.phpmyadmin.net)... 89.187.180.101, 89.187.180.92, 2a02:6ea0:c600::25, ...
    Connecting to files.phpmyadmin.net (files.phpmyadmin.net)|89.187.180.101|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 13764534 (13M) [application/octet-stream]
    Saving to: ‘phpMyAdmin-5.2.2-all-languages.tar.gz’
    
    phpMyAdmin-5.2.2-al 100%[===================>]  13.13M  87.4MB/s    in 0.2s   
    
    2025-06-10 07:19:24 (87.4 MB/s) - ‘phpMyAdmin-5.2.2-all-languages.tar.gz’ saved [13764534/13764534]
    
    Enter password: 
    
     
  16. pyte

    pyte Well-Known Member HowtoForge Supporter

    Oh sorry. Yea it's asking for the mysql root password. If you ran the script with sudo rights/as root you should be able to just hit enter.
     
  17. schwim

    schwim Member HowtoForge Supporter

    Thank you again so much for your help, it's up and running again! Can I send you a tip somehow? You definitely didn't have to help the way you did.
     
    pyte likes this.
  18. pyte

    pyte Well-Known Member HowtoForge Supporter

    Im honored but i don’t need a tip. If you'd like, you are very welcome to support the ISPConfig team instead :)
     
    schwim likes this.

Share This Page