Enable SSL for Secure phpMyAdmin Access in VestaCP
By default, phpMyAdmin in VestaCP is accessible via HTTP, which is not secure. To prevent unauthorized access and data interception, it is important to enable SSL (HTTPS) for phpMyAdmin.
For phpMyAdmin in general (install, security, day-to-day use), see phpMyAdmin — Installation, Configuration & Usage. For the broader VestaCP context, see VestaCP Hosting — Everything You Need to Know and How to Install VestaCP on a VPS/Server.
Verify SSL Certificate
Before forcing SSL for phpMyAdmin, ensure that your domain has an SSL certificate installed. You can check if SSL is already enabled by running:
sudo ls /usr/local/vesta/ssl
If you see .crt and .key files, SSL is installed.
Edit the phpMyAdmin Nginx Configuration
- Open the configuration file for phpMyAdmin:
- Modify the configuration to force HTTPS:
- Find the HTTP (port 80) block and update it to redirect to HTTPS:
sudo nano /etc/nginx/conf.d/phpmyadmin.conf
server {
listen 80;
server_name your-domain.com;
return 301 https://your-domain.com$request_uri;
}
- Ensure your HTTPS (port 443) block contains the correct SSL paths:
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /usr/local/vesta/ssl/certificate.crt;
ssl_certificate_key /usr/local/vesta/ssl/certificate.key;
location /phpmyadmin {
alias /usr/share/phpMyAdmin;
index index.php;
include /etc/nginx/snippets/fastcgi-php.conf;
}
}
- Save and Exit (Press
Ctrl + X, thenY, thenEnter).
Restart Nginx to Apply Changes
After modifying the configuration, restart Nginx:
sudo systemctl restart nginx
Alternative: Use Let's Encrypt for Free SSL
If your domain does not have SSL enabled, you can install a free Let's Encrypt SSL for phpMyAdmin:
- Install Let's Encrypt:
- Generate SSL for phpMyAdmin subdomain:
- Verify SSL Installation:
- Update Nginx Config with Let's Encrypt SSL:
- Restart Nginx:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your-domain.com
sudo ls /etc/letsencrypt/live/your-domain.com/
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
sudo systemctl restart nginx
Secure phpMyAdmin Further
- Restrict Access by IP:
- Password Protect phpMyAdmin (Basic Authentication):
- Create a password file:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd admin - Modify the Nginx config:
- Disable Root Login for MySQL:
location /phpmyadmin {
allow 192.168.1.100;
deny all;
}
location /phpmyadmin {
auth_basic "Restricted Access";
auth_basic_user_file /etc/phpmyadmin/.htpasswd;
}
UPDATE mysql.user SET plugin = 'unix_socket' WHERE User = 'root';
FLUSH PRIVILEGES;
Verify SSL Access
- Open phpMyAdmin via:
https://your-domain.com/phpmyadmin
- Forces HTTPS for phpMyAdmin to prevent security risks.
- Uses Let's Encrypt for free SSL if needed.
- Secures phpMyAdmin with IP restrictions and authentication.


