Chuyển tới nội dung chính

sidebar_position: 1

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ẽ:

  1. Kiểm tra OS compatibility
  2. Cài đặt dependencies
  3. Download và install aaPanel
  4. Cấu hình firewall
  5. 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​

  1. Mở browser: http://YOUR-SERVER-IP:7800/random-string
  2. Login với credentials từ bước 3
  3. Đổi password ngay lập tức
  4. Đọ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​

  1. Chọn stack (LNMP hoặc LAMP)

  2. Chọn phiên bản cho từng component

  3. 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
  4. 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​

  1. Menu bên trái → Website → Add site
  2. Đ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
  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:

  1. Click vào website → Settings → Domains
  2. Add domains/subdomains:
example.com
www.example.com
blog.example.com

Redirect www → non-www:

  1. Settings → Redirect
  2. Select: Redirect www to non-www
  3. Enable 301 Permanent Redirect

Bước 3: Upload Website Files​

Method 1: File Manager (GUI)

  1. Website → Click site → File Manager
  2. Navigate to /www/wwwroot/example.com
  3. Upload files (drag & drop hoặc click Upload)
  4. 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:

  1. App Store → PHP → Click version (e.g., 8.1) → Install Extensions
  2. Install common extensions:
✓ opcache (performance)
✓ redis (caching)
✓ imagick (image processing)
✓ memcached
✓ swoole (async/coroutine)
✓ mongodb
✓ fileinfo

Chỉnh sửa php.ini:

  1. App Store → PHP → Settings → Configuration
  2. 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
  1. 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:

  1. Menu → Database → phpMyAdmin
  2. Or: http://your-server-ip:888

Tạo Database từ Panel:

  1. Database → Add database
  2. 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)​

  1. Website → Click site → SSL
  2. Tab Let's Encrypt
  3. Select domains:
☑ example.com
☑ www.example.com
  1. Enter email
  2. Click Apply
  3. 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​

  1. Tab Other Certificate

  2. Paste certificate files:

    • Certificate (CRT): Your SSL certificate
    • Private Key: Private key file
    • Certificate Chain: CA bundle
  3. Click Save

SSL Best Practices​

Hardening SSL/TLS:

  1. Website → SSL → HTTPS Settings
  2. 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:

  1. App Store → Search "Redis"
  2. Install Redis
  3. Start service

Configure PHP-FPM:

  1. App Store → PHP → Settings
  2. 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:

  1. Website → Click site → Settings → Performance
  2. Enable FastCGI Cache
  3. Set cache time: 60 minutes

3. Database Optimization​

MySQL Tuning:

  1. Database → MySQL → Performance Tuning
  2. 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​

  1. Panel Settings → Security
  2. Enable 2FA
  3. Scan QR code with Google Authenticator

3. IP Whitelist​

  1. Panel Settings → Security → Allowed IP
  2. 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):

  1. App Store → Search "Nginx WAF"
  2. Install
  3. 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:

  1. Backup → Plan
  2. 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:

  1. App Store → System Tools
  2. Install:
    • BT-Monitor: Real-time monitoring
    • Process Manager: Kill problematic processes
    • Log Cleaner: Auto clean old logs

Log Management​

View Logs:

  1. 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)​

  1. Cron → Add Task
  2. 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

Xem thêm: