Hướng Dẫn Cài Đặt và Quản Lý Website Với aaPanel
Giới Thiệu Về aaPanel
aaPanel là control panel miễn phí, mạnh mẽ và dễ sử dụng cho Linux server. Được phát triển dựa trên BT-Panel của Trung Quốc, aaPanel cung cấp giao diện web trực quan để quản lý:
- 🌐 Multiple websites (Nginx/Apache)
- 🗄️ Databases (MySQL, PostgreSQL, MongoDB)
- 🔐 SSL Certificates (Let's Encrypt tích hợp)
- 📊 Server monitoring
- 🔒 Firewall và security
- 📁 File manager
- ⚙️ Cron jobs và tasks
So sánh với các control panels khác:
| Feature | aaPanel | cPanel | Plesk | Webmin |
|---|---|---|---|---|
| Giá | Free | $15-45/tháng | $10-45/tháng | Free |
| Giao diện | Modern | Good | Excellent | Basic |
| Dễ sử dụng | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
| Resource usage | Thấp | Cao | Trung bình | Thấp |
![Screenshot aaPanel dashboard - Đặt ảnh tại /static/img/control-panel/aapanel-dashboard.png]
Thời gian thực hiện: 45-60 phút
Độ khó: Dễ đến Trung bình
Yêu cầu: Clean Ubuntu/CentOS server, 1GB+ RAM
Phần 1: Cài Đặt aaPanel
Yêu Cầu Hệ Thống
OS: Ubuntu 18.04+, Debian 9+, CentOS 7+, Fedora
RAM: 512MB minimum (khuyến nghị 1GB+)
Disk: 10GB+ free space
Network: Public IP address
⚠️ Quan trọng: Cài aaPanel trên CLEAN SERVER (chưa cài web server, PHP, MySQL)
Bước 1: Chuẩn Bị Server
# Update system
sudo apt update && sudo apt upgrade -y
# Kiểm tra hostname
hostname
hostnamectl
# Set hostname nếu cần
sudo hostnamectl set-hostname server.example.com
# Kiểm tra timezone
timedatectl
# Set timezone
sudo timedatectl set-timezone Asia/Ho_Chi_Minh
Bước 2: Cài Đặt aaPanel
Cho Ubuntu/Debian:
# Download và chạy script cài đặt
wget -O install.sh http://www.aapanel.com/script/install-ubuntu_6.0_en.sh && sudo bash install.sh aapanel
Cho CentOS:
yum install -y wget && wget -O install.sh http://www.aapanel.com/script/install_6.0_en.sh && bash install.sh aapanel
Script sẽ:
- Kiểm tra OS compatibility
- Cài đặt dependencies
- Download và install aaPanel
- Cấu hình firewall
- Tạo random admin credentials
Quá trình cài đặt mất khoảng 5-10 phút.
![Screenshot quá trình cài đặt - Đặt ảnh tại /static/img/control-panel/aapanel-install-process.png]
Bước 3: Lưu Thông Tin Đăng Nhập
Sau khi cài xong, terminal sẽ hiển thị:
==================================================================
Congratulations! Installed successfully!
==================================================================
aaPanel Internet Address: http://123.45.67.89:7800/a1b2c3d4
aaPanel Internal Address: http://10.0.0.5:7800/a1b2c3d4
username: admin
password: 12345678
Warning:
If you cannot access the panel,
release the following port (7800|888|80|443|20|21) in the security group
==================================================================
⚠️ LƯU THÔNG TIN NÀY AN TOÀN!
Bước 4: Cấu Hình Firewall
# UFW (Ubuntu/Debian)
sudo ufw allow 7800/tcp comment 'aaPanel'
sudo ufw allow 80/tcp comment 'HTTP'
sudo ufw allow 443/tcp comment 'HTTPS'
sudo ufw allow 21/tcp comment 'FTP'
sudo ufw allow 20/tcp comment 'FTP Data'
sudo ufw allow 888/tcp comment 'phpMyAdmin'
# Firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --zone=public --add-port=7800/tcp
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --permanent --zone=public --add-port=443/tcp
sudo firewall-cmd --permanent --zone=public --add-port=21/tcp
sudo firewall-cmd --permanent --zone=public --add-port=888/tcp
sudo firewall-cmd --reload
Nếu dùng cloud provider (AWS, GCP, Azure):
- Mở security group cho các ports trên
- Whitelist IP của bạn cho port 7800
Bước 5: Truy Cập aaPanel
- Mở browser:
http://YOUR-SERVER-IP:7800/random-string - Login với credentials từ bước 3
- Đổi password ngay lập tức
- Đọc và accept terms of service
![Screenshot aaPanel login page - Đặt ảnh tại /static/img/control-panel/aapanel-login.png]
Phần 2: Cài Đặt LNMP/LAMP Stack
Sau khi login lần đầu, aaPanel sẽ hiển thị wizard để chọn stack.
Option 1: LNMP (Nginx + MySQL + PHP) - Khuyến Nghị
Ưu điểm:
- Performance cao
- Xử lý concurrent connections tốt
- Resource usage thấp hơn Apache
Cấu hình khuyến nghị:
Web Server: Nginx 1.22
Database: MySQL 5.7 (hoặc MariaDB 10.6)
PHP: PHP 8.1, 7.4 (multiple versions)
Cache: Redis 7.0, Memcached
phpMyAdmin: Latest
Option 2: LAMP (Apache + MySQL + PHP)
Ưu điểm:
- Hỗ trợ .htaccess tốt hơn
- Plugin/module ecosystem lớn
- Tương thích cao với legacy apps
Cài Đặt Stack
-
Chọn stack (LNMP hoặc LAMP)
-
Chọn phiên bản cho từng component
-
Select compile mode:
- Fast: Binary installation (5-10 phút) - Khuyến nghị
- Compile: Source compilation (30-60 phút) - Tối ưu hơn
-
Click One-click Install
![Screenshot stack installation - Đặt ảnh tại /static/img/control-panel/aapanel-stack-install.png]
Theo dõi quá trình cài đặt:
- Top menu → Tasks
- Xem real-time logs
# Hoặc theo dõi từ SSH
tail -f /tmp/panelBoot.pl
# Check services status
bt status
Phần 3: Tạo và Quản Lý Website
Bước 1: Thêm Website Mới
- Menu bên trái → Website → Add site
- Điền thông tin:
Domain: example.com
Subdomain: www (optional)
Root Directory: /www/wwwroot/example.com
FTP: Create (tự động tạo FTP account)
Database: Create (tự động tạo database)
PHP Version: 8.1
- Click Submit
![Screenshot add website form - Đặt ảnh tại /static/img/control-panel/aapanel-add-site.png]
Bước 2: Cấu Hình Domain
Thêm multiple domains:
- Click vào website → Settings → Domains
- Add domains/subdomains:
example.com
www.example.com
blog.example.com
Redirect www → non-www:
- Settings → Redirect
- Select:
Redirect www to non-www - Enable 301 Permanent Redirect
Bước 3: Upload Website Files
Method 1: File Manager (GUI)
- Website → Click site → File Manager
- Navigate to
/www/wwwroot/example.com - Upload files (drag & drop hoặc click Upload)
- Extract nếu upload file .zip
Method 2: FTP
# Từ local machine
ftp your-server-ip
# Login với FTP credentials (xem trong aaPanel)
Name: example.com_ftp
Password: xxxxx
# Upload files
cd /www/wwwroot/example.com
put index.html
put -r src/
Method 3: Git Deployment
# SSH vào server
ssh root@your-server-ip
# Navigate to website directory
cd /www/wwwroot/example.com
# Clone repository
git clone https://github.com/username/repo.git .
# Set permissions
chown -R www:www /www/wwwroot/example.com
chmod -R 755 /www/wwwroot/example.com
Bước 4: Cấu Hình PHP
Enable PHP Extensions:
- App Store → PHP → Click version (e.g., 8.1) → Install Extensions
- Install common extensions:
✓ opcache (performance)
✓ redis (caching)
✓ imagick (image processing)
✓ memcached
✓ swoole (async/coroutine)
✓ mongodb
✓ fileinfo
Chỉnh sửa php.ini:
- App Store → PHP → Settings → Configuration
- Key settings:
; Memory limit
memory_limit = 256M
; Upload size
upload_max_filesize = 64M
post_max_size = 64M
; Execution time
max_execution_time = 300
max_input_time = 300
; Performance
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
; Security
expose_php = Off
display_errors = Off
log_errors = On
- Save → Restart PHP
Disable Functions (Security):
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
Bước 5: Cấu Hình Database
Access phpMyAdmin:
- Menu → Database → phpMyAdmin
- Or:
http://your-server-ip:888
Tạo Database từ Panel:
- Database → Add database
- Fill form:
Database Name: example_db
Username: example_user
Password: StrongPass123!
Access Permission: Local server (127.0.0.1)
Import Database:
# Method 1: phpMyAdmin
Upload .sql file (max size theo php.ini)
# Method 2: Command line (cho database lớn)
mysql -u example_user -p example_db < backup.sql
# Method 3: Split large file
split -b 50M backup.sql chunk_
for file in chunk_*; do
mysql -u example_user -p example_db < $file
done
Optimize Database:
-- Check tables
SHOW TABLE STATUS;
-- Optimize tables
OPTIMIZE TABLE table_name;
-- Repair tables
REPAIR TABLE table_name;
-- Analyze tables
ANALYZE TABLE table_name;
Phần 4: SSL Certificate
Option 1: Let's Encrypt (Free SSL)
- Website → Click site → SSL
- Tab Let's Encrypt
- Select domains:
☑ example.com
☑ www.example.com
- Enter email
- Click Apply
- Enable Force HTTPS (redirect HTTP → HTTPS)
Tự động renewal: aaPanel auto-renew 15 ngày trước khi hết hạn.
Verify SSL:
# Check certificate
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
# Test SSL score
curl https://www.ssllabs.com/ssltest/analyze.html?d=example.com
![Screenshot SSL configuration - Đặt ảnh tại /static/img/control-panel/aapanel-ssl.png]
Option 2: Custom SSL Certificate
-
Tab Other Certificate
-
Paste certificate files:
- Certificate (CRT): Your SSL certificate
- Private Key: Private key file
- Certificate Chain: CA bundle
-
Click Save
SSL Best Practices
Hardening SSL/TLS:
- Website → SSL → HTTPS Settings
- Enable:
- ☑ Force HTTPS
- ☑ HSTS (HTTP Strict Transport Security)
- ☑ TLS 1.2 minimum
- ☑ Disable TLS 1.0/1.1
Nginx SSL config:
# Edit site config: /www/server/panel/vhost/nginx/example.com.conf
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_stapling on;
ssl_stapling_verify on;
# HSTS
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
Phần 5: Performance Optimization
1. Enable Caching
Install Redis:
- App Store → Search "Redis"
- Install Redis
- Start service
Configure PHP-FPM:
- App Store → PHP → Settings
- Performance tuning:
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 500
Enable OPcache:
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
2. Nginx Optimization
Edit Nginx config:
# /www/server/nginx/conf/nginx.conf
worker_processes auto;
worker_rlimit_nofile 65535;
events {
worker_connections 10240;
use epoll;
multi_accept on;
}
http {
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml text/javascript
application/json application/javascript application/xml+rss
application/rss+xml font/truetype font/opentype
application/vnd.ms-fontobject image/svg+xml;
# Brotli (nếu có module)
brotli on;
brotli_comp_level 6;
brotli_types text/plain text/css application/json application/javascript;
# Client body buffer
client_body_buffer_size 128k;
client_max_body_size 64m;
# Timeouts
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
# FastCGI cache (WordPress/PHP)
fastcgi_cache_path /tmp/nginx_cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
}
Enable FastCGI Cache cho website:
- Website → Click site → Settings → Performance
- Enable FastCGI Cache
- Set cache time: 60 minutes
3. Database Optimization
MySQL Tuning:
- Database → MySQL → Performance Tuning
- Or edit manually:
sudo nano /etc/mysql/my.cnf
[mysqld]
# InnoDB settings
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
# Query cache
query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M
# Connection settings
max_connections = 200
max_connect_errors = 10000
# Slow query log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow-query.log
long_query_time = 2
Restart MySQL:
bt restart mysql
Phần 6: Security Hardening
1. Change Default Ports
# Change aaPanel port
bt 8
# Enter new port (e.g., 8888)
# Update firewall
sudo ufw allow 8888/tcp
sudo ufw delete allow 7800/tcp
2. Enable Two-Factor Authentication
- Panel Settings → Security
- Enable 2FA
- Scan QR code with Google Authenticator
3. IP Whitelist
- Panel Settings → Security → Allowed IP
- Add your IP addresses:
203.0.113.10 # Office IP
203.0.113.20 # Home IP
4. Install Security Plugins
Nginx WAF (Web Application Firewall):
- App Store → Search "Nginx WAF"
- Install
- Configure rules:
- SQL injection protection
- XSS protection
- File upload restrictions
- Bot protection
Fail2Ban:
# Install Fail2Ban
sudo apt install fail2ban -y
# Create jail for aaPanel
sudo nano /etc/fail2ban/jail.local
[aapanel]
enabled = true
port = 7800
filter = aapanel
logpath = /www/server/panel/logs/error.log
maxretry = 5
bantime = 3600
5. Regular Backups
Cấu hình Automatic Backup:
- Backup → Plan
- Create backup plan:
Type: Full Backup (Website + Database)
Frequency: Daily at 2:00 AM
Retention: 7 days
Storage: Local + Cloud (optional)
Cloud Backup Destinations:
- AWS S3
- Google Drive
- Dropbox
- FTP Server
Manual Backup Script:
#!/bin/bash
# backup-websites.sh
BACKUP_DIR="/backup/websites"
DATE=$(date +%Y%m%d)
# Backup websites
bt backup site example.com
# Backup databases
bt backup database example_db
# Sync to remote server
rsync -avz /www/backup/ backup-server:/backups/
echo "Backup completed: $DATE"
Phần 7: Monitoring và Maintenance
System Monitoring
Dashboard hiển thị:
- CPU usage
- Memory usage
- Disk usage
- Network traffic
- Process list
- Service status
Install Monitoring Tools:
- App Store → System Tools
- Install:
- BT-Monitor: Real-time monitoring
- Process Manager: Kill problematic processes
- Log Cleaner: Auto clean old logs
Log Management
View Logs:
- Files → Navigate to:
Nginx logs: /www/wwwlogs/
PHP logs: /www/server/php/log/
MySQL logs: /www/server/data/
aaPanel logs: /www/server/panel/logs/
Rotate Logs:
# Configure logrotate
sudo nano /etc/logrotate.d/aapanel
/www/wwwlogs/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 0644 www www
sharedscripts
postrotate
/etc/init.d/nginx reload > /dev/null
endscript
}
Scheduled Tasks (Cron)
- Cron → Add Task
- Examples:
# Daily backup at 2 AM
0 2 * * * bt backup site example.com
# Clear cache every 6 hours
0 */6 * * * rm -rf /tmp/nginx_cache/*
# Optimize databases weekly
0 3 * * 0 mysqlcheck -u root -p'password' --optimize --all-databases
# Check SSL expiry
0 0 * * * bt ssl check
Troubleshooting Common Issues
Issue 1: Cannot Access Panel
# Check panel status
bt status
# Start panel
bt start
# Check firewall
sudo ufw status
# Check listening ports
netstat -tulpn | grep 7800
Issue 2: Website Not Loading
# Check Nginx
bt restart nginx
# Check logs
tail -f /www/wwwlogs/example.com.error.log
# Check DNS
nslookup example.com
dig example.com
# Test site config
nginx -t
Issue 3: Database Connection Error
# Check MySQL status
bt status mysql
# Restart MySQL
bt restart mysql
# Check connections
mysql -u root -p -e "SHOW PROCESSLIST;"
# Verify credentials
mysql -u example_user -p example_db
Issue 4: High Resource Usage
# Check top processes
htop
# Check Apache/Nginx processes
ps aux | grep nginx | wc -l
# Check MySQL queries
mysqladmin -u root -p processlist
# Kill problematic process
bt kill process_id
Useful Commands
# aaPanel CLI commands
bt # Main menu
bt status # Check all services
bt restart # Restart services
bt stop # Stop services
bt backup # Backup management
bt ssl # SSL management
bt default # Show default info
bt version # Panel version
bt update # Update panel
# Service management
bt restart nginx
bt restart php-fpm-81
bt restart mysql
bt restart pure-ftpd
# Update panel
bt 16
# Repair panel
bt 7
Best Practices Checklist
☐ Change default panel port
☐ Enable 2FA authentication
☐ Set up IP whitelist
☐ Install WAF
☐ Configure automatic backups
☐ Enable SSL cho all sites
☐ Set up monitoring alerts
☐ Regular security updates
☐ Optimize database monthly
☐ Review logs weekly
☐ Test backup restoration
☐ Document all configurations
Tài Liệu Tham Khảo
Kết Luận
Bạn đã hoàn thành việc cài đặt và cấu hình aaPanel cho production environment. Với control panel này, bạn có thể:
✅ Quản lý multiple websites dễ dàng
✅ Deploy applications nhanh chóng
✅ Monitor server performance
✅ Tự động hóa maintenance tasks
✅ Secure server với best practices
Lưu ý: Thường xuyên backup và update hệ thống để đảm bảo security và stability.
Tags: #aapanel #control-panel #web-hosting #nginx #mysql #ssl #server-management
Cập nhật lần cuối: 19/12/2025
Tác giả: BacPV Docs Team