下面从 Ubuntu 系统层面 和 SQLAdmin 本身 两个角度,讲一下如何“优化 SQLAdmin”(假设你指的是 SQL Admin / 数据库管理界面,常见如 phpMyAdmin、Adminer,或你部署在 Ubuntu 上的 SQL 管理后台)。
sudo apt update && sudo apt upgrade -y
server {
listen 80;
server_name sqladmin.example.com;
root /var/www/sqladmin;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_read_timeout 300;
}
gzip on;
gzip_types text/css application/javascript application/json;
}
启用:
sudo nginx -t
sudo systemctl reload nginx
编辑:
sudo nano /etc/php/8.2/fpm/php.ini
推荐参数:
memory_limit = 512M
max_execution_time = 300
post_max_size = 64M
upload_max_filesize = 64M
opcache.enable=1
opcache.memory_consumption=128
重启 PHP:
sudo systemctl restart php8.2-fpm
[mysqld]
innodb_buffer_pool_size = 1G
max_connections = 200
query_cache_size = 0
slow_query_log = 1
重启数据库:
sudo systemctl restart mysql
location / {
allow 192.168.1.0/24;
deny all;
}
或使用 Basic Auth:
sudo apt install apache2-utils
htpasswd -c /etc/nginx/sqladmin.htpasswd admin
✅ 不要公网直接暴露 SQLAdmin
✅ 使用 HTTPS(Let’s Encrypt)
✅ 定期清理日志
✅ 使用独立数据库用户
我可以给你 更精确的优化方案,比如:
直接告诉我,我可以给你一份 专属 Ubuntu 优化清单。