🗄️ phpMyAdmin Installation & Configuration

Complete Guide for LAMP/LEMP Stack - by Claude

What is phpMyAdmin?

phpMyAdmin is a free, open-source web-based administration tool for MySQL and MariaDB databases. It provides a user-friendly graphical interface for managing databases, tables, users, and permissions without needing to write SQL commands directly. It's an essential tool for database administrators and developers working with MySQL/MariaDB.

1. Prerequisites

Before installing phpMyAdmin, you need a working LAMP or LEMP stack:

Required Components:

  • Web Server: Apache or Nginx
  • Database: MySQL 5.5+ or MariaDB 5.5+
  • PHP: PHP 7.2+ (PHP 8.0+ recommended)
  • PHP Extensions: mysqli, mbstring, zip, gd, json, curl

Check Current Installation:

# Check Apache/Nginx
systemctl status apache2  # Ubuntu/Debian
systemctl status httpd     # RHEL/CentOS
systemctl status nginx     # Nginx

# Check MySQL/MariaDB
systemctl status mysql     # Ubuntu/Debian
systemctl status mariadb   # Most systems

# Check PHP version
php -v

# Check PHP extensions
php -m | grep -E 'mysqli|mbstring|zip|gd|json|curl'
Important: If any required components are missing, install your LAMP/LEMP stack first before proceeding with phpMyAdmin installation.

2. Installation on Ubuntu/Debian

Method 1: Using APT (Recommended for Beginners)

Step 1: Update Package Index

sudo apt update

Step 2: Install phpMyAdmin

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
During Installation: You'll be prompted with configuration questions:
  • Web server: Select apache2 (use spacebar to select, then Enter)
  • Configure database: Select Yes
  • Password: Enter a strong password for phpMyAdmin's database user

Step 3: Enable PHP Extensions

sudo phpenmod mbstring
sudo systemctl restart apache2

Step 4: Verify Installation

Access phpMyAdmin at: http://your-server-ip/phpmyadmin

Success! If you see the phpMyAdmin login page, installation was successful.

For Nginx Users on Ubuntu/Debian:

If using Nginx instead of Apache, additional configuration is needed:

Step 1: Install phpMyAdmin without web server selection

# During installation, do NOT select a web server
sudo apt install phpmyadmin

Step 2: Create Symbolic Link

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

Step 3: Configure Nginx

sudo nano /etc/nginx/sites-available/default

Add this location block inside the server block:

location /phpmyadmin {
    root /usr/share/;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+\.php)$ {
        try_files $uri =404;
        root /usr/share/;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;  # Adjust PHP version
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
        root /usr/share/;
    }
}

location /phpMyAdmin {
    rewrite ^/* /phpmyadmin last;
}

Step 4: Test and Restart Nginx

sudo nginx -t
sudo systemctl restart nginx

3. Installation on RHEL/CentOS/Rocky Linux

Method 1: Using DNF/YUM with EPEL

Step 1: Enable EPEL Repository

# RHEL/CentOS 8/9 / Rocky Linux
sudo dnf install epel-release
sudo dnf update

# RHEL/CentOS 7
sudo yum install epel-release
sudo yum update

Step 2: Install phpMyAdmin

# RHEL 8/9 / Rocky Linux
sudo dnf install phpmyadmin

# RHEL/CentOS 7
sudo yum install phpmyadmin

Step 3: Configure Apache Access

Edit the phpMyAdmin Apache configuration:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Find the section with "Require ip" and add your IP address or network:

# Change from:
Require ip 127.0.0.1
Require ip ::1

# To allow from anywhere (INSECURE - see security section):
Require all granted

# Or allow specific IP:
Require ip 127.0.0.1
Require ip ::1
Require ip YOUR.IP.ADDRESS.HERE
Require ip YOUR.NETWORK/24

Step 4: Restart Apache

sudo systemctl restart httpd

Step 5: Configure SELinux (if enabled)

# Check if SELinux is enforcing
getenforce

# If enforcing, run these commands:
sudo setsebool -P httpd_can_network_connect_db 1
sudo chcon -R -t httpd_sys_rw_content_t /usr/share/phpMyAdmin/

Step 6: Configure Firewall

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Access phpMyAdmin: http://your-server-ip/phpmyadmin

4. Manual Installation (All Distributions)

Manual installation gives you the latest version and more control over the installation process.

Step 1: Download phpMyAdmin

# Download latest version
cd /tmp
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

# Or download specific version (example: 5.2.1)
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.tar.gz

Step 2: Verify Download (Optional but Recommended)

# Download signature
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz.asc

# Import phpMyAdmin signing key
gpg --keyserver keyserver.ubuntu.com --recv-keys 3D06A59ECE730EB71B511C17CE752F178259BD92

# Verify signature
gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc phpMyAdmin-latest-all-languages.tar.gz

Step 3: Extract and Move to Web Directory

# Extract
tar xvf phpMyAdmin-*.tar.gz

# Move to web directory
sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin

# Create symbolic link (Apache)
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

# For Nginx:
sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html/phpmyadmin

Step 4: Create Configuration File

sudo mkdir /usr/share/phpmyadmin/tmp
sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
sudo nano /usr/share/phpmyadmin/config.inc.php

Generate a random blowfish secret:

# Generate 32-character random string
openssl rand -base64 32

Add to config.inc.php:

$cfg['blowfish_secret'] = 'PASTE_YOUR_32_CHARACTER_SECRET_HERE';
$cfg['TempDir'] = '/usr/share/phpmyadmin/tmp';

Step 5: Set Permissions

# For Apache on Ubuntu/Debian
sudo chown -R www-data:www-data /usr/share/phpmyadmin

# For Apache on RHEL/CentOS
sudo chown -R apache:apache /usr/share/phpmyadmin

# For Nginx
sudo chown -R nginx:nginx /usr/share/phpmyadmin

# Set proper permissions
sudo chmod 755 /usr/share/phpmyadmin
sudo chmod 660 /usr/share/phpmyadmin/config.inc.php

Step 6: Create phpMyAdmin Database

sudo mysql -u root -p < /usr/share/phpmyadmin/sql/create_tables.sql
Note: This creates the configuration storage database which enables advanced features like bookmarks, user preferences, and more.

5. Configuration

Basic Configuration File (config.inc.php)

The main configuration file is located at:

  • Ubuntu/Debian: /etc/phpmyadmin/config.inc.php
  • RHEL/CentOS: /etc/phpMyAdmin/config.inc.php
  • Manual Install: /usr/share/phpmyadmin/config.inc.php

Essential Configuration Options:

1. Blowfish Secret (Required)

$cfg['blowfish_secret'] = 'your-32-character-random-string';

2. Authentication Type

// Cookie authentication (recommended)
$cfg['Servers'][$i]['auth_type'] = 'cookie';

// HTTP authentication
$cfg['Servers'][$i]['auth_type'] = 'http';

// Config authentication (stores password in config - NOT RECOMMENDED)
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your-password';

3. Host Configuration

$cfg['Servers'][$i]['host'] = 'localhost';  // Database server
$cfg['Servers'][$i]['port'] = '3306';       // MySQL port
$cfg['Servers'][$i]['socket'] = '';         // Unix socket path (if not using TCP)

4. Enable Advanced Features

// Configuration storage database
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

5. Temp Directory

$cfg['TempDir'] = '/usr/share/phpmyadmin/tmp';  // or '/var/lib/phpmyadmin/tmp'

6. Upload/Save Directories

$cfg['UploadDir'] = '/usr/share/phpmyadmin/upload';
$cfg['SaveDir'] = '/usr/share/phpmyadmin/save';

Create Required Directories:

sudo mkdir -p /usr/share/phpmyadmin/tmp
sudo mkdir -p /usr/share/phpmyadmin/upload
sudo mkdir -p /usr/share/phpmyadmin/save
sudo chown -R www-data:www-data /usr/share/phpmyadmin/{tmp,upload,save}  # Ubuntu/Debian
sudo chown -R apache:apache /usr/share/phpmyadmin/{tmp,upload,save}      # RHEL/CentOS
sudo chmod 700 /usr/share/phpmyadmin/{tmp,upload,save}

Additional Useful Settings:

// Increase PHP upload limit
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

// Session timeout (in seconds)
$cfg['LoginCookieValidity'] = 3600;  // 1 hour

// Maximum number of rows to display
$cfg['MaxRows'] = 50;

// Show phpMyAdmin version
$cfg['ShowPhpInfo'] = false;  // Set to true if needed

// Allow login without password (NOT RECOMMENDED)
$cfg['AllowNoPassword'] = false;

// Hide databases from users
$cfg['Servers'][$i]['hide_db'] = '^(information_schema|performance_schema|mysql|sys)$';

6. Security Hardening

Critical: phpMyAdmin is a common target for attacks. Follow ALL security recommendations!

1. Change Default URL

Don't use /phpmyadmin. Use a custom, hard-to-guess URL:

For Apache:

# Create alias
sudo nano /etc/apache2/conf-available/phpmyadmin.conf  # Ubuntu/Debian
# Or
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf            # RHEL/CentOS

# Add:
Alias /mysecretdbadmin /usr/share/phpmyadmin

sudo systemctl restart apache2  # or httpd

For Nginx:

# Move the directory
sudo mv /usr/share/nginx/html/phpmyadmin /usr/share/nginx/html/mysecretdbadmin

# Update Nginx config
location /mysecretdbadmin {
    # ... rest of config
}

2. Restrict Access by IP

Apache (.htaccess method):

sudo nano /usr/share/phpmyadmin/.htaccess

# Add:
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from YOUR.IP.ADDRESS
Allow from YOUR.NETWORK/24

Apache (VirtualHost method):

<Directory /usr/share/phpmyadmin>
    Require ip 127.0.0.1
    Require ip YOUR.IP.ADDRESS
    Require ip YOUR.NETWORK/24
</Directory>

Nginx:

location /phpmyadmin {
    allow 127.0.0.1;
    allow YOUR.IP.ADDRESS;
    allow YOUR.NETWORK/24;
    deny all;
    
    # ... rest of config
}

3. Add HTTP Authentication

Create Password File:

sudo htpasswd -c /etc/phpmyadmin/.htpasswd admin

For Apache:

sudo nano /usr/share/phpmyadmin/.htaccess

# Add:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

For Nginx:

location /phpmyadmin {
    auth_basic "Restricted Access";
    auth_basic_user_file /etc/phpmyadmin/.htpasswd;
    
    # ... rest of config
}

4. Disable Root Login

# Create a separate admin user instead
mysql -u root -p

CREATE USER 'phpmyadmin_admin'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin_admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Then in config.inc.php:

$cfg['Servers'][$i]['AllowRoot'] = false;

5. Limit Login Attempts

In config.inc.php:

$cfg['LoginCookieValidity'] = 3600;  // Session timeout
$cfg['LoginCookieDeleteAll'] = true; // Delete all cookies on logout

6. Disable Certain Features

// Disable showing MySQL version
$cfg['ShowPhpInfo'] = false;
$cfg['ShowServerInfo'] = false;

// Disable imports from /etc
$cfg['ImportLinksDisabled'] = true;

// Disable arbitrary server connection
$cfg['AllowArbitraryServer'] = false;

7. Set Proper File Permissions

# Configuration file should NOT be writable by web server
sudo chmod 640 /usr/share/phpmyadmin/config.inc.php
sudo chown root:www-data /usr/share/phpmyadmin/config.inc.php  # Ubuntu/Debian
sudo chown root:apache /usr/share/phpmyadmin/config.inc.php    # RHEL/CentOS

8. Use Fail2Ban

# Install fail2ban
sudo apt install fail2ban  # Ubuntu/Debian
sudo dnf install fail2ban  # RHEL/Rocky

# Create phpMyAdmin jail
sudo nano /etc/fail2ban/jail.local

# Add:
[phpmyadmin]
enabled = true
port = http,https
filter = phpmyadmin
logpath = /var/log/apache2/error.log  # Or nginx error log
maxretry = 3
bantime = 3600

# Create filter
sudo nano /etc/fail2ban/filter.d/phpmyadmin.conf

# Add:
[Definition]
failregex = ^<HOST> .* "(GET|POST) .*/phpmyadmin/.*" 401
ignoreregex =

# Restart fail2ban
sudo systemctl restart fail2ban

9. Keep phpMyAdmin Updated

# For package installations
sudo apt update && sudo apt upgrade phpmyadmin  # Ubuntu/Debian
sudo dnf update phpmyadmin                      # RHEL/Rocky

# For manual installations
# Download and install new version, then:
sudo cp /usr/share/phpmyadmin/config.inc.php /usr/share/phpmyadmin.backup/
# Install new version
sudo cp /usr/share/phpmyadmin.backup/config.inc.php /usr/share/phpmyadmin/

7. SSL/HTTPS Setup

Important: Never use phpMyAdmin over plain HTTP in production! Always use HTTPS.

Option 1: Let's Encrypt (Recommended)

Install Certbot:

# Ubuntu/Debian
sudo apt install certbot python3-certbot-apache  # For Apache
sudo apt install certbot python3-certbot-nginx   # For Nginx

# RHEL/Rocky
sudo dnf install certbot python3-certbot-apache  # For Apache
sudo dnf install certbot python3-certbot-nginx   # For Nginx

Get Certificate:

# For Apache
sudo certbot --apache -d yourdomain.com

# For Nginx
sudo certbot --nginx -d yourdomain.com

Auto-Renewal:

# Test auto-renewal
sudo certbot renew --dry-run

# Certbot automatically adds cron/systemd timer for renewal

Option 2: Self-Signed Certificate (Testing Only)

Generate Certificate:

sudo mkdir /etc/ssl/private
sudo chmod 700 /etc/ssl/private
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/ssl/private/selfsigned.key \
    -out /etc/ssl/certs/selfsigned.crt

For Apache:

sudo nano /etc/apache2/sites-available/default-ssl.conf

# Add:
<VirtualHost *:443>
    ServerName yourdomain.com
    DocumentRoot /var/www/html
    
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/selfsigned.key
    
    <Directory /usr/share/phpmyadmin>
        AllowOverride All
    </Directory>
</VirtualHost>

# Enable SSL module and site
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo systemctl restart apache2

For Nginx:

sudo nano /etc/nginx/sites-available/default

# Modify server block:
server {
    listen 443 ssl;
    server_name yourdomain.com;
    
    ssl_certificate /etc/ssl/certs/selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/selfsigned.key;
    
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    
    # ... rest of configuration
}

sudo nginx -t
sudo systemctl restart nginx

Force HTTPS Redirect:

Apache:

# In .htaccess or VirtualHost
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Nginx:

server {
    listen 80;
    server_name yourdomain.com;
    return 301 https://$server_name$request_uri;
}

8. Troubleshooting

Common Issues and Solutions:

1. "The $cfg['TempDir'] is not accessible"

# Create and set permissions
sudo mkdir -p /usr/share/phpmyadmin/tmp
sudo chown www-data:www-data /usr/share/phpmyadmin/tmp  # Ubuntu/Debian
sudo chown apache:apache /usr/share/phpmyadmin/tmp      # RHEL/CentOS
sudo chmod 700 /usr/share/phpmyadmin/tmp

# Add to config.inc.php
$cfg['TempDir'] = '/usr/share/phpmyadmin/tmp';

2. "The phpMyAdmin configuration storage is not completely configured"

# Import configuration tables
sudo mysql -u root -p < /usr/share/phpmyadmin/sql/create_tables.sql

# Verify tables were created
mysql -u root -p
USE phpmyadmin;
SHOW TABLES;
EXIT;

3. "mysqli extension is missing"

# Ubuntu/Debian
sudo apt install php-mysqli
sudo systemctl restart apache2

# RHEL/CentOS
sudo dnf install php-mysqlnd
sudo systemctl restart httpd

4. "Session not created" or "Session expired"

# Check session directory permissions
ls -ld /var/lib/php/sessions  # or /var/lib/php/session

# Fix permissions
sudo chown -R www-data:www-data /var/lib/php/sessions  # Ubuntu/Debian
sudo chown -R apache:apache /var/lib/php/sessions      # RHEL/CentOS

# In php.ini, ensure:
session.save_path = "/var/lib/php/sessions"
session.gc_maxlifetime = 1440

5. 404 Not Found Error

# For Apache - enable phpMyAdmin conf
sudo a2enconf phpmyadmin
sudo systemctl reload apache2

# Check symbolic link
ls -la /var/www/html/ | grep phpmyadmin

# Recreate if needed
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

6. "Access denied for user" Errors

# Check MySQL/MariaDB user
mysql -u root -p

SELECT User, Host FROM mysql.user;

# Grant privileges if needed
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
EXIT;

7. Blank Page / White Screen

# Enable PHP error display temporarily
sudo nano /etc/php/*/apache2/php.ini  # Adjust PHP version

# Change:
display_errors = On
error_reporting = E_ALL

# Check PHP error log
sudo tail -f /var/log/apache2/error.log     # Ubuntu/Debian
sudo tail -f /var/log/httpd/error_log       # RHEL/CentOS
sudo tail -f /var/log/nginx/error.log       # Nginx

# Check PHP-FPM log (if using FPM)
sudo tail -f /var/log/php*-fpm.log

8. "Cannot start session without errors"

# Clear session files
sudo rm -rf /var/lib/php/sessions/sess_*

# Restart web server
sudo systemctl restart apache2  # or httpd or nginx

9. Upload Errors (File too large)

# Edit php.ini
sudo nano /etc/php/*/apache2/php.ini  # Adjust path

# Change these values:
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300

# Restart web server
sudo systemctl restart apache2

Checking Logs:

# Apache logs
sudo tail -f /var/log/apache2/access.log
sudo tail -f /var/log/apache2/error.log

# Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log

# MySQL/MariaDB logs
sudo tail -f /var/log/mysql/error.log

# PHP-FPM logs (if applicable)
sudo tail -f /var/log/php8.1-fpm.log

Testing Configuration:

# Test Apache configuration
sudo apache2ctl configtest

# Test Nginx configuration
sudo nginx -t

# Check phpMyAdmin config
php -l /usr/share/phpmyadmin/config.inc.php

9. Maintenance & Updates

Regular Maintenance Tasks:

1. Keep phpMyAdmin Updated

# Package installations
sudo apt update && sudo apt upgrade phpmyadmin  # Ubuntu/Debian
sudo dnf update phpmyadmin                      # RHEL/Rocky

# Manual installations
# 1. Backup current installation
sudo cp -r /usr/share/phpmyadmin /usr/share/phpmyadmin.backup

# 2. Download new version
cd /tmp
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

# 3. Extract and replace
tar xvf phpMyAdmin-*.tar.gz
sudo rm -rf /usr/share/phpmyadmin/*
sudo mv phpMyAdmin-*/* /usr/share/phpmyadmin/

# 4. Restore config
sudo cp /usr/share/phpmyadmin.backup/config.inc.php /usr/share/phpmyadmin/

# 5. Fix permissions
sudo chown -R www-data:www-data /usr/share/phpmyadmin

2. Monitor Security Advisories

  • Subscribe to phpMyAdmin security mailing list
  • Check https://www.phpmyadmin.net/security/
  • Follow @phpmyadmin on Twitter

3. Regular Backups

# Backup phpMyAdmin configuration
sudo cp /usr/share/phpmyadmin/config.inc.php ~/phpmyadmin-config.backup

# Backup phpMyAdmin database
mysqldump -u root -p phpmyadmin > phpmyadmin-db-backup.sql

4. Clean Temporary Files

# Remove old session files
sudo find /var/lib/php/sessions -name 'sess_*' -mtime +7 -delete

# Clean phpMyAdmin temp directory
sudo rm -rf /usr/share/phpmyadmin/tmp/*

5. Review Access Logs

# Check for suspicious activity
sudo grep phpmyadmin /var/log/apache2/access.log | grep -E "404|401|403"
sudo grep phpmyadmin /var/log/nginx/access.log | grep -E "404|401|403"

# Check for brute force attempts
sudo grep "Access denied" /var/log/mysql/error.log

Performance Optimization:

PHP Configuration:

# /etc/php/*/apache2/php.ini
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
post_max_size = 128M
upload_max_filesize = 128M

# Enable OPcache
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

MySQL Configuration:

# /etc/mysql/mysql.conf.d/mysqld.cnf (Ubuntu/Debian)
# /etc/my.cnf.d/server.cnf (RHEL/CentOS)

[mysqld]
max_connections = 100
connect_timeout = 10
wait_timeout = 600
max_allowed_packet = 64M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 64M
max_heap_table_size = 64M

Monitoring:

# Check web server status
sudo systemctl status apache2  # or httpd or nginx

# Check database status
sudo systemctl status mysql  # or mariadb

# Monitor disk space
df -h /usr/share/phpmyadmin
df -h /var/lib/mysql

# Monitor memory usage
free -h

# Check failed login attempts
sudo grep "Access denied" /var/log/mysql/error.log | tail -n 20

Best Practices Summary

✓ Security Checklist:
  • Change default /phpmyadmin URL to custom path
  • Restrict access by IP address
  • Add HTTP authentication layer
  • Use HTTPS (SSL/TLS) - mandatory!
  • Disable root login to phpMyAdmin
  • Keep phpMyAdmin updated
  • Set proper file permissions (640 for config.inc.php)
  • Enable fail2ban for brute force protection
  • Regular security audits and log reviews
  • Use strong blowfish secret
✓ Performance Checklist:
  • Enable PHP OPcache
  • Configure adequate PHP memory limits
  • Optimize MySQL/MariaDB configuration
  • Use latest PHP version supported
  • Clean temporary files regularly
✓ Maintenance Checklist:
  • Subscribe to security advisories
  • Backup config.inc.php regularly
  • Update phpMyAdmin when releases available
  • Monitor access logs for suspicious activity
  • Test backups and disaster recovery procedures

← Back to LAMPS Index ↑ Back to EXPANDED