User Agents

Web browsers and everyday web tech, explained

How to Change phpMyAdmin Access URL (Apache & Nginx)

· 5 min read · How the Web Works

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide explains how to change the URL used to access phpMyAdmin on your server, which improves security by hiding the default /phpmyadmin path. You'll learn how to rename the alias in Apache and Nginx, and how to verify the change works. You'll need SSH (or cPanel file manager) access to your server and the ability to edit configuration files.

What You'll Need

  • SSH access to your server (or cPanel/control panel file manager)
  • Text editor (nano, vim, or a local editor like Notepad++)
  • Basic familiarity with the command line
  • Root or sudo privileges (for system-wide config changes)

Step-by-Step

For Apache (most common)

  1. Locate the phpMyAdmin configuration file. On Debian/Ubuntu systems, it's usually /etc/phpmyadmin/apache.conf. On CentOS/RHEL, it's often /etc/httpd/conf.d/phpMyAdmin.conf. If you installed from source, the file may be in your Apache config directory.
  2. Back up the configuration file. Run: sudo cp /etc/phpmyadmin/apache.conf /etc/phpmyadmin/apache.conf.bak (adjust the path as needed).
  3. Open the file in a text editor. For example: sudo nano /etc/phpmyadmin/apache.conf
  4. Find the Alias directive. Look for a line like Alias /phpmyadmin /usr/share/phpmyadmin. The first part after Alias is the URL path.
  5. Change the alias path. Replace /phpmyadmin with your desired URL, e.g., /my-secret-admin. The line becomes Alias /my-secret-admin /usr/share/phpmyadmin.
  6. Check for other references. If there are blocks that reference the old path, update them too. For example, change to (though usually the directory path stays the same, only the alias changes).
  7. Save and close the file. In nano, press Ctrl+O, then Ctrl+X.
  8. Test the configuration. Run sudo apachectl configtest or sudo httpd -t to check for syntax errors.
  9. Reload Apache. Run sudo systemctl reload apache2 (Debian/Ubuntu) or sudo systemctl reload httpd (CentOS/RHEL).

For Nginx

  1. Locate your Nginx configuration. It's usually in /etc/nginx/sites-available/ or /etc/nginx/conf.d/. The relevant file is the one for your site (e.g., default or example.com).
  2. Back up the configuration. sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
  3. Open the file. sudo nano /etc/nginx/sites-available/default
  4. Find the location block for phpMyAdmin. Look for something like location /phpmyadmin { ... } or a rewrite rule that points to phpMyAdmin.
  5. Change the location path. Replace /phpmyadmin with your new path, e.g., location /my-secret-admin { ... }. Also update any alias or root directives inside that block if they reference the old path.
  6. Save and close the file.
  7. Test the configuration. Run sudo nginx -t.
  8. Reload Nginx. Run sudo systemctl reload nginx.

After the change

  1. Clear your browser cache or use a private/incognito window to avoid cached redirects.
  2. Access phpMyAdmin via the new URL. For example, https://yourdomain.com/my-secret-admin.
  3. Update any bookmarks or scripts that reference the old URL.

Common Mistakes

  • Forgetting to update the block in Apache. If you change only the Alias but not the Directory path, you may get a 403 error because the directory access rules still apply to the old path.
  • Using a path that conflicts with existing files. If you choose a URL that already exists (e.g., /admin), you may get a conflict or unintended behavior.
  • Not testing the configuration before reloading. A syntax error can bring down your web server.
  • Changing the wrong file. On systems with multiple config files, you might edit a file that isn't actually loaded. Always check with apachectl -S or nginx -T to see which files are in use.
  • Not clearing browser cache. You might still see the old URL working due to caching, leading to confusion.

Tips

  • Choose a long, random path (e.g., /a1b2c3d4e5) instead of something guessable like /admin or /db.
  • Combine this with other security measures: use a strong password, enable two-factor authentication if your setup supports it, and restrict access by IP if possible.
  • If you use a control panel like cPanel, there may be a built-in option to change the phpMyAdmin URL—check the documentation first, as manual edits may be overwritten.
  • After changing, update any automated backups or monitoring scripts that reference the old URL.
  • Consider using a separate subdomain or a dedicated port for extra obscurity, but be aware that this can complicate SSL setup.

Troubleshooting

  • You get a 404 Not Found error. This usually means the alias/location wasn't changed correctly or the server wasn't reloaded. Re-check the config file and reload the server again.
  • You get a 403 Forbidden error. This often indicates a Directory permission issue in Apache. Make sure the block matches the new alias path and that the directory has the correct permissions (typically 755 for directories and 644 for files).
  • You get a 500 Internal Server Error. This could be a syntax error in the config. Run apachectl configtest or nginx -t to see the exact error message.
  • The old URL still works. This might be due to browser caching or a redirect. Try a different browser or clear cache. Also, ensure no other config file is overriding your changes.
  • After changing, phpMyAdmin loads but shows errors (e.g., missing CSS). This can happen if the base URL is hardcoded in some files. Check the phpMyAdmin configuration (config.inc.php) for any $cfg['PmaAbsoluteUri'] setting and update it to the new URL.
  • You can't find the config file. Use find / -name '*phpmyadmin*' 2>/dev/null to locate it, or check your web server's configuration with apachectl -S or nginx -T to see which files are included.

Frequently Asked Questions

Is changing the URL enough to secure phpMyAdmin?

No. While it reduces automated attacks, it's not a substitute for strong passwords, IP restrictions, or keeping phpMyAdmin updated. Think of it as one layer of security.

Will this break my existing sessions or cookies?

Usually not, but users who are logged in may need to log in again. The session cookie is tied to the domain, not the path, so it should still work.

Can I change the URL back if I forget the new one?

Yes, you can edit the config file again and revert to the original path. If you forget the new path, you can always check the config file.

Does this work on shared hosting?

It depends. On shared hosting, you may not have access to the server config. Many hosts provide a way to change the phpMyAdmin URL via the control panel—check your host's documentation.

What if I use both Apache and Nginx as a reverse proxy?

You need to change the alias/location in both configurations. The Nginx config typically proxies requests to Apache, so the path must match in both.

Will this affect other applications that use phpMyAdmin?

Only if those applications have hardcoded links to the old URL. Most apps use relative links, so they should work fine. If you use a CMS that integrates with phpMyAdmin, you may need to update its settings.